Example of using Python to interact with I2C sensor with Firmata to read data from the Atmega32u4 controller and publish the smae using MT7688 MPU available in the Linkit7688 DUO module.
pip install pymata
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.