[MQTT] discovered 'Nan' signal

551 views
Skip to first unread message

Stephen Haesung Lee

unread,
Oct 18, 2016, 11:39:09 PM10/18/16
to Node-RED
Dear all

discovered 'Nan' signal in MQTT system.
How can I improve the signal quality?
I also changed qos from 0 to qos2.
They still make the signal.


LEE, Stephen


IMG_0307.JPG
IMG_0309.JPG

Colin Law

unread,
Oct 19, 2016, 3:10:12 AM10/19/16
to node...@googlegroups.com

Is that coming straight out of the mqtt node? If so then it is whatever is feeding it to mqtt that is generating Not a Number.

Colin


--
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+unsubscribe@googlegroups.com.
To post to this group, send an 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/3f7dfa86-5c4f-4027-9a71-680b5cd10cdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Haesung Lee

unread,
Oct 19, 2016, 3:23:57 AM10/19/16
to node...@googlegroups.com
Dear Colin Law

My home gas valve checker works well whereas just found the 'Nan' message. I just was wondering.
You might see the reason of node-red before. The raw data is coming from MQTT node of Gas valve sensor.











You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.

Dave C-J

unread,
Oct 19, 2016, 3:58:04 AM10/19/16
to node...@googlegroups.com
Hi.
neither of your pictures shows where you are seeing this NaN error. 
Is it coming out of one of the three function nodes in the middle flow ? If so which one ? and if one of thise what is the code inside the function ?  
Or is it direct from the MQTT node ? again which one ?

Stephen Haesung Lee

unread,
Oct 19, 2016, 5:29:00 AM10/19/16
to Node-RED
Dear Dave C-J

It's just my small mqtt v3.1 experiment. 

According to my note,  'Nan' error came from first mqtt node(Gas valve Sensor).
And then I linked the first mqtt node with GasV/V. The broker is really small server(Raspberry pi2) in the middle node.
Lastly, the broker helps last subscriber connect Twillo,Twitter, and E-mail.






2016년 10월 19일 수요일 오후 6시 58분 4초 UTC+11, Dave C-J 님의 말:

Mark Setrem

unread,
Oct 19, 2016, 5:50:19 AM10/19/16
to Node-RED
This is unlikely to be a MQTT issue, but is either a problem with the data coming in or most likely a problem with your function code.


If the NaN error is coming from your gas value sensor, wire up a file node (or debug node) to your gas value sensor input, this will allow you to check the value that isn't a number is coming from there.

Alternatively your function node after the MQTT Gas Value-in contains some code that causes it.

For anyone to help you further you will need to share your functions actual code.  

Dave C-J

unread,
Oct 19, 2016, 5:50:39 AM10/19/16
to node...@googlegroups.com
If it's really coming from an MQTT node then that most likely means that is what is being sent into the broker from the other side - as we don't process the data (or try to force it to be a number) on the input. 
So I would suspect whatever is publishing the data in the first place.

Stephen Haesung Lee

unread,
Oct 19, 2016, 6:38:15 AM10/19/16
to Node-RED
Dear Mark Setrem

As you can see, it's just connected only nodes without coding. The sensor is really simple like a on/off switch. 
I'm going to share below. Anyway, the nods should be safe for home. 
I believe the 'Nan' error came from 2 nodes such as Raspberry pi node, MQTT node and MQTT v 3.1.








LEE, Stephen

2016년 10월 19일 수요일 오후 8시 50분 19초 UTC+11, Mark Setrem 님의 말:

Stephen Haesung Lee

unread,
Oct 19, 2016, 6:45:30 AM10/19/16
to Node-RED
Dear Dave C-J

As you can see, it's just connected only nodes without coding. The sensor is really simple like a on/off switch. 
I'm going to share below. Anyway, the nods should be safe for home. 
I believe the 'Nan' error came from 2 nodes such as Raspberry pi node, MQTT node and MQTT v 3.1.

2016년 10월 19일 수요일 오후 8시 50분 39초 UTC+11, Dave C-J 님의 말:

Stephen Haesung Lee

unread,
Oct 19, 2016, 6:47:49 AM10/19/16
to Node-RED




2016년 10월 19일 수요일 오후 9시 45분 30초 UTC+11, Stephen Haesung Lee 님의 말:

Julian Knight

