Problem Using a Button with DS18B20 Node

Hi. I am using the node below:

The problem is, I need to control a relay with a button on the screen, but for now, I am using an LED to see if it works or not. When I click on it, it takes 2-3 seconds for LED to light up, and another 2-3 seconds for the button icon to change on my dashboard.

I tried removing nodes one by one, the node with the link above is the problem. Without that, the response time is perfect. I don't know how to fix this issue.

Show us your flow. Make sure to read this thread first. How to share code or flow json

[{"id":"fe382da6.7454b","type":"tab","label":"Test","disabled":false,"info":""},{"id":"9d68992a.599ce8","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":3,"disabled":false,"hidden":false},{"id":"fbf99233.a08e6","type":"ui_group","z":"","name":"Default","tab":"9d68992a.599ce8","order":1,"disp":false,"width":12,"collapse":false},{"id":"8eaa7a72.f06ba8","type":"ui_base","theme":{"name":"theme-dark","lightTheme":{"default":"#0094CE","baseColor":"#000000","baseFont":"Century Gothic,CenturyGothic,AppleGothic,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#000000","baseFont":"Century Gothic,CenturyGothic,AppleGothic,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#097479","value":"#000000","edited":true},"page-titlebar-backgroundColor":{"value":"#000000","edited":false},"page-backgroundColor":{"value":"#111111","edited":false},"page-sidebar-backgroundColor":{"value":"#000000","edited":false},"group-textColor":{"value":"#262626","edited":false},"group-borderColor":{"value":"#555555","edited":false},"group-backgroundColor":{"value":"#333333","edited":false},"widget-textColor":{"value":"#eeeeee","edited":false},"widget-backgroundColor":{"value":"#000000","edited":false},"widget-borderColor":{"value":"#333333","edited":false},"base-font":{"value":"Century Gothic,CenturyGothic,AppleGothic,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"true","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"de757978.c781a8","type":"ui_group","z":"","name":"Default","tab":"","order":1,"disp":true,"width":"6","collapse":false},{"id":"45b5d58a.06aa5c","type":"ui_group","z":"","name":"logo","tab":"9d68992a.599ce8","order":2,"disp":false,"width":"6","collapse":false},{"id":"af75be72.ec7d1","type":"ui_tab","z":"","name":"Main","icon":"dashboard","order":1,"disabled":false,"hidden":false},{"id":"428a3dc8.96d354","type":"ui_tab","z":"","name":"asd","icon":"dashboard","order":2,"disabled":false,"hidden":false},{"id":"eb91cd69.17c39","type":"ui_group","z":"","name":"Default","tab":"428a3dc8.96d354","order":1,"disp":false,"width":"6","collapse":false},{"id":"cf5fa4bd.8b8bc8","type":"ui_media","z":"fe382da6.7454b","group":"eb91cd69.17c39","name":"logo","width":"0","height":"0","order":2,"category":"","file":"logo.jpg","layout":"center","showcontrols":false,"loop":false,"onstart":false,"scope":"local","tooltip":"","x":310,"y":80,"wires":[[]]},{"id":"af647a00.668358","type":"inject","z":"fe382da6.7454b","name":"","topic":"","payload":"logo/logo.jpg","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":150,"y":80,"wires":[["cf5fa4bd.8b8bc8"]]},{"id":"c0d213ab.39009","type":"rpi-gpio out","z":"fe382da6.7454b","name":"","pin":"11","set":true,"level":"0","freq":"50","out":"out","x":960,"y":180,"wires":[]},{"id":"e42771f5.eee14","type":"ui_switch","z":"fe382da6.7454b","name":"","label":"Başlat/Durdur","tooltip":"","group":"45b5d58a.06aa5c","order":2,"width":6,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"mi-power_settings_new ","oncolor":"black","offvalue":"false","offvalueType":"bool","officon":"mi-power_settings_new ","offcolor":"yellow","x":780,"y":180,"wires":[["c0d213ab.39009"]]},{"id":"8344c30f.cf4dd","type":"inject","z":"fe382da6.7454b","name":"","topic":"","payload":"+1","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":130,"y":160,"wires":[["653ffb86.337194"]]},{"id":"653ffb86.337194","type":"delay","z":"fe382da6.7454b","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":160,"wires":[["91d6a277.046d6"]]},{"id":"91d6a277.046d6","type":"ui_ui_control","z":"fe382da6.7454b","name":"","events":"all","x":540,"y":160,"wires":[[]]},{"id":"cfbe84c6.2f1368","type":"switch","z":"fe382da6.7454b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"40","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":150,"y":440,"wires":[["8ee0ba6c.3b7a28"]]},{"id":"8ee0ba6c.3b7a28","type":"ui_toast","z":"fe382da6.7454b","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"KAZAN - YÜKSEK SICAKLIK! Derece:","name":"","x":330,"y":440,"wires":[]},{"id":"28801413.b4286c","type":"switch","z":"fe382da6.7454b","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"EBDC79A20003","vt":"str"},{"t":"eq","v":"8056D6192001","vt":"str"},{"t":"eq","v":"560A79A20003","vt":"str"},{"t":"eq","v":"D6F079A20003","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":550,"y":300,"wires":[["cfbe84c6.2f1368","b15926b.5aa18d8"],["deb3bdcd.230b7","b16c7e96.66556"],["8814efdc.c9621","b1015c71.177c4"],["a63924d2.5d63f8","7b48a953.873078","4b66bf34.013c"]]},{"id":"8814efdc.c9621","type":"switch","z":"fe382da6.7454b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"40","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":150,"y":560,"wires":[["e2cac15b.70b6f"]]},{"id":"e2cac15b.70b6f","type":"ui_toast","z":"fe382da6.7454b","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"KASK-2 - YÜKSEK SICAKLIK! Derece:","name":"","x":330,"y":560,"wires":[]},{"id":"a63924d2.5d63f8","type":"switch","z":"fe382da6.7454b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"40","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":150,"y":620,"wires":[["e1ceb4d4.2963c8"]]},{"id":"e1ceb4d4.2963c8","type":"ui_toast","z":"fe382da6.7454b","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"KASK-3 - YÜKSEK SICAKLIK! Derece:","name":"","x":330,"y":620,"wires":[]},{"id":"deb3bdcd.230b7","type":"switch","z":"fe382da6.7454b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"40","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":150,"y":500,"wires":[["deab31b6.394f5"]]},{"id":"deab31b6.394f5","type":"ui_toast","z":"fe382da6.7454b","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"KASK-1 - YÜKSEK SICAKLIK! Derece:","name":"","x":330,"y":500,"wires":[]},{"id":"4a5bfe.56378404","type":"ui_media","z":"fe382da6.7454b","group":"45b5d58a.06aa5c","name":"logo","width":0,"height":0,"order":1,"category":"","file":"logo.jpg","layout":"center","showcontrols":false,"loop":false,"onstart":false,"scope":"local","tooltip":"","x":650,"y":80,"wires":[[]]},{"id":"968aa320.5df7f","type":"inject","z":"fe382da6.7454b","name":"","topic":"","payload":"logo/logo.jpg","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":490,"y":80,"wires":[["4a5bfe.56378404"]]},{"id":"ee2c3bd6.82e1d8","type":"rpi-gpio out","z":"fe382da6.7454b","name":"","pin":"3","set":false,"level":"0","freq":"msg.payload","out":"pwm","x":1100,"y":480,"wires":[]},{"id":"bbc4ced8.6b38c","type":"range","z":"fe382da6.7454b","minin":"0","maxin":"1","minout":"100","maxout":"0","action":"scale","round":false,"property":"payload","name":"","x":940,"y":480,"wires":[["ee2c3bd6.82e1d8"]]},{"id":"7b48a953.873078","type":"PID","z":"fe382da6.7454b","name":"","setpoint":"28.2","pb":1,"ti":"1800","td":"3","integral_default":0.5,"smooth_factor":3,"max_interval":600,"enable":1,"disabled_op":0,"x":780,"y":480,"wires":[["bbc4ced8.6b38c"]]},{"id":"ae4df6b6.0a1c78","type":"inject","z":"fe382da6.7454b","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"onceDelay":"3","x":150,"y":300,"wires":[["5e7e1cb9.2f2ef4"]]},{"id":"5e7e1cb9.2f2ef4","type":"rpi-ds18b20","z":"fe382da6.7454b","topic":"","array":false,"name":"","x":350,"y":300,"wires":[["28801413.b4286c"]]},{"id":"416ddbf1.1d00c4","type":"ui_gauge","z":"fe382da6.7454b","name":"","group":"fbf99233.a08e6","order":4,"width":6,"height":6,"gtype":"gage","title":"Kask-3","label":"derece","format":"{{value | number:1}}","min":"-35","max":"35","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":940,"y":440,"wires":[]},{"id":"4b66bf34.013c","type":"delay","z":"fe382da6.7454b","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":760,"y":400,"wires":[["416ddbf1.1d00c4"]]},{"id":"b1015c71.177c4","type":"delay","z":"fe382da6.7454b","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":740,"y":340,"wires":[["19f671bf.bbc55e"]]},{"id":"19f671bf.bbc55e","type":"ui_gauge","z":"fe382da6.7454b","name":"","group":"fbf99233.a08e6","order":3,"width":6,"height":6,"gtype":"gage","title":"Kask-2","label":"derece","format":"{{value | number:1}}","min":"-35","max":"35","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":940,"y":380,"wires":[]},{"id":"b16c7e96.66556","type":"delay","z":"fe382da6.7454b","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":740,"y":300,"wires":[["83c23f7.c2f88c"]]},{"id":"83c23f7.c2f88c","type":"ui_gauge","z":"fe382da6.7454b","name":"","group":"fbf99233.a08e6","order":2,"width":6,"height":6,"gtype":"gage","title":"Kask-1","label":"derece","format":"{{value | number:1}}","min":"-35","max":"35","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":940,"y":320,"wires":[]},{"id":"b15926b.5aa18d8","type":"delay","z":"fe382da6.7454b","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":740,"y":260,"wires":[["87f114f9.8a9708"]]},{"id":"87f114f9.8a9708","type":"ui_gauge","z":"fe382da6.7454b","name":"","group":"fbf99233.a08e6","order":1,"width":6,"height":6,"gtype":"gage","title":"Kazan","label":"derece","format":"{{value | number:1}}","min":"-35","max":"35","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":930,"y":260,"wires":[]}]

Shared the flow above. Also, I had a problem using gauges. It kept saying "Connection Lost", and it stopped doing that when I got rid of and put Text instead of those. I want to do it with gauges, but I don't understand why that caused a problem.

If I interpret the flow correctly you are trying to read the temperature of four DS18B20 devices every second. If I remember correctly it takes most of a second to read a DS18B20, so trying to read four in one second is doomed to failure. Does it improve matters if you drop that down to once every 10 seconds?

It is the same. Tried with 5 seconds too. I wrote "button", but it is actually the "switch" node in dashboard. Sorry about that part.

In my flow, timestamp starts and repeats the sensor reading, then switch separates them by their unique IDs, then after a tiny amount of delay (without these, it keeps saying "Connection Lost", because gauges can't keep up with the rapid change), I display the values on gauges. This is all a single branch. Another branch is the button, and output pin. This branch waits for the previous one to be done completely, then does its thing. Like waiting in line, so maybe I need something like an "interruption" to cut the process, so switch can do its thing, then the other process continues. I don't know how to do that.

With the inject running at ten seconds, if you put a debug node on the output of the sensor node what do you see? What is the timing of the messages going to that debug node?

I see that it prints out all 4 at the same time mostly, sometimes the 3rd one is one second late, and the 4th one is 2 seconds late, compared to 1st and 2nd one. Button works fine for some time, then it happens again. I think in that 10 second timestamp, 4 second is for sensor to read, 6 seconds are free to do other stuff. It is not able to cut in.

Is there anything I can use as an "interrupt"?

Did you wait for the button stopped working? Does the node output stay the same at that point?

Node output stays the same. It shows 4 values as expected, then I can freely change the swtich state. When it is time for the sensor node to do its thing again, I am unable to change the switch state. I press it, and it happens after the sensor node is done doing its thing.

Ok, that confirms that the node is locking up node-red while it is doing its scan. I think that the idea in this node of doing a complete scan of the bus may be what is causing the problem. I suggest that instead of telling it to scan everything that you use it in the mode where you pass in a device id in the topic. So instead of sending it one inject with empty topic send it four messages with the four id strings in the topic. Then it won't do a complete scan looking for devices but will just get the readings you want.
It is pretty rubbish design that it locks node-red while it is scanning.

I don't use this node I use node-red-contrib-owfs but that requires owserver to be used with it.

1 Like

I couldn't understand it. Can you please explain it in a bit more detail?

How can I send 4 objects, and how can I do it again and again? I have the IDs in the switch, I just couldn't understand how to implement your idea on Node-Red.

Something like this

[{"id":"49bf5a26.718594","type":"inject","z":"57017347.8029cc","name":"Every 10 secs","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":250,"y":480,"wires":[["47b77a6c.0bf7f4"]]},{"id":"47b77a6c.0bf7f4","type":"function","z":"57017347.8029cc","name":"","func":"msg1 = {topic: \"EBDC79A20003\"}\nmsg2 = {topic: \"id2\"}\nmsg3 = {topic: \"id3\"}\nmsg4 = {topic: \"id4\"}\nreturn [[msg1, msg2, msg3, msg4]];","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":480,"wires":[["e0f08517.249998"]]},{"id":"e0f08517.249998","type":"debug","z":"57017347.8029cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"topic","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":480,"wires":[]}]

I put it before the sensor node, now it doesn't switch to the 2nd page. I also got "Connection Lost" error.

Edit: It switched to the 2nd screen and now it is working even slower. It refreshes itself from time to time.

What are you seeing from the 1-wire node now? I presume that you did set up the topics correctly, I had only put the first one in.

It should switch in 2 seconds to the 2nd screen, but it takes like 10 or even more seconds to do that in the editor side, and it stays the same for even a longer period of time on the UI page.Also, it gives 4 of them at the same time like previous version.

Edit: It didn't even switch to the 2nd screen this time. The image was also gone.

But there will be gaps between to let other tasks in. If you stop the inject node from repeatedly injecting and just click it manually does the rest work ok?
Edit - you have not gone back to every second have you?
More edits - do you just see the four values once every ten seconds?

There were no gaps at all.

Yes, when inject is off (when the sensor node is not working), everything works really fast and fine.

No, still 10 seconds. It takes much longer than before when I try to turn the LED on and off. It feels like 4 times longer than before. So, that sensor node may now be doing its own thing 4 times, once for each ID.

So you just get a continuous stream rather than 4 every ten seconds?
Post a screenshot of the debug pane showing the debug from the 1-wire node.