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.
- In the Bluemix dashboard, select your Watson IoT boilerplate application. Then, click Overview on the left navigation.
- Under Connections, select the existing Cloudant NoSQL database engine.
- In the Cloudant service dashboard, click Launch. Then, add a new database by clicking Create Database and name it
temperatures. Then, click Create.
- 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:
- Connect the cloudant out node and function node to the previously created Node-RED flow at the output of the temp node.
- 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();
- Optional: Reposition the nodes on the palette to make the flow easier to follow.
- Redeploy the Node-RED flow.
- To see how the temperatures are being recorded, open the Cloudant database Dashboard and review the temperature records:
- 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.