Hi all,
Apologies if this has been asked and answered already but I couldn’t find it in this forum. I am running ESPHome and programming up some MH-ET live ESP32 boards (mhetesp32minikit). What I am trying to achieve is to see the maximum voltage that was present on a pin and tx that value to HomeAssistant. At the moment on my test bed I have 3.3Vdc being pulsed on for 30ms and then off every second. I know the voltage is getting to the pins as I have an LED showing the pulses. However with my programming and at this speed of pulse it only shows me 0.075V all the time. If I turn on very_verbose mode on and look at the debug I can see
[13:26:02][VV][scheduler:226]: Running interval 'update' with interval=60000 last_execution=2323018 (now=2383018)
[13:26:02][V][adc:132]: 'Max V': Got voltage=0.0750V
[13:26:02][V][sensor:043]: 'Max V': Received new state 0.075000
[13:26:02][VV][sensor.filter:014]: Filter(0x3ffb2a5c)::input(0.075000)
[13:26:02][VV][sensor.filter:170]: MaxFilter(0x3ffb2a5c)::new_value(0.075000)
[13:26:02][VV][sensor.filter:182]: MaxFilter(0x3ffb2a5c)::new_value(0.075000) SENDING 0.075000
[13:26:02][VV][sensor.filter:021]: Filter(0x3ffb2a5c)::output(0.075000) -> SENSOR
[13:26:02][D][sensor:094]: 'Average V of Electric Fence': Sending state 0.07500 V with 2 decimals of accuracy
[13:26:02][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
key: 1383357185
state: 0.075
missing_state: NO
I assume that it takes a measurement at that exact moment in time and not over the whole period of time?
As a test I increased the on time to 500ms and I can see that it does pick up the value now, and can only assume that the sample period is too slow to pick up my 30ms pulse?
As a seperate test I setup a pulse counter to measure the rising edges and it can pick up 60 pulses every minutes, so that tells me that it is able to sample for that short period of time.
I just want to know if I have done something wrong and there is a way to measure a peak voltage within a second and tx that to HomeAssistant.
Code for ESP below:
- platform: pulse_counter
pin: GPIO35
count_mode:
rising_edge: INCREMENT
falling_edge: DISABLE
name: "pulse counter referance"
update_interval: 60s
- platform: adc
pin: GPIO34
name: "Max V"
attenuation: auto
filters:
- max:
window_size: 6
send_every: 1