https://github.com/vyshakhbabji/wiliot-developer-docs/tree/master/demos/wiliot-demo-mqtt-nodejs
This sample app demonstrates how to use Wiliot MQTT connection to receive events from Wiliot Cloud Platform.
- Node.js installed on your machine
- A Wiliot account. If you don't have one, you can sign up here.
- A Wiliot device. If you don't have one, you can buy one here.
- HiveMQ MQTT configuration setup. Please follow the guide hiveForMQTTUrl.md
-
Clone this repository to your local machine.
-
Change directory to demos/wiliot-demo-mqtt-nodejs
$ cd demos/wiliot-demo-mqtt-nodejs
- Run the following command to install the dependencies:
$ npm install
- Configure .env file with your HiveMQ MQTT configuration credentials. Please follow the guide hiveForMQTTUrl.md
4. Run the following command to start the app:
```bash
$ npm start
- When you test the MQTT on Wiliot's management portal, you should see the events as output in the terminal:
vyshakhbabji@Vyshakhs-Mini wiliot-demo-mqtt-nodejs % npm start
> node-mqtt@1.0.0 start
> node index.js
Connected
Received message: 7B022D35-7373-489D-8503-C4266BFA7E32 {"eventName":"connectivity","value":"0","startTime":"1676000191728","endTime":"0","ownerId":"607737204301","createdOn":"1676000191986","assetId":"7B022D35-7373-489D-8503-C4266BFA7E32","categoryID":"12","confidence":"1.00","keySet":"[(key:connectivity,value:0)]"}