Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

     sensorLib:require('node-dht-sensor'),



Function in Node-RED:

var sensorLib = context.global.sensorLib;
var d = new Date();

sensorLib.initialize(11, 4);
var readout = sensorLib.read();
msg.topic="temp";
msg.payload = {time:d.toLocaleTimeString(),temp:readout.temperature.toFixed(2), hum:readout.humidity.toFixed(2)};
console.log(msg);
return msg;


JavaScript: display date and time:

https://www.w3schools.com/jsref/jsref_obj_date.asp