SubName: Reading a water sensor (3 pin red)
Description: You can use this simple code to read a 3 pin rain/droplet/water sensor detector.
When the sensor is completely dry (no resistance) the logs will show 0(zero). With this particular sensor the more water there is on it, the more there is resistance, thus the reading goes higher.
Tags: Water, Sensor, Arduino, ESP
Arduino wiring
Actual sensor/module
Description: You can use this simple code to read a 3 pin rain/droplet/water sensor detector.
When the sensor is completely dry (no resistance) the logs will show 0(zero). With this particular sensor the more water there is on it, the more there is resistance, thus the reading goes higher.
********************* PROGRAM STARTING ****************
AppStart
0
it's dry
0
it's dry
515
It's Wet
542
It's Wet
657
It's Wet
653
It's Wet
693
It's Wet
672
It's Wet
659
It's Wet
653
It's Wet
649
It's Wet
649
It's Wet
649
It's Wet
635
It's Wet
583
It's Wet
578
It's Wet
580
It's Wet
639
It's Wet
656
It's Wet
648
It's Wet
648
It's Wet
599
It's Wet
557
It's Wet
550
It's Wet
535
It's Wet
385
It's Wet
375
It's Wet
369
It's Wet
362
It's Wet
355
It's Wet
355
It's Wet
353
It's Wet
389
It's Wet
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
AppStart
0
it's dry
0
it's dry
515
It's Wet
542
It's Wet
657
It's Wet
653
It's Wet
693
It's Wet
672
It's Wet
659
It's Wet
653
It's Wet
649
It's Wet
649
It's Wet
649
It's Wet
635
It's Wet
583
It's Wet
578
It's Wet
580
It's Wet
639
It's Wet
656
It's Wet
648
It's Wet
648
It's Wet
599
It's Wet
557
It's Wet
550
It's Wet
535
It's Wet
385
It's Wet
375
It's Wet
369
It's Wet
362
It's Wet
355
It's Wet
355
It's Wet
353
It's Wet
389
It's Wet
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
0
it's dry
B4X:
'WIRE LEGEND for red 3 pin water sensor
'GND = GND
'VCC = 5V
'S (Sensor) = A0
'*************************
'*** BOARD TYPE ***
'*** Mega or Mega 2560 ***
'*************************
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Private V_Pin_A0 As Pin
Private TmrReadings As Timer
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
V_Pin_A0.Initialize(0, V_Pin_A0.AnalogRead)
TmrReadings.Initialize("Readings_Tick", 1000)
TmrReadings.Enabled = True
End Sub
Sub Readings_Tick
Log(V_Pin_A0.AnalogRead)
If V_Pin_A0.AnalogRead = 0 Then Log("It's dry") Else Log("It's wet")
End Sub
Arduino wiring
Actual sensor/module
Last edited: