Way for one device to quickly report on another being up/running?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Normal user
Posts: 7
Joined: 20 Jun 2018, 20:51

Way for one device to quickly report on another being up/running?

#1 Post by DonV » 30 Jun 2018, 09:22

Hi, continue to be thrilled/amazed by what I can do with ESP Easy pretty much out of the box! I'm running stable R1.20 on several different models of 8266.

My application is temperature and humidity data capture for a non-profit's current building as we prepare a fundraiser towards installing air conditioning. We're working to capture actual conditions over time to inform the system sizing effort. I've got either DHT-22 or DS18B20 sensors attached to each node to capture the conditions.

On one of the modules installed I also have an OLED display which currently shows temperature and humidity values from the directly attached sensors, plus a couple of remote sensors made available via the global sync approach (with some rules to manipulate the data before displaying it from dummy devices). Once I figured out how all that worked and remembered to give every device an IDX number not.eq 0, it's been working great.

So far I've not been able to figure out a clean way to do the following, would appreciate any tips or guidance.

One of my nodes is to be powered in parallel with a whole room exhaust fan (controlled via wall-switched mains). It's one of the nodes that's set up for global sync and currently feeding temperature data as a global value. In the final application, that node will be powered on and off as the exhaust fan is switched on and off. As a result, the node will go off line occasionally (more off than on).

I would like to be able to show the power on/off status of the fan-tied unit via the OLED display on the other unit, e.g.: Fan ON or OFF, as a means for folks to check the status on this fan which is high up in a cupola and hard to hear 40 ft. below. I would like this to be accurate to within ~10 seconds, which is the refresh timing currently set on the display and about the amount of time required to walk across the large room the fan is in to the exit door where the display is. Ideally, I would also like to have a clean on/off status show up in Domoticz as well as a means to let us determine the in-room conditions impact of the fan.

It's unclear to me how the second (display) unit may be set up to determine if the fan-tied unit is currently on-line/up? I guess this could be based upon the last temperature update time (if that is somehow retained) or some other global sync variable but it's over my head right now and I'd love some guidance as to a possible low-latency approach to make this work.


Normal user
Posts: 32
Joined: 12 Jun 2017, 11:12

Re: Way for one device to quickly report on another being up/running?

#2 Post by countcobolt » 30 Jun 2018, 09:59


My 2ct's:
- connect a capacitor between the source power and the esp device
- Make sure you have a diode between the original source and a capacitor, so when the power shuts off, the capacitor doesn't try to power the fan.
- Measure the power before the diode on the source side and connect it (using the right resistors for voltage) to the Analog input (or if it is 5v / 3.3V to Digital input which.
- When the main fan turns of , the esp device will run a bit longer on the capacitor, yet your A0 or digital input will drop to 0. At that drop report to the main node that the power down. When it is up report that it is on.

Kind regards


PS: I used this with a 1F capacitor to make sure that my raspberry pi properly shuts down when the power is gone.
PPS: Keep in mind that the capacitor needs to be charged and can pull so much power that it kills the main power. Pay attention with those.

Normal user
Posts: 7
Joined: 20 Jun 2018, 20:51

Re: Way for one device to quickly report on another being up/running?

#3 Post by DonV » 30 Jun 2018, 22:38

Thanks for the ideas. Unfortunately the unit and sensor package HW is already completed and is using an ESP-01 module hard soldered with no pins available. I do have a 470uF cap on the power pins to help with stability. I've seen cautions on line regarding having DC fans in the same circuit. The unit is powered by an old mobile phone AC to USB 5v wall wart with no other loads than a 5v->3V3 converter feeding the ESP-01, not directly connected to the fan and not DC coupled to the fan in any way. I'm hoping this set-up brings no greater risk to the ESP-01 than turning on and off your kitchen exhaust fan while having your cell charger elsewhere on the same AC mains branch.

I was hoping to accomplish this in software and had an idea overnight. It appears there are some new system variables (like %unixtime%) which are not available in the R1.20 release I'm using (plus some other limitations I've been finding). As a result, I'm going to try a workaround along these lines (pseudo code):

On cupola unit - Set up global sync dummy device value cup_uptm_dec and local value uptm_dec_ctr with a delay of 5 sec

Cupola unit rules

Code: Select all

- On boot, set cup_uptm_dec = 0, uptm_dec_ctr = 9 // starts at 9 to avoid single digit decimals problem downstream
- In a 5 second timer loop:
-- If uptm_dec_ctr >= 39, set uptm_dec_ctr = 9 // start over
-- Increment uptm_dec_ctr by 1 // ticks off 5 second units of time
-- set cup_uptm_dec = %uptime%.[uptm_dec_ctr] // concats uptm_dec_ctr to uptime for 5 second granularity i.e. 23.10 increments to 23.11, etc. up to 23.39
// should %uptime% increment within the uptm_dec_ctr loop cycle, cup_uptm_dec still works for true comparison i.e. 23.11 increments to 24.12
- end timer loop
On display unit - Set up local dummy device values fan_status, cup_uptm_last, cup_updt_ck with delay = 5 seconds

Display unit rules

Code: Select all

- On boot, set fan_status = 0, cup_uptm_last = 0, cup_unit_ck = 0
- Timer loop for 5 seconds:
-- If fan_status <> 1 // not already ON
--- If cup_uptm_dec > cup_uptm_last // cupola unit is up/fan on
--- Set fan_status = 1 // ON
-- Else // currently ON
--- If cup_uptm_dec <= cup_uptm_last // cupola unit off or booted <= 1 timer cycle ago
---- Increment cup_updt_ck by 1
---- If cup_unit_ck > 1 // two timer cycles with no uptime increase, so cupola unit off
----- Set fan_status = 0 // OFF
----- Set reported temperature value = 999 // or some other way to disable data display if off
----- Set cup_unit_ck = 0 // reset check counter
---- End if
--- End if
-- End if/else
-- Set cup_uptime_last = cup_uptm_dec // store latest value locally
- end timer loop
I'm hoping that the timing and limited number of write cycles on a 5 second cadence will not be an issue.

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests