How to implement different sensors? What's the best way to learn node - red?

445 views
Skip to first unread message

adre...@gmail.com

unread,
Jan 28, 2018, 6:37:52 PM1/28/18
to Node-RED
Hi guys!

I recently discovered node-red as a powerful tool. I managed to find some codes/tutorials online and set up temperature readings and turning led on/off from raspberry pi.

I am willing to add more sensors, what is the best way to learn how to do it? The kit I have for the PI comes with python code for each sensor, but I am sure it is not enough. What would you suggest where to start? How to learn? Perhaps you have a good way or source of tutorials to suggest?

Regards

Zenofmud

unread,
Jan 28, 2018, 8:19:20 PM1/28/18
to node...@googlegroups.com
What sensors do you have? There are lots of node-red nodes out there for lots of them.

If you have a ds18b20 or dht11 or dht22, try making a temperature monitor. if you go to https://flows.nodered.org you can search for nodes for the sensor. Use a debug code to see the results, then send it to a dashbaord gauge or graph.

You probably have an LED or two. If you have a red, blue and green ones, you could cobble up a circuit then use the gpis node and a switch statement to light up the blue led if the temp is less than 50, green one if it is 51-80 and the red one if it is over 8.

Paul
--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/60547c5e-763e-48a7-af7b-2b45d0d30523%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Dempster

unread,
Jan 29, 2018, 3:38:36 AM1/29/18
to Node-RED
Here's a link to some resources (intsruction sheets) that you might find useful.
The students (at the school where I tutor an IoT Computer Club) use ESP8266 modules talking to Node-Red via MQTT.
They have used DHT11 sensors, soil moisture sensors, wind speed sensor as well as Alexa controlling mains-driven devices.

http://youtrain.me.uk/iotclub/resources.html

Cheers from David

Julian Knight

unread,
Jan 29, 2018, 5:11:59 AM1/29/18
to Node-RED
As David alludes to, many of us prefer to keep our sensors on dedicated microprocessor platforms. Arduino is a good starting point and can be connected to the Pi via serial. But ESP8266 devices are just as cheap really and have the advantage of being Wi-Fi enabled. Both can be programmed in a simplified dialect of C++ and are ideal for the realtime platforms suited to sensors. The ESP devices support direct connection to MQTT which is the easiest way to get them talking with Node-RED.

Using dedicated microprocessors means that if you make a mistake and fry a chip, you are not destroying your Pi. You also get more freedom as to where to position your sensors. As you add sensors, you will begin to realise that positioning is very important and that a nearby hot Pi with LEDs on it can significantly alter the sensor readings.

There are thousands of tutorials for both platforms covering every type of sensor you can imagine - and quite a few you probably can't imagine!

Stephen Mann

unread,
Jan 29, 2018, 11:19:20 AM1/29/18
to Node-RED
Like Juian, I am a big fan of the esp8266 modules.  I have many throughout my home on an MQTT 'net' connecting through a Mosquitto Broker running on a Raspberry Pi-3.  Most are light controls and a couple are temperature monitors.  My esp8266-01 in the attic also has a light sensor that, through Node red, tells me with a voice: "The attic light is on" after fifteen minutes.  (I have a bad habit of not turning off the Attic light).  Best yet, the esp boards are so cheap that I don't care if I brick one.  I've recently been using the NodeMCU boards which have an esp8266-12 on them for my experiments, and they can be had for about $5 each.

Six months ago, I did not know of the existence of Node Red, MQTT and the esp8266.  And today, I am still coming up with new projects to start.  The experienced users here have been absolutely terrific to offer assistance when I hit a speed-bump in my learning process.

Steve Mann

Julian Knight

unread,
Jan 29, 2018, 3:42:28 PM1/29/18
to Node-RED
I use the Wemos ones that I buy direct from China. I like them because of the form factor and the nice stable power supply.

Stephen, do you create your own switches with them or do you use the Sonoff devices?

adre...@gmail.com

unread,
Jan 29, 2018, 3:46:13 PM1/29/18
to Node-RED
Thanks guys for replies and links!

I do know there are many tutorials, but not all of them work. Or perhaps it's just my knowledge. I do know how to run them using ssh on pi using a python script. But how do I transfer that python code to the node red so it works if I click on the button and it would show on the dashboard? 

For example DHT11 and DHT22 I found a tutorial online -how to import python code in pi and then use it with node  - easy and simple (learned a lot this way). Are there any sources you could suggest?

I have a few questions:

1. Why do sometimes sensors output aren't working on the dashboard? It's like non-responsive and if I click refresh it loads forever then I have to restart many times the PI to start working again.

2. Tried to find this online - how to delete groups in node-red? I did import different scripts using a clipboard and now I have more than 30 different groups that I don't need. In the section where you create groups I deleted them but the list still stays in place if I want to choose a group for a specific node.


Zenofmud

unread,
Jan 29, 2018, 4:41:57 PM1/29/18
to node...@googlegroups.com

I do know there are many tutorials, but not all of them work. Or perhaps it's just my knowledge. I do know how to run them using ssh on pi using a python script. But how do I transfer that python code to the node red so it works if I click on the button and it would show on the dashboard? 
Why would you want to use python code when there are already nodes to read the sensors?

For example DHT11 and DHT22 I found a tutorial online -how to import python code in pi and then use it with node  - easy and simple (learned a lot this way). Are there any sources you could suggest
I have a few questions:

go to http://flows.nodered.org and if you search for ‘dht’ you will find https://flows.nodered.org/node/node-red-contrib-dht-sensor - install it and try it - no python needed.

1. Why do sometimes sensors output aren't working on the dashboard? It's like non-responsive and if I click refresh it loads forever then I have to restart many times the PI to start working again.
What do you mean? can you share your flow so we can take a look? (select your flow and go to the hamburger menu -right top - and then export. Then you can copy the flow and paste it into a reply here.)

2. Tried to find this online - how to delete groups in node-red? I did import different scripts using a clipboard and now I have more than 30 different groups that I don't need. In the section where you create groups I deleted them but the list still stays in place if I want to choose a group for a specific node.

By groups do you mean tabs on the backend screen? if so double click the tab and one of the options is delete

—Paul



--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
Message has been deleted
Message has been deleted

adre...@gmail.com

unread,
Jan 30, 2018, 9:13:18 AM1/30/18
to Node-RED


On Tuesday, 30 January 2018 14:11:39 UTC, adre...@gmail.com wrote:


On Tuesday, 30 January 2018 14:06:56 UTC, adre...@gmail.com wrote:
Thanks Paul for your reply.

Sorry if I brought an extra misunderstanding, it's because English isn't my first language. 

For the DHT it makes sense. But now I am trying to add more sensors such as:
  • MQ-2 gas smoke sensor
  • MQ-5 Combustible gas detector sensor
  • MQ-7
  • Water level
  • DS18B20
  • BPM180 digital
I could find let's say BPM180 node but I got an error if I install the node using  "hamburger menu - manage palette" I got an error saying that it cannot be installed. p.s. I could install node once I deleted all nodes and updated PI3 B and Node Red.

Strangely after I deleted all nodes and updated system the website (http://192.168.0.10:1880/ui/) could show me nodes afterwards and it become smooth/responsive, not like yesterday when it was unusable.

Just wondering as I am doing just now testing, what should I do in case if I have many nodes and many tabs it suddenly decided not to work? 


p.s.s. tried to install another node but I got this error again, I also attached error log. 




Enter code here...msg : string[48264]
string[48264]
Error: Command failed: npm install --save --save-prefix="~" --production node-red-co...@0.1.6
npm WARN deprecated coffee...@1.3.3: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
../src/i2c.cc: In function ‘void setAddress(int8_t)’:
../src/i2c.cc:21:28: error: ‘New’ is not a member of ‘v8::String’
       Exception::TypeError(String::New("Failed to set address"))
                            ^~~~~~
../src/i2c.cc:22:5: error: ‘ThrowException’ was not declared in this scope
     );
     ^
