i use a moisture sensor on A0 with analogRead(). To get a more stable measurement, i cycle 10 times and calculate the average.
At all measurement loops, the first measured value is around the half of the remaining measured values. Ex.: the first value is 200, the remaining values toogling at 400. Curious.
Need the analogRead() a kind of activation for the port?
Thx Peter
Feather M0 analogRead()
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- dastels
- Posts: 15667
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Feather M0 analogRead()
What moisture sensor? It might be that it needs a refresh time before another reading can be made. You could try increasing the time between readings.
Dave
Dave
- MarkEmK
- Posts: 13
- Joined: Sun Jul 25, 2021 4:46 pm
Re: Feather M0 analogRead()
It sounds like your moisture sensor just outputs a voltage proportional to the moisture level, so hard to see why it would need a refresh time. Are you powering it down between each block of 10 readings? If so, perhaps it has a startup time requirement.
It would be helpful to know what device you're using, otherwise you will get more wild guesses like mine :)
It would be helpful to know what device you're using, otherwise you will get more wild guesses like mine :)
- dastels
- Posts: 15667
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Feather M0 analogRead()
If there's a capacitor involved in generating the output voltage there may be some settling time. But just a wild guess :)MarkEmK wrote:It sounds like your moisture sensor just outputs a voltage proportional to the moisture level, so hard to see why it would need a refresh time.
Dave
- pythonaire
- Posts: 66
- Joined: Fri Nov 15, 2019 9:38 am
Re: Feather M0 analogRead()
Thx for commenting, I was on holiday, sorry for late answer.
It is an DFRobot capacity moisture sensor SEN0308, data line is connected to the A0 port.
Before the measuring starts, the sensor is set on power, controlled by a mosfet, after that a delay of 50 ms.
My workaround is: a "useless" analogRead() command plus 100ms delay before the actual measuring begins. Like a sensor warmup.
After some probing i saw, a loop with 5 readings is enough to get a "stable" value. Additionally i set 100ms delay between each reading in the loop.
Im more python experienced, then C++. Is there a chance to make a kind of reset for the A0 port for analog reading?
It is an DFRobot capacity moisture sensor SEN0308, data line is connected to the A0 port.
Before the measuring starts, the sensor is set on power, controlled by a mosfet, after that a delay of 50 ms.
My workaround is: a "useless" analogRead() command plus 100ms delay before the actual measuring begins. Like a sensor warmup.
After some probing i saw, a loop with 5 readings is enough to get a "stable" value. Additionally i set 100ms delay between each reading in the loop.
Im more python experienced, then C++. Is there a chance to make a kind of reset for the A0 port for analog reading?
- pythonaire
- Posts: 66
- Joined: Fri Nov 15, 2019 9:38 am
Re: Feather M0 analogRead()
found it:
the unit itself stands outside, battery powered. to save battery capacity i use deep sleep. each time the system comes up, i powering both sensors with a Mosfet triggered by a pin.
the Mosfet for powering the moisture sensor has a malfunction.
Thx for your advices
the unit itself stands outside, battery powered. to save battery capacity i use deep sleep. each time the system comes up, i powering both sensors with a Mosfet triggered by a pin.
the Mosfet for powering the moisture sensor has a malfunction.
Thx for your advices
- pythonaire
- Posts: 66
- Joined: Fri Nov 15, 2019 9:38 am
Re: Feather M0 analogRead()
Hahaha - the MOSFET has not a malfuntion, rather my brain...
i bought a false MOSFET, thought it was a PNP MOSFET, but it is a NPN-MOSFET.
i bought a false MOSFET, thought it was a PNP MOSFET, but it is a NPN-MOSFET.
Please be positive and constructive with your questions and comments.