Please can someone give me a pointer on how to poll slider widgets when an ESP8266 wakes from sleep? Any help would me much appreciated.
Thanks
Paul
The objective is as follows:
This is a newbie project to do room temperature balancing. I’m logging temperature data to Cayenne but also want a visual output on the unit itself.
-I’ve got LEDs attached to an ESP8266 that change colour to show whether a DHT11 sensor is within a particular range.
The ESP8266 sleeps for a while then wakes, takes a reading and sends it to Cayenne, flashes the appropriate LED colour (red too warm, blue too cold) then goes back to sleep.
I’ve put upper and lower range sliders on my dashboard that I want to use as two variables in my code.
The hope was that I would be able to tweak the upper and lower temp limits from the dashboard rather than tweaking the code and uploading to the board.
Moving the sliders works perfectly when the ESP8266 is awake, but if I move them while it’s asleep then the changes aren’t picked up when it wakes. This does make sense based on my limited understanding of MQTT as the subscriber isn’t listening when the change is published and then presumably sent out by the broker.
Progress so far:
ESP8266 connects to Cayenne, publishes temp and humidity, sleeps, wakes and repeats.
Any slider changes that I happen to make while the ESP8266 is awake make their way to the ESP8266.
I looked through the documentation and tried CAYENNE_CONNECTED() and Cayenne.SyncVirtual but then found that these weren’t applicable to MQTT.
I know that changes in the sliders are received by the device when it’s not in deep sleep. So, I can add a physical “wake from sleep” button connected to the reset pin. I can then press that button to know that it’s awake. I can then adjust the sliders from Cayenne and know that it will update the values held on the device.
i am not sure if the value is stored if the device is offline and the slider position is changed. @jameszahary can you it a try whether this is possible?
When I unplug a 8266 that owns the slider, I can change the slider on the website, but after a refresh the slider goes back to where it started. And when I query the database with rest-api, I get the original value.
So the slider will only change if its device is connected and receiving messages.
Idea: You could put the slider on a different 8266 and cayenne device that is always connected, and receiving messages, and then query that from your usually sleeping 8266. But you would not get the immediate update through mqtt of the changes on the usually sleeping device, but rather just on the always awake device. So somewhat complicated approach.
Mostly when you have an actuator to control it is best that the device is online always. it is only when sensors are present the device can go offline and send data when the device comes back online.