capacitive moisture sensor
capacitive moisture sensor
I am new to MP, and have searched this archive, and the internet in general. I am using a NodeMCU V3 board, flashed with "..20191220-v1.12.bin". The code outputs a 3, or 2. Just a guess, is that voltage? It is powered at 3.3v with yellow connected to D0. See attached code:
import machine
from machine import Pin
from machine import ADC
import time
from time import sleep
moisture = ADC(0)
while True:
moisture_value = moisture.read()
print(moisture_value)
sleep(3)
Thanks in advance, cheers from Nova Scotia
import machine
from machine import Pin
from machine import ADC
import time
from time import sleep
moisture = ADC(0)
while True:
moisture_value = moisture.read()
print(moisture_value)
sleep(3)
Thanks in advance, cheers from Nova Scotia
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: capacitive moisture sensor
You'll need to give us more information about your sensor hardware and how it's connected if we are to be able to help.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: capacitive moisture sensor
Good day Sir,
This is the unit: https://www.amazon.com/Analog-Capacitiv ... il-bullets
I got these specs from the same site.
This analog capacitive soil moisture sensor measures soil moisture levels by capacitive sensing, rather than resistive sensing like other types of moisture sensor
It is made of a corrosion resistant material giving it a long service life
Insert it into soil and impress your friends with the real-time soil moisture data
This module includes an on-board voltage regulator which gives it an operating voltage range of 3.3 ~ 5.5V
This sensor is compatible with DFRobot 3-pin "Gravity" interface, which can be directly connected to the Gravity I/O expansion shield
Features:
Supports 3-Pin Gravity Sensor interface
Analog output
Applications:
Garden plants
Moisture detection
Intelligent agriculture
Specifications:
Operating Voltage: DC 3.3-5.5V
Output Voltage: DC 0-3.0V
Interface: PH2.0-3P
Size: 99x16mm/3.9x0.63"
Quantity: 1 Set
This is the unit: https://www.amazon.com/Analog-Capacitiv ... il-bullets
I got these specs from the same site.
This analog capacitive soil moisture sensor measures soil moisture levels by capacitive sensing, rather than resistive sensing like other types of moisture sensor
It is made of a corrosion resistant material giving it a long service life
Insert it into soil and impress your friends with the real-time soil moisture data
This module includes an on-board voltage regulator which gives it an operating voltage range of 3.3 ~ 5.5V
This sensor is compatible with DFRobot 3-pin "Gravity" interface, which can be directly connected to the Gravity I/O expansion shield
Features:
Supports 3-Pin Gravity Sensor interface
Analog output
Applications:
Garden plants
Moisture detection
Intelligent agriculture
Specifications:
Operating Voltage: DC 3.3-5.5V
Output Voltage: DC 0-3.0V
Interface: PH2.0-3P
Size: 99x16mm/3.9x0.63"
Quantity: 1 Set
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: capacitive moisture sensor
The ESP8266 ADC has a 0-1V range. Some boards (e.g. the D1 Mini) have a voltage divider to provide a 3.3V range. Unless the NodeMCU V3 has a voltage divider, you will need to provide one to bring the 0-3.0V range down to 0-1.0V.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: capacitive moisture sensor
I have this image, it's yours from a previous discussion. Is J1 the positive voltage for the sensor? ESP8266 has no attenuation, so this will hopefully get me on track. Thanks! I just connected it with the supplied resistance and wiring, same deal number 2 or 3 in the output. I am getting 1.0 v DC from J1 to ground, same 2 or 3 as the output?
Re: capacitive moisture sensor
Please see drawing, is this what I am after?pythoncoder wrote: ↑Thu Jun 25, 2020 5:00 pmThe ESP8266 ADC has a 0-1V range. Some boards (e.g. the D1 Mini) have a voltage divider to provide a 3.3V range. Unless the NodeMCU V3 has a voltage divider, you will need to provide one to bring the 0-3.0V range down to 0-1.0V.
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: capacitive moisture sensor
as far as I know all nodemcu v3 boards already have a voltage divider so you can put 3.3V to the adc pin. (haven't used the adc pin in a while but got lots of nodemcu v3 here and iirc I always connected 3.3V directly to the adc)
But you can easily check that. Put 3.3V onto your voltage divider and if the adc doesn't read 1024 but ~300 then there's already a voltage divider on the board.
But your drawing is definitely not what you're after. What you did is make a voltage divider on the power supply and then have a 2.2kR before the device which means it won't work at all because it only gets a small fraction of voltage.
You (maybe) need a voltage divider between the output pin and the adc pin.
When refering to your picture, the 3.3V is the output of the sensor and j1 is the adc pin.
But you can easily check that. Put 3.3V onto your voltage divider and if the adc doesn't read 1024 but ~300 then there's already a voltage divider on the board.
But your drawing is definitely not what you're after. What you did is make a voltage divider on the power supply and then have a 2.2kR before the device which means it won't work at all because it only gets a small fraction of voltage.
You (maybe) need a voltage divider between the output pin and the adc pin.
When refering to your picture, the 3.3V is the output of the sensor and j1 is the adc pin.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: capacitive moisture sensor
I don't have a nodemcu board. You want to power the sensor from 3.3V. If Kevin is right (he usually is ) you can connect connect the output directly to the ADC pin: no resistors required.
Then issue
Then issue
Code: Select all
from machine import ADC
adc = ADC(0)
print(adc.read_u16())
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: capacitive moisture sensor
Thanks!! I connected a new sensor to a new NodeMCU, with a DHT22 also connected and the following code gives me all the inputs i need without resistors.pythoncoder wrote: ↑Sat Jun 27, 2020 10:57 amI don't have a nodemcu board. You want to power the sensor from 3.3V. If Kevin is right (he usually is ) you can connect connect the output directly to the ADC pin: no resistors required.
Then issueCode: Select all
from machine import ADC adc = ADC(0) print(adc.read_u16())
from machine import Pin
from machine import ADC
from time import sleep
import dht
adc = ADC(0)
sensor = dht.DHT22(Pin(14))
#sensor = dht.DHT11(Pin(14))
while True:
try:
sleep(2)
sensor.measure()
temp = sensor.temperature()
hum = sensor.humidity()
temp_f = temp * (9/5) + 32.0
print('Temperature: %3.1f C' %temp)
print('Temperature: %3.1f F' %temp_f)
print('Humidity: %3.1f %%' %hum)
sleep(1)
print(adc.read_u16())
except OSError as e:
print('Failed to read sensor.')
I get this output:
Temperature: 27.3 C
Temperature: 81.1 F
Humidity: 49.4 %
50943
feels good to get a result, perfect start to a plant minder, warm evening in the Maritimes. Thanks for your patience and indulgence!