Add a Cloudant database to store temperature data

In addition to adding Twitter notifications, you can add a Cloudant database node to store the temperature data. Then, you might want to read that data from your smart device when you want to validate what is happening with your physical temperature sensor and follow up with your social network followers.

  1. In the Bluemix dashboard, select your Watson IoT boilerplate application. Then, click Overview on the left navigation.
  2. Under Connections, select the existing Cloudant NoSQL database engine.
  3. In the Cloudant service dashboard, click Launch. Then, add a new database by clicking Create Database and name it temperatures. Then, click Create.
  4. storage, drag a cloudant out node onto the canvas. Be sure to use the cloudant out node with the Cloudant logo on the right as shown in the following screen capture. Then, double-click it to add data to the internal Cloudant database by using the following values:
    • Database: temperatures
    • Operation: insert


  5. Connect the cloudant out node and function node to the previously created Node-RED flow at the output of the temp node.
  6. Configure the timestamp node to add the time to the temperature in the msg.payload to insert it in the Cloudant database:
    msg.timestamp= new Date().toISOString();
    return msg;
  7. Optional: Reposition the nodes on the palette to make the flow easier to follow.
  8. Redeploy the Node-RED flow.
  9. To see how the temperatures are being recorded, open the Cloudant database Dashboard and review the temperature records:
  10. If you can see the records as shown above, you are ready to build an iOS app that has a UI to display the temperatures that are sent from the Cloudant database.