Trying to send Sauna temp to Thingspeak

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
jarbeni
New user
Posts: 7
Joined: 01 Apr 2018, 14:16

Trying to send Sauna temp to Thingspeak

#1 Post by jarbeni » 08 Sep 2019, 20:14

Hello!

I have a 18650 battery operated wemos D1 in an enclosure in bathroom and the ds18b20 temp sensor goes to sauna.

I am using analog input along with the temp sensor, for reading battery voltage.

Instead of reading and publishing sauna temperature to Thingspeak in a fixed interval, I would like to make the temperature determine if values are sent in a slow or fast interval.
Because, when sauna is not in use, it is about 25 degrees and something like 15 minute interval is enough.
And then when sauna is turned on to heat up, the temp sensor will soon see a rise in temperature, and after +30 degrees, the interval should change to updating every 1 minute.
After sauna is shut down, and temperature drops below 30 degrees, the update interval should be 15 minutes again.
Also, when ever possible, wemos should be sleeping.


So far, I have no luck.
I´m either locked out of the web interface because of immeadiate sleeping, or things seem to work but no values are sent to ThingsPeak.

This is my latest Rule arrangement:

Code: Select all

on Wifi#Connected do

if [Sauna#Temperature]>30

sendToHTTP api.thingspeak.com,80,/update?key=XXXXXXXXXXXXXXX&field7=[Sauna#Temperature]
timerSet,1,16      //Set Timer 1 for the next event in 16 seconds


on Rules#Timer=1 do  //When Timer1 expires, do
sendToHTTP api.thingspeak.com,80,/update?key=XXXXXXXXXXXXXXX&field8=[akku#percentage]
timerSet,1,0

delay 10000 //lähetetään tietoa 60 sek välein
deepsleep,60 //Sauna is heating, so going for short sleep

endif


if [Sauna#Temperature]<30

sendToHTTP api.thingspeak.com,80,/update?key=XXXXXXXXXXXXXXX&field7=[Sauna#Temperature]
timerSet,2,16      //Set Timer 1 for the next event in 15 seconds
endon

on Rules#Timer=2 do  //When Timer1 expires, do
sendToHTTP api.thingspeak.com,80,/update?key=XXXXXXXXXXXXXXX&field8=[akku#percentage]
timerSet,2,0

delay 20000 //delay just for fun

deepsleep,900 //sauna was cold, going for a longer sleep

endif


endon

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Trying to send Sauna temp to Thingspeak

#2 Post by grovkillen » 09 Sep 2019, 14:52

Okay, you're missing the syntax. Please study the documentation regarding how to write rules. EndIf and EndOn for example is really important to get right...


I have created a simpler ruleset for you.

Code: Select all

on Wifi#Connected do
  if [Sauna#Temperature]>30
    event,PublishToThingSpeak=60
  else
    event,PublishToThingSpeak=900
  endif
endon

on PublishToThingSpeak do
  let,1,%eventvalue%
  sendToHTTP,api.thingspeak.com,80,/update?key=XXXXXXXXXXXXXXX&field7=[Sauna#Temperature]
  timerSet,1,15
endon

on Rules#Timer=1 do
  sendToHTTP,api.thingspeak.com,80,/update?key=XXXXXXXXXXXXXXX&field8=[akku#percentage]
  deepsleep,[VAR#1]
endon
Let is setting an internal variable to the preferred deepsleep length (only to be used later once the timer expires). I fetch the internal variable by this syntax [VAR#1].
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

jarbeni
New user
Posts: 7
Joined: 01 Apr 2018, 14:16

Re: Trying to send Sauna temp to Thingspeak

#3 Post by jarbeni » 09 Sep 2019, 17:56

You made that look like so much simpler.
I kind of understand what you did there, but I need to look at that more carefully so that I really understand how that is done.

Like you said, endif and endon were something I was unsure how to put them on my code.
That "Let" is completely a new thing for me.

Thanks very much for helping me on this!

jarbeni
New user
Posts: 7
Joined: 01 Apr 2018, 14:16

Re: Trying to send Sauna temp to Thingspeak

#4 Post by jarbeni » 09 Sep 2019, 18:17

I tried this and it is not sending anything to Thingspeak.

I do see this on serial log:

Code: Select all

6884 : ACT  : sendToHTTP,api.thingspeak.com,80,/update?key=(MY WRITE API KEY)&field7=25.31
6894 : Command: sendtohttp
My earlier attempts failed too, even with the simpliest way to send ANYTHING.

I start to suspect that problem is in the way espeasy sends to Thingspeak using rules.
If I just make a Thingspeak controller and set a device to send values there, it always works.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Trying to send Sauna temp to Thingspeak

#5 Post by TD-er » 09 Sep 2019, 19:07

That's right, there is also an issue about it.
The send to http called from the rules is not waiting for an acknowledgement.

jarbeni
New user
Posts: 7
Joined: 01 Apr 2018, 14:16

Re: Trying to send Sauna temp to Thingspeak

#6 Post by jarbeni » 09 Sep 2019, 21:58

Yes, I read about that somewhere.

But why my motion detector is working ok then?

It has the collowing code and everything works:

Code: Select all

on Motion#Detection=1 do

SendToHTTP api.thingspeak.com,80,/update?api_key=(MY WRITE API KEY)&field1=0
delay 15000
SendToHTTP api.thingspeak.com,80,/update?api_key=(MY WRITE API KEY)&field1=1
delay 60000
SendToHTTP api.thingspeak.com,80,/update?api_key=(MY WRITE API KEY)&field1=0

delay 60000
endon

Why does this work properly then?
I know I had differences in fimware, so I updated my Sauna Thermometer but that didn´t help.
(That 0, 1, 0, is my way to have a motion indicationg spike that starts from a recent zero value, and not from some previous value in history.)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Trying to send Sauna temp to Thingspeak

#7 Post by TD-er » 09 Sep 2019, 22:24

Oh please do not use delay in rules and especially not delay calls over several seconds.
I really should do something about this delay command, like print it on paper and burn it.

Rules' Delay Statement Considered Harmful.

Please use timers for this and don't use delay.
The delay command does halt the entire node for the set period.

jarbeni
New user
Posts: 7
Joined: 01 Apr 2018, 14:16

Re: Trying to send Sauna temp to Thingspeak

#8 Post by jarbeni » 09 Sep 2019, 22:41

Oh okay then.. :shock:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Trying to send Sauna temp to Thingspeak

#9 Post by grovkillen » 10 Sep 2019, 10:44

You could try this one:

Code: Select all

on Motion#Detection=1 do
  if [VAR#16]=0
   Let,16,1
   SendToHTTP,api.thingspeak.com,80,/update?api_key=(MY WRITE API KEY)&field1=0
   TimerSet,1,15
  endif
endon

on Rules#Timer=1 do
  SendToHTTP,api.thingspeak.com,80,/update?api_key=(MY WRITE API KEY)&field1=1
  TimerSet,2,60
endon

on Rules#Timer=2 do
  SendToHTTP,api.thingspeak.com,80,/update?api_key=(MY WRITE API KEY)&field1=0
  TimerSet,3,60
endon

on Rules#Timer=3 do
  Let,16,0
endon

ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Nestitherapy
New user
Posts: 2
Joined: 09 Sep 2019, 09:19

Re: Trying to send Sauna temp to Thingspeak

#10 Post by Nestitherapy » 19 Sep 2019, 12:49

I tried and is not sent to Thingspeak.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Trying to send Sauna temp to Thingspeak

#11 Post by grovkillen » 19 Sep 2019, 13:16

Can you send it manually? As a test.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Trying to send Sauna temp to Thingspeak

#12 Post by TD-er » 19 Sep 2019, 15:26

SendToHTTP and thingspeak are not working, that's a known issue.

For Thingspeak you need to wait for the response from the server and SendToHTTP does not wait for a response.
For that you really need to use the Thingspeak controller.

User avatar
iron
Normal user
Posts: 221
Joined: 24 Sep 2016, 08:37
Location: Greece
Contact:

Re: Trying to send Sauna temp to Thingspeak

#13 Post by iron » 20 Sep 2019, 12:22

mine works...

https://thingspeak.com/channels/33034

Code: Select all

On Thermometer#Temperature do
SendToHTTP,api.thingspeak.com,80,/update?api_key={myAPIkey]&field1=[Thermometer#Temperature]&field2=[Thermometer#Humidity]
endon
-D
-D

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 27 guests