unread,
Oct 19, 2016, 9:54:42 AM10/19/16
to Node-RED
Is that the output from the Gas Valve Sensor node?

Did I miss it because I cannot see an actual payload value? Or is all of that output the payload? 

Please add a debug node to the output of the sensor node, set to report just the msg.payload and let us know what that gives.

Stephen Haesung Lee

unread,
Oct 19, 2016, 11:12:08 AM10/19/16
to node...@googlegroups.com
Dear Julian Knight 
 
I think the problem came from the RaspberryPi mode.
I added the debugging node. 


LEE, Stephen
--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
IMG_0317.JPG

Julian Knight

unread,
Oct 20, 2016, 1:42:32 AM10/20/16
to Node-RED
From the screenshot, 1 out of the 3 messages from your sensor has returned a non-numeric payload. Obviously this will be sent directly on to the MQTT topic. Since MQTT values are stored as text, the "Not a Number" (NaN) entry sent by the sensor becomes the literal text "NaN" in MQTT.

One way to fix this is to put a function node between the sensor and MQTT out nodes that checks for non-numeric payloads and drops the message. I have to do this with many of my sensors which are based on serial output since serial output regularly chops the end off a message. In my case, I always make sure that sensor output is in JSON format so that it is fairly easy to validate.

Stephen Haesung Lee

unread,
Oct 20, 2016, 1:33:09 PM10/20/16
to Node-RED
2016년 10월 20일 목요일 오전 12시 54분 42초 UTC+11, Julian Knight 님의 말:
IMG_0316.JPG

Nicholas O'Leary

unread,
Oct 21, 2016, 4:49:37 AM10/21/16
to Node-RED Mailing List
Stephen,

From your screenshot image IMG_0316.JPG the fact the Debug node is displaying NaN means that value is coming from the RaspberryPi GPIO nodes. This means it has absolutely nothing to do with MQTT.

The question is then: why is the GPIO node occasionally emitting NaN rather than 0 or 1.


If you run node-red with the -v option, you'll enable verbose logging. The Pi GPIO nodes will print to the node-red log the raw data they receive. That will help us understand what's going. But please don't give us another screenshot. Copy and paste the text as it is much easier to work with.


For future reference, if you have some JSON to share, copy and paste the json, not a photo of the json, otherwise we can't do anything with it.

Nick


--
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+unsubscribe@googlegroups.com.
To post to this group, send an email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Stephen Haesung Lee

unread,
Oct 21, 2016, 11:24:12 PM10/21/16
to Node-RED
Dear Julian & Nick

First of all, Thank you for supporting.
I just added josn node in the middle of the nodes.
The result is below the imgaes.






LEE, Stephen



2016년 10월 21일 금요일 오후 7시 49분 37초 UTC+11, Nick O'Leary 님의 말:
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

Stephen Haesung Lee

unread,
Oct 21, 2016, 11:42:59 PM10/21/16
to Node-RED
eclosed the GasValve.txt for json format.


2016년 10월 22일 토요일 오후 2시 24분 12초 UTC+11, Stephen Haesung Lee 님의 말:
GasValv.txt

Nicholas O'Leary

unread,
Oct 22, 2016, 2:18:51 AM10/22/16
to Node-RED

And what about doing as I suggested and running Node-RED with the -v option and sharing the Node-RED log output? Until you do that, there's not much else I can do to help.

Nick


To post to this group, send email to node...@googlegroups.com.

Stephen Haesung Lee

unread,
Oct 22, 2016, 2:39:29 AM10/22/16
to node...@googlegroups.com


pi@iotmaker:~ $ mosquitto_sub -v -t 'topic/gasValve'
topic/gasValve 1
topic/gasValve NaN
topic/gasValve NaN
topic/gasValve NaN
topic/gasValve NaN
topic/gasValve NaN
topic/gasValve 1
topic/gasValve 0
topic/gasValve 1
topic/gasValve NaN
topic/gasValve NaN
topic/gasValve 1
topic/gasValve 0
topic/gasValve NaN
topic/gasValve NaN
topic/gasValve 1
topic/gasValve 0
topic/gasValve 1


pi@iotmaker:~ $ mosquitto_sub -v -t 'topic/ping'
topic/ping 3.6
topic/ping 6.17
topic/ping 3.08
topic/ping 7.27
topic/ping 4.2


