Wipy sensor node
-
Hi all, creating a sensor node comprising temperature, light levels etc. to ping data to my home automation system over MQTT. Temperature is working well with a DS18B20. Now added a plan moisture sensor, and hoping someone can advise on the ADC component. Currently reading a fixed 4095 from the sensor, so presume it is saturating? Unfortunately the sensor has no documentation but I believe @bucknall has used this or a very similar sensor?
https://www.amazon.co.uk/gp/product/B00K67Z76O/ref=oh_aui_detailpage_o06_s00?ie=UTF8&psc=1
-
@robmarkcole The frequency of sampling depends of the rate, your data changes. The sampling for averaging here can be fast, since it just deals with the intrinsic noise of the esp32 adc (which, by the way, is a very bad one). So the whole burst is to be taken as one sample.
The plant moisture will not change really fast. So taking a value burst like once per hour should be more than sufficient. If you want some theory about that, search for "Shannon sampling theorem".
-
@robert-hh OK great, is there a general optimum rate to sample the analogue reading for averaging - or is it hardware specific?
Taking 100 averages and sampling once a second, my values appear to oscillate when in air..
In water, the readings initially drift upwards.
After a minute or so, it appears to reach a steady state.
-
@robmarkcole said in Wipy sensor node:
ADC.ATTN_11DB
ADC.ATTN_11DB is a constant with the value of 3. I tried it with my build, and it did not work. But I have an older build.
The method for integration is a simple average, like:avg = 0 _AVG_NUM = const(100) for _ in range (_AVG_NUM): avg += adc.read() avg /= _AVG_NUM
-
Thanks @robert-hh I am now seeing sensible values. Bit noisy, will have to use a long integration - is there a method for that?
Also I don't see atten=3 as an option in the docs..? https://docs.pycom.io/pycom_esp32/library/machine.ADC.html 'The supported values are: ADC.ATTN_0DB, ADC.ATTN_2_5DB, ADC.ATTN_6DB, ADC.ATTN_11DB'
-
@robmarkcole Hello Rob,
try something like:
apin = adc.channel(pin='P16',attn=3) # create an analog pin on P16
That extends the range of the adc to 0..3.5V. Then it should not overflow, and you can see the required range,
-
HI @livius when I short the two electrodes with a wire the value drops to 0, which is what I expect from the documentation which states high value for high resistance, and low for none. However when I place the electrode in water it briefly changes value (for a single reading) but then returns to 4095. Perhaps I am in differential read mode - or should use a different pin?
I read with:adc = machine.ADC() # create an ADC object
apin = adc.channel(pin='P16') # create an analog pin on P16
analog_val = apin()I notice that the example (https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/adc.html) uses pin 13 but I don't see this on the board diagram (https://docs.pycom.io/pycom_esp32/_downloads/exp_v03_pinout_v13.pdf)
-
@robmarkcole
i see 3V3 poverin - good
Now question is how you declare ADC?
And do you checked what chappened if you put some part to water? Does value changed? And what happened on digital pin from sensor (currently not connected by you)