About
Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.
Usage
To simulate Device and Server we can use Node red and publish and subscribe MQTT topics to send and receive messages.
https://cookbook.nodered.org/mqtt/connect-to-broker#problem
Installation
- Install Docker(Prerequisite)
- Install NodeRED using – https://nodered.org/docs/getting-started/docker
- Once installed you can then browse to http://{host-ip}:1880 to get the familiar Node-RED desktop.
- NODE-RED is now ready to be used.

Using with AWS
- We can use X.509 certificate to connect to AWS IOT Core system
- Create a certificate, download Private Key, Public key, Certificate and store it at local file
- Download CA certificate for server authentication from
https://docs.aws.amazon.com/iot/latest/developerguide/server-authentication.html
https://www.amazontrust.com/repository/AmazonRootCA1.pem - Create a policy(Connect, publish and subscribe privileges should be with policy)
- Create a thing.
- Attach Policy to Certificate and Certificate to Thing.
- Now Open Node-Red http://{host-ip}:1880
- Start creating flow
- Select an mqtt out node and drag it to dashboard as shown.

- Double click on Node and start configuring.
- Select topic to publish, qos level, give a name to server and then select add-new-mqtt-broker and click on edit button as shown.

- Provide AWS server endpoint(You can get it from IOT core → settings), port = 8883, tick enable SSL/TLS connection, select “Use legacy mqtt support 3.1”, and Give name to this MQTT broker as shown

- Click on TLS configration and add new TLS configuration
- Name the TLS configuration, Add private key, Add public certificate and Amazon Root CA1 certificate.
[Note- Due to some issue we are not able to validate server certificate so untick Verify server certificate] - Save the configuration
- Once configuration is saved you can see Node connected to AWS as shown –

- Now add Inject node and configure json data to be passed to AWS MQTT broker and connect it with Broker, Along with it add Debug node for debugging purpose and conncet Inject node to Debug as shown –

- Now your MQTT client is ready to be used.
- Click on push button left to Inject Node to push data.