Search code examples
raspberry-piibm-cloudiotnode-redwatson-iot

Sending commands back to raspberry pi from bluemix node red


I am reading sensor values from Raspberry Pi 2 and sending it to bluemix IoT platform using node-red application on the Pi. After monitoring the values, I would like to send the command back to raspberry pi from the node red starter in the bluemix to control the GPIO on the Pi using node red application on the Pi.

I am able to send the data from the raspberry pi to the Bluemix using Node Red, and the data is also displayed on the node red starter in Bluemix (ibmiotin node). But the command from the bluemix to the Pi is not being sent.

When I try to send command by using the inject node to the PI, then the command is sent perfectly, but when I use the sensor input node to send the command, the command is not sent to the device.

Is there any criteria in the Bluemix that the same device can't be used for sending and receiving the data simultaneously?

How can I send the data back to the raspberry pi using the bluemix node-red starter?

P.S. Both the devices(sensor and Pi) are shown as connected in the IoT dashboard and also in node-red.

The image of my node red in bluemix is as shown below.

enter image description here


Solution

  • I just needed to add a json node before the ibmiot out node to send the commands to the device.

    This solved the problem.

    The updated flowenter image description here is follows: