Feather M0 analogRead()

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
pythonaire
 
Posts: 66
Joined: Fri Nov 15, 2019 9:38 am

Feather M0 analogRead()

Post by pythonaire »

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

User avatar
dastels
 
Posts: 15667
Joined: Tue Oct 20, 2015 3:22 pm

Re: Feather M0 analogRead()

Post by dastels »

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

User avatar
MarkEmK
 
Posts: 13
Joined: Sun Jul 25, 2021 4:46 pm

Re: Feather M0 analogRead()

Post by MarkEmK »

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 :)

User avatar
dastels
 
Posts: 15667
Joined: Tue Oct 20, 2015 3:22 pm

Re: Feather M0 analogRead()

Post by dastels »

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.
If there's a capacitor involved in generating the output voltage there may be some settling time. But just a wild guess :)

Dave

User avatar
pythonaire
 
Posts: 66
Joined: Fri Nov 15, 2019 9:38 am

Re: Feather M0 analogRead()

Post by pythonaire »

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?

User avatar
pythonaire
 
Posts: 66
Joined: Fri Nov 15, 2019 9:38 am

Re: Feather M0 analogRead()

Post by pythonaire »

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

User avatar
pythonaire
 
Posts: 66
Joined: Fri Nov 15, 2019 9:38 am

Re: Feather M0 analogRead()

Post by pythonaire »

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”