- Firmata library for Python Pymata
pip install pymata
- MQTT Client Library for Python Eclipse Paho
pip install paho-mqtt
To make the Python script run on boot I have used InitScripts, to creare the job follow the following commands, (Its a basic script and doesnot have error handling and all)
vi /etc/init.d/dht12
Paste the followinf content,
#!/bin/sh /etc/rc.common
START=98
start(){
ubus -t 60 wait_for network.interface network.interface.loopback # Makes sure network is up
echo "Starting the DHT12 Sensor Script"
python /root/sensor.py &
}
Make the file executable and enable it,
chmod +x /etc/init.d/dht12
/etc/init.d/dht12 enable
Now you can reboot the module and can see the sensor data getting published to the provided topic.