monteslu / node-red-contrib-gpio

A set of node-red nodes for connecting to johnny-five IO Plugins
MIT License
41 stars 31 forks source link

Temperature sensor #21

Open protolyser opened 7 years ago

protolyser commented 7 years ago

Is there more documentation about how to use the nodes? I want to use a tmp36 sensor with johnny five within node-red on raspberry pi with an attached arduino. Which node should I use? GPIO node gives me input but I don't know how to use the johnny five stuff then. (https://github.com/rwaldron/johnny-five/blob/master/docs/temperature-tmp36.md)

With the johnny five node I can't get it to work because I don't really understand how. The led blink example works.

Can someone give me a hint?

monteslu commented 7 years ago

You can almost take the code directly from that example. You just need to pull out the code that happens inside of the ready event and put that in the johnny5 node:

  var temperature = new five.Thermometer({
    controller: "TMP36",
    pin: "A0"
  });

  temperature.on("change", function() {
    console.log(this.celsius + "°C", this.fahrenheit + "°F");
  });

If you want to have the data passed along in your flow, you can do something like this instead of just console logging:

  var temperature = new five.Thermometer({
    controller: "TMP36",
    pin: "A0"
  });

  temperature.on("change", function() {
    node.send({
       topic: 'temperature',
       celsius: this.celsius,
       fahrenheit: this.fahrenheit
    });
  });
protolyser commented 7 years ago

always that easy if you know how.. Thanks a lot. Now I have the problem that it puts out strange values. 55°C in reality here are 18°C. I set it up exactly like in the example. Also it seems that the temperature sensor is influenced by a light sensor attached to A1. Do you know how I can fix that? Or do know a adress where I can ask questions about that?

monteslu commented 7 years ago

This could be a bug, any chance you can try that example outside of node-red and with johnny-five directly and compare the values?