../src/i2c.cc: At global scope:
../src/i2c.cc:26:32: error: ‘Arguments’ does not name a type
 Handle<Value> SetAddress(const Arguments& args) {
                                ^~~~~~~~~
../src/i2c.cc: In function ‘v8::Handle<v8::Value> SetAddress(const int&)’:
../src/i2c.cc:27:15: error: ‘v8::HandleScope::HandleScope()’ is protected within this context
   HandleScope scope;
               ^~~~~
In file included from /home/pi/.node-gyp/6.12.3/include/node/node.h:42:0,
             ...
30/01/2018, 14:10:28msg : string[42]
"------------------------------------------"

Thank you for any help, really appreciate it!

Regards

Zenofmud

unread,
Jan 30, 2018, 10:30:28 AM1/30/18
to node...@googlegroups.com
If you follow the thread (i.e. go to flows.nodered.org then to GitHub) you will find that an error about this was reported back in May 2017 but the author has not replied and it hasn’t been updated since 2016 so it is possible the author has abandoned it :>(

-- 
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
--- 
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Stephen Mann

unread,
Jan 30, 2018, 5:40:23 PM1/30/18
to Node-RED
All of the above?

I do have one Wemos switch, but they are a bit on the expensive side.  My esp8266 nodes all run Fauxmo to look like Wemos switches for Alexa to discover.
I have one esp8266-01 that I put inside a vaporizer that turns it on when the relative humidity goes below 60%.  It drives a solid-state relay I happened to have laying around.  the RH data comes from WeatherUnderground on node-Red because I have found the DHT series of sensors to be wildly inaccurate.
I have another in the attic with a DHT11 temperature sensor and a photoresistor.  The temperature us just to satisfy my curiosity about how hot does it get up there.  The main purpose of the node is to monitor the light in the attic.  If it's on for more than 15 minutes, an MQTT message gets sent and my Node-Red tells me with a voice notification that I forgot to turn off the attic light.  Again.
I have a Sonoff Touch wall switch in the Dining Room, a couple of wall switches with a Sonoff switch box inside.  I discovered that if you hacksaw the plastic Sonoff switch about a quarter-inch on each end, it will fit inside a standard U.S. four-inch box.  You don't need the cover over the screw terminals when the Sonoff is inside an electical box.  I brought out the extra GPIO from the Sonoff Switch wired to a standard wall switch giving me local control of the light.
I have more plans.  Soon I will hack an outdoor floodlight fixture with a nodeMCU at its core.  I will add a PIR motion detector and light sensor to the MQTT message back to Node Red.  Basically, I wanted a way to turn the driveway light on when I wanted it.

Of course, I controlled the Christmas tree with a Sonoff switch box, and BigTimer on node-Red turned it on at dusk.  But, my wife enjoyed telling Alexa to turn the Christmas Tree Light on.
I also have a pair of Ikea Tradfri lights in the mix.  My wife got a chuckle of the node names.  The lights are on our bedroom nightstands, and I named them "Steve" and "Kim".  So, "Alexa, turn Steve on" does sound kind of kinky.

By the way, I discovered that Sonoff also has another version of the Switch called the Sonoff SV.  I haven't used them yet, but I did flash one just to make sure I could.  It's basically a bare (no plastic box) Sonoff Switch with a couple more GPIO pins, and it's smaller than the Sonoff switch.

Oh, I am also working on an IR TV remote that will be on Node Red and Alexa so that I can control the TV (monitor) and the Cable TV receiver by saying "Alexa, turn on NBC".

My Alexa has "discovered" 39 devices and my IP scan has 56 IP addresses.  And I am just getting started.

Steve Mann

Julian Knight

unread,
Jan 31, 2018, 4:56:51 AM1/31/18
to Node-RED
Hi Steve, certainly sounds like you are busy!

The Wemos D1 Mini is around the same price as other NodeMCU compatible devices.

I wish I could hack my dehumidifier like you've done for your humidifier. I can turn it on OK but you can't safely turn them off remotely as they need time to warm up the condensing plate before completely turning off. Or so the manufacturer says anyway.

Yes, the DHT sensors are rubbish. I changed mine over a while ago. I use the BME/BMP-280 devices which are vastly better. They are also a reasonable price. I think the HDC1080 based devices may be even more accurate but more expensive last time I looked. Honestly though, the BME/P-280's are more than good enough. Even with the DHT-22's I found that none of the sensors were even within 10% of each other even before you factor in their poor response rate, poor recovery from humidity extremes and drift over time. 

For me, external weather information is highly inaccurate. The result of living in a city with multiple hills that is on the edge of the moors. The weather just a street or two away from ours can be wildly different. One day, I may get round to setting up my own weather station.

I have an opposite use to you for a light sensor. I have one on the ESP in the rear hallway which doesn't get much natural light. While the lamp there is on a timer (based on sunrise/set), on overcast days, it needs a boost, the light sensor takes care of that using a BH1750 sensor. It is also set to come on automatically if the PIR in the front hallway triggers at night time.

I don't have an Alexa - being a security person, I'm still waiting for some of the worst of the security issues to be ironed out! Nor do I have any smart lights, just remote switches using LightwaveRF and HomeEasy EU mainly with a couple of Sonoff's & an older Edimax Wi-Fi switch (that isn't very reliable but does measure load). Of course, the Christmas tree lights were on a timer. As are the permanent tree lights in the copper beech tree in our back yard. And various other ones of course.

The wall light switches are no good at all for the UK market unfortunately as our switches are not compatible. I would like to automate our overhead lights but this isn't really that feasible right now without significant expense.

I like the look of the Tradfri stuff and, with a newly opened Ikea in the city, I'll probably get some soon. I always found ZigBee to be too expensive in the past but Ikea have certainly lowered the costs significantly. This may help resolve the issue with the overhead lighting (the wall switch incompatibility) as we might not need wall switches! Or at least not traditional ones.

Anyway, always good to hear about what others are doing.

adre...@gmail.com

unread,
Feb 1, 2018, 5:42:44 AM2/1/18
to Node-RED
That makes sense why it's that. I realised that there are many nodes that are not working if I install this way. Is there any way I can clean node red from the unsuccessful installs and other unnecessary stuff? (similar if I would clean cache or registry for the windows then it becomes smoother).

What do you usually do if there are no nodes available? Do you use javascript or python script instead?

Regards
Reply all
Reply to author
Forward
0 new messages