pi@iotmaker:~ $ mosquitto_sub -v -t 'topic/cpuTemp'
topic/cpuTemp 47.6
topic/cpuTemp 47.6
topic/cpuTemp 47.6
topic/cpuTemp 47.6


pi@iotmaker:~ $ mosquitto_sub -v -t 'topic/text'
topic/text Please turn off the gas valve at home. Please check the gas valve for safety.
topic/text Please turn off the gas valve at home. Please check the gas valve for safety.
topic/text Please turn off the gas valve at home. Please check the gas valve for safety.
topic/text Please turn off the gas valve at home. Please check the gas valve for safety.
topic/text Please turn off the gas valve at home. Please check the gas valve for safety.
topic/text Please turn off the gas valve at home. Please check the gas valve for safety.
topic/text Please turn off the gas valve at home. Please check the gas valve for safety.

To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@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/dcba8be6-a474-4890-9db9-b2075d1d919e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@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 Haesung Lee

unread,
Oct 22, 2016, 2:42:45 AM10/22/16
to node...@googlegroups.com
Dear Nick

Thanks so much. Is that correct above?
Other topics is very good but only gasValve still makes the 'Nan' message.

LEE, Stephen 

Nicholas O'Leary

unread,
Oct 22, 2016, 2:59:32 AM10/22/16
to node...@googlegroups.com

No. I didn't ask you to run mosquitto_sub. Please run Node-RED with the -v option.



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/dcba8be6-a474-4890-9db9-b2075d1d919e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, 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.

--
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.

Stephen Haesung Lee

unread,
Oct 22, 2016, 3:07:48 AM10/22/16
to node...@googlegroups.com
Dear Nick & Julian

I added above the logged data.
I'm trying to add a delay function node(0.05 sec) between a gasValve node and a mqtt node.

To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@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/dcba8be6-a474-4890-9db9-b2075d1d919e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

--
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+unsubscribe@googlegroups.com.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@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 Haesung Lee

unread,
Oct 22, 2016, 3:08:40 AM10/22/16
to node...@googlegroups.com
Where is the -v option?


On Saturday, 22 October 2016, Nicholas O'Leary <nick....@gmail.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@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/dcba8be6-a474-4890-9db9-b2075d1d919e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

--
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+unsubscribe@googlegroups.com.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@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/CAF%3DvhqfGoQ8aq7Fy-611c4Eop3kCZ_-ieD6PfdwzdV%2B8fSDjpw%40mail.gmail.com.

Nicholas O'Leary

unread,
Oct 22, 2016, 3:11:01 AM10/22/16
to node...@googlegroups.com

How are you running Node-RED?



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/dcba8be6-a474-4890-9db9-b2075d1d919e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, 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.

--
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.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, 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.
--
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.

Dave C-J

unread,
Oct 22, 2016, 6:20:47 AM10/22/16
to node...@googlegroups.com
Stephen,
can you do me a massive favour. I'm trying to re-create the error here, and (no surprise) it's working for me :-) 
Can you edit the file 
    /usr/lib/node_modules/node-red/nodes/core/hardware/36-rpi-gpio.js
you will need to be root to edit it - eg
   sudo nano /usr/lib/node_modules/node-red/nodes/core/hardware/36-rpi-gpio.js
and insert a line - change lines 82-84 from
if (node.running && node.buttonState !== -1) {
                        node.send({ topic:"pi/"+node.pin, payload:Number(data) });
                    
to
if (node.running && node.buttonState !== -1) {
                        console.log("DATA",Number(data),data,":::");
                        node.send({ topic:"pi/"+node.pin, payload:Number(data) });
 
then stop and restart node-red. In the console log it should now print out every value it reads...  - obviously the ones I am interested in are the ones that have Nan  in them.

After we have some - please edit the file back as it was. Thanks               

Dave C-J

unread,
Oct 22, 2016, 6:41:27 AM10/22/16
to node...@googlegroups.com
Other thought is... the gas sensor input. Do you know what sort of signal it produces ? Is it an active high or low signal or is it actually a set of switched contacts ? in which case are they normally open or closed - and can we perhaps use either the pull up or pull down setting to make the signal more stable. (Obviously this needs to be correct before applying or you could be trying to force a signal high (or low) when it doesn't want to and could damage the input.)

Stephen Haesung Lee

unread,
Oct 22, 2016, 6:42:48 AM10/22/16
to node...@googlegroups.com
Dear Dave C-J

Wow! It's very interesting!! Thank you for giving good experience!!


LEE, Stephen

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Dave C-J

unread,
Oct 22, 2016, 6:47:07 AM10/22/16
to node...@googlegroups.com
Stephen,

final question... (maybe :-)...  which version of Node-RED are you running ? and which model of Pi is this on ?
at the top of the log it should print out something like below... what does your say ?

Welcome to Node-RED

===================

22 Oct 10:46:20 - [info] Node-RED version: v0.15.1

22 Oct 10:46:20 - [info] Node.js  version: v0.10.29

22 Oct 10:46:20 - [info] Linux 4.4.21-v7+ arm LE

Stephen Haesung Lee

unread,
Oct 22, 2016, 7:56:57 AM10/22/16
to node...@googlegroups.com
Dear Dave C-J

You are really cool! 

I edited it.

I want to test other pi. I'll back with the edited files soon.

Please wait more.

*The edited code: 
====================================================================
if (node.running && node.buttonState !== -1) {
                        console.log("DATA",Number(data),data,":::");
                        node.send({ topic:"pi/"+node.pin, payload:Number(data) });
===================================================

* My test results:
===================================================

pi@iotmaker:~ $ node-red-start


Start Node-RED

 

Once Node-RED has started, point a browser at http://169.254.170.40:1880

On Pi Node-RED works better with the Firefox browser

 

Use   node-red-stop                          to stop Node-RED

Use   node-red-start                         to start Node-RED again

Use   node-red-log                           to view the recent log output

Use   sudo systemctl enable nodered.service  to autostart Node-RED at every boot

Use   sudo systemctl disable nodered.service to disable autostart on boot

 

To find more nodes and example flows - go to http://flows.nodered.org

You may also need to install and upgrade npm

      sudo apt-get install npm

      sudo npm i -g npm@2.x

 

Started Node-RED graphical event wiring tool..

DATA 1 1 :::

DATA 0 0 :::

DATA 1 1 :::

DATA 0 0 :::

DATA 1 1 :::

DATA NaN 0

1 :::

22 Oct 11:48:37 - [error] [json:6e99e5cd.1d5cac] Unexpected token N

DATA 1 1 :::

DATA 0 0 :::

DATA 1 1 :::

DATA 0 0 :::

DATA 1 1 :::

DATA 0 0 :::

DATA 1 1 :::

DATA 0 0 :::

DATA 1 1 :::

DATA 1 1 :::

DATA 0 0 :::

DATA 1 1 :::

DATA 0 0 :::

DATA 1 1 :::

DATA 0 0 :::

DATA 1 1 :::

DATA 0 0 :::

DATA 1 1 :::

DATA 0 0 :::

DATA 1 1 :::

DATA 0 0 :::

===================================================

Ohter result:

===================================================

pi@iotmaker:~ $ mosquitto_sub -v -t 'topic/gasValve'

topic/gasValve 0

topic/gasValve 1

topic/gasValve 1

topic/gasValve 0

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 0

topic/gasValve 1

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve NaN

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 1

topic/gasValve 0

topic/gasValve 0

===================================================


Please wait just second!

I want to test other pi.



Lee, Stephen










--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
Edited__36-rpi-gpio.js

Stephen Haesung Lee

unread,
Oct 22, 2016, 10:53:48 AM10/22/16
to node...@googlegroups.com
Dear Dave C-J

You made the cool testing program!!
Implemented 2nd test on my raspberry pi2
Enclosed the edited file


* 1st-Pi Test
===================
Versions
===================
22 Oct 12:29:00 - [info] Node-RED version: v0.14.6
22 Oct 12:29:00 - [info] Node.js  version: v0.10.29
22 Oct 12:29:00 - [info] Linux 4.4.21-v7+ arm LE
22 Oct 12:29:00 - [info] Loading palette nodes
===================

My Test Result:
===================
pi@iotmaker:~ $ node-red-stop

Stop Node-RED
 
Use   node-red-start   to start Node-RED again
 
pi@iotmaker:~ $ node-red-start

Start Node-RED
 
Once Node-RED has started, point a browser at http://169.254.170.40:1880
On Pi Node-RED works better with the Firefox browser
 
Use   node-red-stop                          to stop Node-RED
Use   node-red-start                         to start Node-RED again
Use   node-red-log                           to view the recent log output
Use   sudo systemctl enable nodered.service  to autostart Node-RED at every boot
Use   sudo systemctl disable nodered.service to disable autostart on boot
 
To find more nodes and example flows - go to http://flows.nodered.org
You may also need to install and upgrade npm
      sudo apt-get install npm
      sudo npm i -g npm@2.x
 
Started Node-RED graphical event wiring tool..
Welcome to Node-RED
===================
22 Oct 12:47:54 - [info] Node-RED version: v0.14.6
22 Oct 12:47:54 - [info] Node.js  version: v0.10.29
22 Oct 12:47:54 - [info] Linux 4.4.21-v7+ arm LE
22 Oct 12:47:54 - [info] Loading palette nodes
pi : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/python -u /usr/lib/node_modules/node-red/nodes/core/hardware/nrgpio.py info
pam_unix(sudo:session): session opened for user root by (uid=0)
pam_unix(sudo:session): session closed for user root
22 Oct 12:48:04 - [info] Settings file  : /home/pi/.node-red/settings.js
22 Oct 12:48:04 - [info] User directory : /home/pi/.node-red
22 Oct 12:48:04 - [info] Flows file     : /home/pi/.node-red/flows_iotmaker.json
22 Oct 12:48:04 - [info] Server now running at http://127.0.0.1:1880/
22 Oct 12:48:04 - [info] Starting flows
pi : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/python -u /usr/lib/node_modules/node-red/nodes/core/hardware/nrgpio.py in 12 tri 25
pam_unix(sudo:session): session opened for user root by (uid=0)
22 Oct 12:48:05 - [info] Started flows
22 Oct 12:48:05 - [info] [mqtt-broker:2be4dc46.47a5b4] Connected to broker: mqtt://localhost:1883
===================


LEE, Stephen
Edited__36-rpi-gpio.js

Stephen Haesung Lee

unread,
Oct 22, 2016, 11:01:21 AM10/22/16
to node...@googlegroups.com
1stPiTest.txt

Stephen Haesung Lee

unread,
Oct 22, 2016, 12:06:51 PM10/22/16
to node...@googlegroups.com
Dear Dave C-j

I'm going to add pull-up resistor for clear signal. 
Next time, I'm gonna add the pull-up resistor in front of the signal pin. 


LEE, Stpehen




2016-10-22 21:41 GMT+11:00 Dave C-J <dce...@gmail.com>:
Other thought is... the gas sensor input. Do you know what sort of signal it produces ? Is it an active high or low signal or is it actually a set of switched contacts ? in which case are they normally open or closed - and can we perhaps use either the pull up or pull down setting to make the signal more stable. (Obviously this needs to be correct before applying or you could be trying to force a signal high (or low) when it doesn't want to and could damage the input.)

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Dave C-J

unread,
Oct 22, 2016, 1:09:13 PM10/22/16
to node...@googlegroups.com
Hi... aha
this is the problem

DATA NaN 0

1 :::

it is actually sending two results in one go - and I am not handling properly...

would you mind editing that file again and this time replace the whole of the  node.child.stdout function with this.. (line 79)

            node.child.stdout.on('data', function (data) {
                var d = data.toString().trim().split("/n");
                for (var i = 0; i < d.length; i++) {
                    if (node.running && node.buttonState !== -1 && !isNaN(Number(d[i]))) {
                        node.send({ topic:"pi/"+node.pin, payload:Number(d[i]) });
                    }
                    node.buttonState = d[i];
                    node.status({fill:"green",shape:"dot",text:d[i]});
                    if (RED.settings.verbose) { node.log("out: "+d[i]+" :"); }
                }
            });

and report back if you see any more NaN

Dave C-J

unread,
Oct 22, 2016, 1:23:11 PM10/22/16
to node...@googlegroups.com
aargh... apologies..  that should be  \n in there not /n

var d = data.toString().trim().split("\n");

Stephen Haesung Lee

unread,
Oct 22, 2016, 11:03:52 PM10/22/16
to node...@googlegroups.com
Dear Dave C-J

Thanks for giving good experience. It's good challenge!! 
I clearly fixed the problem by using a pull-up resistor(1 k ohm) with original code. I'm gonna enclose my circuit diagram. Also, I omitted the calculation of pull-up resistor here.
I'm going to test your code without a pull-up resistor after noon.




On Sunday, 23 October 2016, Dave C-J <dce...@gmail.com> wrote:
aargh... apologies..  that should be  \n in there not /n

var d = data.toString().trim().split("\n");

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
IMG_0343.JPG

Stephen Haesung Lee

unread,
Oct 23, 2016, 2:51:15 AM10/23/16
to node...@googlegroups.com
Dear Dave C-J, Nick, Julian, and all.


We are very well done!!! It's really Good Job!!

Dave C-J nearly figured out as SW method with 2nd edited code whereas I clearly solved out as HW method with original code.

I clearly understand your code what you think.


In a nutshell,  there are 2 kinds solutions such as HW method,  SW method to fix 'NaN' signal. So, both methods are clearly possible to improve. Also, I'm going to enclose both methods with test results.


LEE, Stephen

Colin Law

unread,
Oct 23, 2016, 3:01:05 AM10/23/16
to node...@googlegroups.com
I don't know the device you are connecting to, but assuming that it is a contact that is either open circuit or grounded then you absolutely need a pullup to guarantee that it will work. I don't think it needs to be as low as 1k, I use 4.7k.  Without the pullup the input is in an undefined state when open and may not read reliably.

Colin

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+unsubscribe@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 Haesung Lee

unread,
Oct 23, 2016, 3:08:52 AM10/23/16
to node...@googlegroups.com
Dear Colin Law

You are right! I just make it for clear signal. I'm going to test the 4.7 k ohm value you selected.

Thank you for giving your wisdom.


LEE, Stephen

Stephen Haesung Lee

unread,
Oct 23, 2016, 7:37:02 AM10/23/16
to node...@googlegroups.com
Dear Colin Law

I just used your value without using a pull-up& down resistor but it never works. Pleas help me draw yours with calculation on paper like me.
I'm going to enclose my calculation of a pull-up resistor.


LEE, Stephen 

IMG_0345.JPG
IMG_0344.JPG

Stephen Haesung Lee

unread,
Oct 23, 2016, 7:46:11 AM10/23/16
to node...@googlegroups.com
The safe limitation is max 50 mA according to Data Sheet. So, my appropriate is 100 ohm but I'll use really long wire in the future.

Colin Law

unread,
Oct 23, 2016, 8:20:31 AM10/23/16
to node...@googlegroups.com
On 23 October 2016 at 12:36, Stephen Haesung Lee <ach...@gmail.com> wrote:
Dear Colin Law

I just used your value without using a pull-up& down resistor but it never works. Pleas help me draw yours with calculation on paper like me.

I don't know what you mean by 'without a pull-up and down resistor'. My suggestion was a 4.7k pullup.

Colin
 

Colin Law

unread,
Oct 23, 2016, 8:26:44 AM10/23/16
to node...@googlegroups.com
The 1.8k pullup on the datasheet refers to those particular pins, which have a 1.8k pullup built into the chip.  I thought you were using one of the general purpose pins, which do not have a builtin pullup.

Colin

Colin Law

unread,
Oct 23, 2016, 8:28:41 AM10/23/16
to node...@googlegroups.com
The 50ma is referring to the situation where the pin is an output. That is the max you can draw from the pin. When it is configured as an input you just need enough to make sure it is at a logic high level when it is not being pulled low by the device you have connected.

Colin

Stephen Haesung Lee

unread,
Oct 23, 2016, 9:32:44 AM10/23/16
to node...@googlegroups.com
Dear Colin Law

That's right. Than you. 
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/CAL%3D0gLvmJznMF7vFV4JRiBZJNNyAWtWAN3fpfmK2pc3Ddg6P0A%40mail.gmail.com.

Stephen Haesung Lee

unread,
Oct 23, 2016, 9:33:37 AM10/23/16
to node...@googlegroups.com


Thank you

Stephen Haesung Lee

unread,
Oct 25, 2016, 1:54:23 AM10/25/16
to Node-RED
Dear all.


I shared my smart gas valve design because I received many helps here.
When you go the linked web, you can download all.  
 If you find some errors, I will fix & add all to improve. Really Thank you! 





LEE, Stephen

2016년 10월 24일 월요일 오전 12시 33분 37초 UTC+11, Stephen Haesung Lee 님의 말:

Julian Knight

unread,
Oct 27, 2016, 7:25:28 AM10/27/16
to Node-RED
Cool! Clever use of a mag switch. I have one on the freezer door having had a couple of major disasters with it being left open. But I use LightWaveRF devices so I don't have to build the MCU/comms part.

Stephen Haesung Lee

unread,
Oct 27, 2016, 7:37:18 AM10/27/16
to node...@googlegroups.com
Dear Colin Law

Thanks. The magnetic sw is really useful!

 I'm making a IoT JPG Camera for Home Security with OpenCV.
 This is really usefull! 


LEE, Stephen. 

Stephen Haesung Lee

unread,
Oct 27, 2016, 7:39:25 AM10/27/16
to node...@googlegroups.com
Dear Julian Knight

I mistook it to write.

Thanks. The magnetic sw is really useful!

 I'm making a IoT JPG Camera for Home Security with OpenCV.
 This is really usefull! 

Stephen Haesung Lee

unread,
Oct 27, 2016, 7:52:38 AM10/27/16
to node...@googlegroups.com
Dear Julian Knight

Thanks. 
Arduino could easily connect with your LightWaveRF devices. 


LEE, Stephen

Stephen Haesung Lee

unread,
Nov 10, 2016, 6:37:17 AM11/10/16
to Node-RED
Dear Dave C-J

I' am looking the PID node in GitHub.
I want to know how to compute the P+I+D  values because It's really simple inside.

Thank you for giving your precious time.




2016년 10월 23일 일요일 오전 4시 23분 11초 UTC+11, Dave C-J 님의 말:

Stephen Haesung Lee

unread,
Nov 10, 2016, 6:59:46 AM11/10/16
to Node-RED
Dear Dave C-J

I just found the origin source from (https://github.com/Philmod/node-pid-controller

Stephen LEE 
  

2016년 11월 10일 목요일 오후 10시 37분 17초 UTC+11, Stephen Haesung Lee 님의 말:

Ben Hardill

unread,
Nov 10, 2016, 11:57:23 AM11/10/16
to Node-RED
There is another PID controller here:

https://github.com/tyrrellsystems/node-red-contrib-pid-controller

That allows a lot more control, it's still under development but is very close to being finished

Stephen Haesung Lee

unread,
Nov 14, 2016, 4:52:31 AM11/14/16
to Node-RED
Dear Ben Hardill 

Thank you. You're awesome!
I searched your node at the npm. Thre is no yours. 
It's really painful to tune each PID values.
Anyway, please help me check my PID control's experiment result.







Regards,
LEE, Stephen

2016년 11월 11일 금요일 오전 3시 57분 23초 UTC+11, Ben Hardill 님의 말:

Stephen Haesung Lee

unread,
Nov 14, 2016, 4:54:41 AM11/14/16
to Node-RED
sorry. The setpoint value is 40.

2016년 11월 14일 월요일 오후 8시 52분 31초 UTC+11, Stephen Haesung Lee 님의 말:

Stephen Haesung Lee

unread,
Nov 14, 2016, 4:59:31 AM11/14/16
to Node-RED
My motivation for PID Control For CPU Temperature of Raspberry Pi came for many reasons such as very hot CPU, very noisy fan's sound and fast battery consumption because the hot CPU makes the system really unstable while using Raspberry Pi for a long time. So, I have optimized the failing by using PID node on Node-RED. It's visually helpful for a trainee to understand the PID control system for an educational purpose.
2016년 11월 14일 월요일 오후 8시 52분 31초 UTC+11, Stephen Haesung Lee 님의 말:

Stephen Haesung Lee

unread,
Nov 14, 2016, 5:29:32 AM11/14/16
to Node-RED


Dear Dave C-J, Nick, and Ben Hardill


I'm writing to get your feedback in my result of PID control experiment. There are some overshoots and undershoots. 

You can see more details here.  http://www.instructables.com/id/PID-Control-for-CPU-Temperature-of-Raspberry-Pi/

Thank you for giving your precious time.


Lee, Stephen







You can have a look in my instructable.

http://www.instructables.com/id/PID-Control-for-CPU-Temperature-of-Raspberry-Pi/




2016년 11월 14일 월요일 오후 8시 52분 31초 UTC+11, Stephen Haesung Lee 님의 말:

Stephen Haesung Lee

unread,
Nov 21, 2016, 12:34:20 AM11/21/16
to Node-RED
Dear Dave C-J, Nick and all

I'm writing to approach the Node-RED  for Australia children education instead of using Scratch Programming.
This is really big for me to approach. Have you taught it for children?


Regards, 
LEE, Stephen



2016년 11월 14일 월요일 오전 2시 29분 32초 UTC-8, Stephen Haesung Lee 님의 말:

Julian Knight

unread,
Nov 21, 2016, 3:57:56 AM11/21/16
to Node-RED
Cool. Not done that myself but I have taught all sorts of different subjects to both youth and adults in the past - I'm sure I won't be the only one in this group - so if you want any input, please ask.

Node-RED should be great for teaching kids since it installs pretty much anywhere from a SBC to a server & is easy to run. 

Perhaps one thing to watch out for though is that with flow-based programming you are not always exposed to the "hard logic" e.g. if/then/else, do/while and so on because this is somewhat hidden. You can, of course, do that logic in NR but it isn't always as clear cut & you will need to find a way to explain that and also to link if/then/else to the switch node and so on.

Stephen Haesung Lee

unread,
Nov 21, 2016, 4:41:59 AM11/21/16
to node...@googlegroups.com
Dear Julian Knight

Thank you for giving your precious time. You are really cool!! 
 Even though I'm not an Australian, I'd like teaching all children about Robotics. My Korean boss has established many robotics' classes for Australian children in Sydney. So, I will carefully suggest my boss the Node-RED instead of using Scratch programming. That's because It's really hard to connect with children education to industry whereas the Node-RED is much easier to approach in the Industry. There are no children books of Node-RED nowadays. Also, I'm making a textbook for children in the robotics class including basic mathematics. Are there textbooks of Node-RED for children in England?

Yours faithfully,

Lee, Stephen


 
 

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/YG_0nSRhWao/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Julian Knight

unread,
Nov 21, 2016, 11:53:52 AM11/21/16
to Node-RED
Hi Stephen, always great to hear of businesses investing in future generations. There is of course a massive skills gap so this falls neatly into "enlightened self-interest" ;-)

I agree that getting kids to make the leap from Scratch to a "real" programming language is actually quite hard. It takes some real teaching skill I think in order to keep them interested. My favorite idea is to set some tasks that are REALLY hard to do any way other than with a computer. Even something as simple as multiplying some really big numbers. Sadly, I don't think many curricula manage to get a good balance of theory and fun when it is time to make the leap.

Node-RED can really help there by maintaining the visual aspect and starting to introduce real-world problems. Especially when linked to hardware like the Raspberry Pi. Of course, using Node-RED also gives opportunities to link out to external cloud systems which can be interesting. Like weather, movement (via GPS and OwnTracks), even introducing medical/biological sensing using simple sensors for temperature and skin resistance. If you can manage to raise some funds, the possibilities with cheap electronics are endless. Great introductions to smart buildings, smart cities, medical sensing and more. Not to mention robotics of course.

I'm not aware of any textbooks for Node-RED anywhere though doubtless others may correct me. My own opinion is that the subject is too fast moving to make for a good textbook. I'd probably encourage the use of websites and perhaps get the kids to make their own textbooks by collaborating with each other - even easier if the school gives them access to Office 365 (OneNote) which many schools do given the heavy discounting that Microsoft do for education users. You might even see if you can get some kids to put together a website with information on Node-RED, using Node-RED of course!

Almost makes me wish I were a teacher! Though far too many of our users are worse than badly behaved children! :-{
To unsubscribe from this group and all its topics, 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 Haesung Lee

unread,
Nov 27, 2016, 12:08:32 AM11/27/16
to Node-RED
Dear Julian Knight

Thank you for replying.
We hold IYRC for kids in Australia.



Stephen Lee,

2016년 11월 22일 화요일 오전 3시 53분 52초 UTC+11, Julian Knight 님의 말:
Reply all
Reply to author
Forward
0 new messages