Files
iot-architeture/README.md

42 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Setup environment
**20 October 2022**
> Arch
```
sudo pacman -S nodejs npm
```
> Check installation
```
╭─ehofmann@ncc-1733 in repo: iot-architeture on  master [?] took 341ms
[🔴] × node --version && npm --version
v16.16.0
8.19.2
```
> install node-red
```
╭─ehofmann@ncc-1733 in repo: iot-architeture on  master [?] took 15s
╰─λ sudo npm install -g --unsafe-perm node-red
```
> start node-red
```
node-red
```
> install mosquitto
```
sudo pacman -S mosquitto
sudo systemctl start mosquitto
```
> load the test code
```
[{"id":"6aa3baf4.0d1874","type":"tab","label":"Event to mqtt broker","disabled":false,"info":""},{"id":"63e03741.5d6cf8","type":"inject","z":"6aa3baf4.0d1874","name":"Injecting true","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"10","topic":"","payload":"true","payloadType":"bool","x":110,"y":120,"wires":[["398df5fb.e9e4ea"]]},{"id":"398df5fb.e9e4ea","type":"function","z":"6aa3baf4.0d1874","name":"Device Payload","func":"\nvar longitude1 = 24.0456;\nvar latitude1 = 60.123;\n\n// Array of pseudo random temperatures\nvar temp1 = [15,17,18.5,20,21.5,23,24,22.2,19,18];\n\n// Array of pseudo random relative humidities\nvar humidity1 = [50,55,61,68,65,60,53,49,45,47];\n\n// Counter to select from array.\nvar counter1 = context.get('counter1')||0;\ncounter1 = counter1+1;\nif(counter1 > 9) counter1 = 0;\ncontext.set('counter1',counter1);\n\n// Create MQTT message in JSON\nmsg = {\n payload: JSON.stringify(\n {\n d:{\n \"temp\" : temp1[counter1],\n \"humidity\" : humidity1[counter1],\n \"location\" :\n {\n \"longitude\" : longitude1,\n \"latitude\" : latitude1\n },\n }\n }\n )\n};\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":120,"wires":[["8f56361b.779e98","36e34c50.b57c04"]]},{"id":"8f56361b.779e98","type":"debug","z":"6aa3baf4.0d1874","name":"Debug Payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":330,"y":280,"wires":[]},{"id":"36e34c50.b57c04","type":"mqtt out","z":"6aa3baf4.0d1874","name":"MQTT Server","topic":"EnvSensor1","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"2b5d47f073ec1fb5","x":570,"y":120,"wires":[]},{"id":"772b8d63.6c67f4","type":"mqtt in","z":"6aa3baf4.0d1874","name":"","topic":"EnvSensor1","qos":"0","datatype":"auto","broker":"2b5d47f073ec1fb5","nl":false,"rap":false,"inputs":0,"x":140,"y":380,"wires":[["8e9a06ec.bdd718"]]},{"id":"5064e11f.dedc2","type":"debug","z":"6aa3baf4.0d1874","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":380,"wires":[]},{"id":"8e9a06ec.bdd718","type":"delay","z":"6aa3baf4.0d1874","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":340,"y":380,"wires":[ ["5064e11f.dedc2"]]},{"id":"2b5d47f073ec1fb5","type":"mqttbroker","name":"","broker":"127.0.0.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
```