1
votes

I registered my Raspberry Pi with IBM Bluemix successfully . It has dht22 temp and humidity sensor connected to it and running.

Question: While building Internet of things starter app , do i need to code anything on Rpi to push that sensor data into Bluemix or simply providing the MAC address and the API will do the trick?

Note: I followed a recipe to configure my Raspberry Pi , registered with the MAC address. It is connected and sending messages when i check in the device.

Kindly let me know if i need to do any other configuration or coding to send specifically my dht22 sensor data to visualize in Bluemix and use it in Node-red.

4
I modified the Raspberry Pi recipe for a dht11 recently, take a look: github.com/vmorris/iot-raspberrypiholocron

4 Answers

3
votes

By default Raspberry Pi recipe sends only the CPU temperature and CPU load. As there are no sensors present in Raspberry Pi by default, the recipe uses parameters like CPUTemp and CPULoad.

In your case, you will need to update the code to include dht22 temp and humidity parameters to be sent to IoTF(Bluemix). Please check the code in Github for the raspberry Pi recipe - https://github.com/ibm-messaging/iot-raspberrypi

Navigate to samples/c for the recipe code. You will have to gather the dht22 sensor data and convert them to JSON and send it to IoTF.

  1. In the iot.h, update the json struct to include your sensor values. You can remove the cputtemp and cpuload parameters if you dont need them.

  2. In iotmain.c, line 152 update the code with the code to gather the dht22 sensor values.

  3. In jsonator.c, update the new sensor values based on your new struct.

Then follow the steps provided here to compile the code and install the new deb file. Now the iot service will send data with dht22 sensor values.

0
votes

If the Bluemix IOT console is showing the that the device is connected and sending data then you should not need to do anything more on the Raspberry Pi.

You will need to bind the IOT service to your Node-RED instance (assuming you are running Node-RED on Bluemix) to access the data.

0
votes

I believe the recipe you used was this one: https://developer.ibm.com/iot/recipes/raspberry-pi/

Per the readme in the source code, the events that are emitted in this sample are:

CPU temperature
CPU Load
Simulated Sine wave to demonstrate the different events can be pushed to IoT Portal and visualized.

If you are trying to capture other items such as humidity you may need to create additional code/logic.

0
votes

I have an ansible role to register raspberrypi, fyr https://github.com/reachlin/fangge/tree/master/ansible/roles/iot

You have to replace your credentials in file defaults/main.yml

ORG:xxx
TYPE:xxx
ID:xxx
AUTH:token
TOKEN:xxx