A simple framework for viewing and receiving data from sensors on a Raspberry Pi.
-
Install Required Python Libraries
Connect to your Raspberry Pi as the pi user and use the following command to install neccissary Python modules.
sudo apt-get install python-twisted python-lxml -
Clone Repository
Clone the contents of the repository to the home directory for the pi user on the Raspberry Pi.
cd ~ git clone https://github.com/CrackerStealth/pi-sensor-service.git -
Create Config File
If this the first time install of the software, create a new config file using the sample JSON file.
cd ~/pi-sensor-service cp config.json.sample config.jsonConfigure any sensors you want to be accessible through the XML service.
-
Configure SSL Certificates
In order for secure communication to be allowed, the controller application needs SSL certificates. By default, the service expects the certificate and key to be at
/home/pi/pi-sensor-service-cert/localhost.crtand/home/pi/pi-sensor-service-cert/localhost.keyrespectively. You can either update the locations in the config file or place these items at these locations.To quickly generate SSL certificates for testing, do the following:
mkdir -p /home/pi/pi-sensor-service-cert openssl req -new -x509 -days 3650 -nodes -out /home/pi/pi-sensor-service-cert/localhost.crt -newkey rsa:4096 -sha256 -keyout /home/pi/pi-sensor-service-cert/localhost.key -subj "/CN=localhost" chmod 700 /home/pi/pi-sensor-service chmod 600 /home/pi/pi-sensor-service/* -
Configure The Auto-start Service
This software expects a recent version of Raspian that is using systemd.
sudo cp /home/pi/pi-sensor-service/extra/pisensorserviced.service /lib/systemd/system sudo chmod 644 /lib/systemd/system/pisensorserviced.service sudo systemctl daemon-reload sudo systemctl enable pisensorserviced.service sudo systemctl start pisensorserviced.service
-
Wi-Fi Auto-Reconnection Script
Occassionally, when using Wi-Fi, a network connection might get dropped causing access to the garage controller to become unavailable. If you are using the Raspberry Pi built in Wi-Fi interface, you can use the included connection script to re-connect when this happens.
To use the re-connection script, modify the root crontab:
sudo crontab -eAdd the following line to check every 5 minutes for a proper connection. Replace 192.168.1.1 with the IP address of your router/gateway or another computer to check against.
*/5 * * * * sh /home/pi/pi-sensor-service/extra/check-wifi-connection.sh 192.168.1.1 >/dev/null 2>&1