Skip to end of metadata
Go to start of metadata

Component list


  1. BeagleBone Black
  2. DHT11/22 or AM2302 temperature and humidity sensor
  3. 4.7K or 10K resistor
  4. Breadboard
  5. Jumper wires

1. BBB and sensor Hardware preparation


To prepare BBB hardware and software for sendor use tutorial under link Temperature monitoring with BeagleBoneBlack and DHT11/22 and AM2302 temperature and humidity sensor .

You only need to follow the steps from 1 to 5. Assuming that now we have the working scripts read_temperature.py and read_humidity.py you can follow the instructions given below.

2. GadgetKeeper configuration


Follow the Instructions in Implement Remote Property to implement the remote property.

On step 2. "Create MQTT connection to device",  set "Response, ms" to 60000 ms

 

3. MQTT client preparation


  1. create a directory MQTT

  2. Download the mosquitto from this site or simply use the following command. http://mosquitto.org/download/

  3. I used this mosquitto-1.0.2.tar.gz version for this tutorial
  4. Follow these commands to install mosquitto

  5. If it fails the compile process try the following supportive commands on the terminal to install the dependency libraries. Then compile again

  6. Next step is to prepare the MQTT client script to communicate with gadgetkeeper MQTT server. Following Python script can be used to do it. First go to the gadgetkeeper directory we created on the Temperature monitoring with BeagleBoneBlack and DHT11/22 and AM2302 temperature and humidity sensor tutorial. Then create a file as follows

    Then paste the following Python code on it.

  7. Now simply run this script as follows

  8. Make sure that port 1883 is not blocked by the firewall.

4. Test communication


Now you can use the "Get property value" step on the Implement Remote Property .Simply click on "Get" button and it should fetch the new value (Temperature or Humidity) from the BBB via the MQTT protocol.

Sensor read error will be shown as below (If the sensor is not available or fetching the temperature or humidity value from the sensor is failed, then the following response will be received from the MQTT client. You can assign any value for this as the error code on the python script. I have used -1000 to indicate error readings)

Successful communication between user and server you can see below.