项目作者: oksbwn

项目描述 :
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.
高级语言: C++
项目地址: git://github.com/oksbwn/Linkit7688-Python-Firmata-MQTT-Example.git


DHT12 Connection Diagram:-

Imgge

Dependencies:-

  1. Firmata library for Python Pymata
    1. pip install pymata
  2. MQTT Client Library for Python Eclipse Paho
    1. pip install paho-mqtt

    Run on Boot:-

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,

  1. #!/bin/sh /etc/rc.common
  2. START=98
  3. start(){
  4. ubus -t 60 wait_for network.interface network.interface.loopback # Makes sure network is up
  5. echo "Starting the DHT12 Sensor Script"
  6. python /root/sensor.py &
  7. }

Make the file executable and enable it,

  1. chmod +x /etc/init.d/dht12
  2. /etc/init.d/dht12 enable

Now you can reboot the module and can see the sensor data getting published to the provided topic.