Explorer pHAT analog-event.py gives no output


#1

I have a 10-turn 20k trimpot connected between 5V and Gnd with the wiper connected to Analog1. I can see the voltage for Analog1 vary when I run sensor.py, but I get no output from analog-event.py.

Is there more information about analog changed() beyond:
“changed( handler_function, sensitivity ) - Calls “handler_function” when a change greater than the threshold millivolts occurs”?

  • What is the time period for the change? My trimpot might be too slow to adjust?
  • There is no sensitivity value in analog-event.py; what is the default value? Adding a small value (1) has not made a difference in my case.

I’m hoping to monitor an analog pressure transducer on a well pump with this, and the value varies slowly. I can find other ways to alert me to values of interest, but this seemed like a interesting way to do it.


#2

according to the library, the default sensitivity is 0.1mV and the polling occurs every 0.01s… if I’m reading this right.

Try to pass a sensitivity value of 0.02, it will probably help (0.01 was too sensitive here and would register occassional random change)


#3

Thanks for your rapid reply! That sounds like the kind of info I’m looking for - can you give a link so I can read more?
The sensitivity unit would be volts, with a default of one millivolt if I understand correctly. I was confused by the mention of ‘threshold millivolts’.
Trying the values you suggested does indeed bring results. It looks like it would be useful for rapid changes (checked every 10 mS) rather than the slower changes for the signal I’m following. I’d like to look further into the library.


#4

the sensitivity is in milivolts, same as the readings, see:

https://github.com/pimoroni/explorer-hat/blob/74d8da9f88a3b3635b0be25f32627fbf0fada25f/library/explorerhat/init.py#L568-L574

the default is specified as part of the init for the class, on line 549 (at this point in time).