In a post about accessing Amazon Web Services from Node-RED that I wrote for another device, I claimed that it would also work on a Raspberry Pi. I wrote that without testing. I guess I'll have to put the money where the mouth is, and show that the claim is true. Let's install Node-RED on a Pi and communicate with Amazon Web Services.
|
Starting Position: Fresh Raspbian Stretch Lite with Node-RED and AWS Nodes
- Raspbian Stretch Light installed, latest version (at the time of writing: 2019-04-08-raspbian-stretch-lite).
- Headless configured following these instructions: https://hackernoon.com/raspberry-pi-headless-install-462ccabd75d0 .
- Node-RED installed following these instructions: https://nodered.org/docs/hardware/raspberrypi .
- I added the AWS MQTT Node library: https://flows.nodered.org/node/node-red-contrib-aws-iot-hub . (take care to run the installation from
/home/pi/.node-red).
- Start Node-RED following the instructions above, and in your browser surf to http://<yourpi>:1880/.
Register Raspberry Pi as A Thing, Test with AWS Test Kit and Install Certificates
I followed my own instructions to configure the Raspberry Pi as a Thing in AWS and test it with the AWS Test Kit.
Follow these two sections: Set up the Node-RED Container as an AWS Thing and Adapt the Security Policy.
Where you see harting_mica_nodered, use rapsberrypi.
In the raspberrypi-Policy, make sure to add client/raspberrypi* instead of client/harting_mica_nodered*.
Testing the Exchange with AWS and Node-RED
I'm again using the test flow from my Harting Mica blog. Only the certificate directory name, endpoint and client id are different:
After Deploying the flow, use the IoT Core Test MQTT page to shoot a message to topic_1.
Yes. Success. Enjoy.
Need inspiration? To see what you can do with your (sensor?) data once it arrived at AWS, check: Manage Arduino MKR WIFI 1010 Battery Life in the Cloud - AWS, Graphs and Alerts.