Files
2024-11-09 17:55:28 +01:00
..
2016-10-08 18:26:11 +02:00
2016-10-08 16:51:12 +02:00
2016-06-08 10:03:17 +02:00
2016-06-08 08:24:43 +02:00
2016-06-08 10:34:05 +02:00
2017-11-16 20:33:07 +01:00
2024-11-09 17:55:28 +01:00
2016-01-24 09:15:14 +01:00
2016-10-08 16:55:15 +02:00

Tfm Controller - little thingy that reads sensors, runs motors and communicates with the cloud

Installation

mkdir projects
git clone https://github.com/senaduka/tfm
  1. Go to every subdirectory in drivers directory and follow instructions about installation of drivers
/home/pi/projects/tfm/controller/drivers/adafruit# cat README.md
  1. edit controller/config/init.py and set your controller ID to unique number
  2. configure cron to run controller.py every 15 minutes as a superuser:
crontab -e -u root
#enter these lines
*/5 * * * * cd /home/pi/projects/tfm/controller && sh activity.sh
*/30 * * * * /usr/bin/python /home/pi/projects/tfm/controller/network_check.py
*/1 * * * *  /usr/bin/python /home/pi/projects/tfm/controller/camera_capture.py                  
  1. add following lines at the end of /etc/rc.local before "exit 0"
python /home/pi/projects/tfm/controller/lockdown.py
python /home/pi/projects/tfm/controller/dweet.py
  1. create directory
mkdir -p /mnt/zoblakdata
  1. add following line to /etc/fstab for ramdisk
tmpfs   /mnt/zoblakdata        tmpfs   nodev,nosuid,size=100M          0  0
  1. install packages
sudo apt-get update
sudo apt-get install libav-tools
  1. set timezone
sudo cp /usr/share/zoneinfo/Europe/Sarajevo /etc/localtime
sudo ntpd -gq
  1. to set 3g mode
sudo apt-get install usb-modeswitch ppp

cd
mkdir umtskeeper
cd umtskeeper
wget "http://mintakaconciencia.net/squares/umtskeeper/src/umtskeeper.tar.gz"
tar -xzvf umtskeeper.tar.gz
chmod +x sakis3g umtskeeper

#add following line at the end of /etc/rc.local before "exit 0" (USBMODEM='12d1:1506' is a VARIABLE visible by issuing the command: lsusb):
sudo /home/pi/umtskeeper/umtskeeper --sakisoperators "USBINTERFACE='0' OTHER='USBMODEM' USBMODEM='12d1:1506' SIM_PIN='0000' APN='CUSTOM_APN' CUSTOM_APN='active.bhmobile.ba' APN_USER='0' APN_PASS='0'" --sakisswitches "--sudo --console" --devicename 'Huawei' --log --silent --monthstart 1 --nat 'no' --sakismaxfails 20 --httpserver &>> /home/pi/umtskeeper/error.log
  1. to set up vpn
install openVPN on the client

generate vpn certificate, key and config (ovpn) files on server (see STEP 3: https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04)

unify the OpenVPN profile (see STEP 4: https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04)

transfer them to the client (WinSCP or a similar tool, maybe need to copy the key files to another directory, "chmod 644 [filename]" for the .key file in order to transfer it - see STEP 4: https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-14-04)

edit /etc/rc.local add the line
openvpn --daemon --cd /etc/openvpn --config zoblakFarmAlarmAmirZepce01.ovpn
before "exit 0" in order to start the vpn daemon on startup, where zoblakFarmAlarmAmirZepce01.ovpn is the generated conf file

p.s. just for reference, the setting whether the client is using local or remote gw for internet access is being set for all clients in the /etc/openvpn/server.conf file on the server - comment or uncomment line ;push "redirect-gateway def1 bypass-dhcp"
  1. to set up the hardware watchdog
please follow this guide (it is valid for RPI3!): 
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=147501

please note that in the /etc/watchdog.conf it is sufficient to uncomment these lines:
max-load-1              = 24
watchdog-device = /dev/watchdog

furthermore, this can be added at the end o the file:
# I added the following command to get rid of a pesky error message
watchdog-timeout=15

  1. multiple cameras support
as multiple cameras need to be combined and avconv does not support the appropriate functionality an additional tool must be installed

1. apt-get update
2. sudo apt-get install imagemagick

this is being used in /controller/config/__init__.py PICTURE_COMMAND when executing the "convert" command while combining multiple images
  1. set up fixed IP addresses (rpi3):
Edit /etc/dhcpcd.conf as follows:-

 Here is an example which configures a static address, routes and dns.
       interface eth0
       static ip_address=192.168.1.6/24
       static routers=192.168.1.1
       static domain_name_servers=192.168.1.1

       interface wlan0
       static ip_address=192.168.1.7/24
       static routers=192.168.1.1
       static domain_name_servers=192.168.1.1
  1. set up w1 thermometer sensing
DS18B20
W1-thermometer sensing on RPI3

wiring schema: https://cdn-learn.adafruit.com/downloads/pdf/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing.pdf (firrt schema - I used GPIO BCN #17)
edit /boot/config.txt - at the end insert (rpi2 doesn't need the gpiopin, but rpi3 does! see for more info: http://raspberrypi.stackexchange.com/questions/37157/ds18b20-no-longer-working, rpi would need only: dtoverlay=w1-gpio):
dtoverlay=w1-gpio-pullup,gpiopin=17

reboot
issue the following commands, the last directory has a variable name, based on the sensor's serial number!
sudo modprobe w1-gpio
sudo modprobe w1-therm
cd /sys/bus/w1/devices
ls
cd 28-xxxx (change this to match what serial number pops up)
cat w1_slave