Simulated Sensor
This flow will simulate a sensor - sending latitude/longitude and temperature
I've omitted the MQTT node and sent the output to DEBUG - so it will need to be edited to include the MQTT-out node
[{"id":"8d37a936.a21ac","type":"tab","label":"Sensor Flow","disabled":false,"info":""},{"id":"c138ef48.bc628","type":"inject","z":"8d37a936.a21ac","name":"Start Sensor","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":80,"wires":[["abd96616.02651"]]},{"id":"d98f6e3.47d829","type":"debug","z":"8d37a936.a21ac","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":480,"wires":[]},{"id":"abd96616.02651","type":"change","z":"8d37a936.a21ac","name":"GPS","rules":[{"t":"set","p":"latitude","pt":"msg","to":"40.133369","tot":"num"},{"t":"set","p":"longitude","pt":"msg","to":"-72.792427","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":220,"wires":[["95de282d.dae7c"]]},{"id":"95de282d.dae7c","type":"change","z":"8d37a936.a21ac","name":"Temp Sensor","rules":[{"t":"set","p":"temperature","pt":"msg","to":"20","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":280,"wires":[["8f632eaf.58542"]]},{"id":"6a02c58.368f73c","type":"trigger","z":"8d37a936.a21ac","name":"","op1":"1","op2":"0","op1type":"num","op2type":"str","duration":"-30","extend":false,"overrideDelay":false,"units":"s","reset":"stop","bytopic":"all","topic":"topic","outputs":1,"x":610,"y":220,"wires":[["95345f53.873fe"]]},{"id":"95345f53.873fe","type":"function","z":"8d37a936.a21ac","name":"Adjust Temp","func":"data = global.get('students')\nmsg.payload = data[0]\n\ntemp_increment = Math.random()\nif (Math.random() > 0.5)\n{\n msg.temperature = msg.temperature + temp_increment\n}\nelse {\n msg.temperature = msg.temperature - temp_increment \n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":830,"y":220,"wires":[["d98f6e3.47d829"]]},{"id":"2dfca968.7eb016","type":"function","z":"8d37a936.a21ac","name":"Gather Readings","func":"\nlat = msg.latitude\nlong = msg.longitude\ntemp = msg.temperature\nname = msg.name\n\n\nglobal.set('students',[{\"name\":name, \n \"lat\":lat, \n \"lon\":long,\n \"age\":10,\n \"temp\": temp }]);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":410,"y":340,"wires":[["6a02c58.368f73c"]]},{"id":"5cac1f6a.9449d","type":"inject","z":"8d37a936.a21ac","name":"Stop Sensor","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"stop","payloadType":"str","x":410,"y":80,"wires":[["6a02c58.368f73c"]]},{"id":"8f632eaf.58542","type":"change","z":"8d37a936.a21ac","name":"Name","rules":[{"t":"set","p":"name","pt":"msg","to":"Matt","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":170,"y":340,"wires":[["2dfca968.7eb016"]]},{"id":"71d727d.5493ad8","type":"comment","z":"8d37a936.a21ac","name":"GPS and Name need to be setup","info":"Simulated sensor. \n\nYou must update:\n\n\"GPS\" with a correct lat/long\n (use: https://www.latlong.net/)\n \n\"Name\" with a sensor identifier\n","x":310,"y":180,"wires":[]}]