Skip to content

Commit 48a837c

Browse files
authored
Merge pull request #3074 from adafruit/soil_sensor
additional soil sensor examples
2 parents e9b900c + b74bbaf commit 48a837c

File tree

6 files changed

+79
-0
lines changed

6 files changed

+79
-0
lines changed

Simple_Soil_Sensor_Demos/Arduino/metroAdvSoilSensor/.uno.test.only

Whitespace-only changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
/* Advanced Soil Sensor Demo */
6+
7+
int sensorPin = A0;
8+
int onPin = 2;
9+
int moisture = 0;
10+
11+
void setup() {
12+
Serial.begin(115200);
13+
while ( !Serial ) delay(10);
14+
pinMode(onPin, OUTPUT);
15+
16+
}
17+
18+
void loop() {
19+
digitalWrite(onPin, HIGH);
20+
delay(1000);
21+
// read the value from the sensor:
22+
moisture = analogRead(sensorPin);
23+
Serial.println(moisture);
24+
digitalWrite(onPin, LOW);
25+
delay(1000);
26+
}

Simple_Soil_Sensor_Demos/Arduino/metroSimpleSoilSensor/.uno.test.only

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
/* Simple Soil Sensor Demo */
6+
7+
int sensorPin = A0;
8+
int moisture = 0;
9+
10+
void setup() {
11+
Serial.begin(115200);
12+
while ( !Serial ) delay(10);
13+
14+
}
15+
16+
void loop() {
17+
// read the value from the sensor:
18+
moisture = analogRead(sensorPin);
19+
Serial.println(moisture);
20+
delay(2000);
21+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import time
6+
import board
7+
from analogio import AnalogIn
8+
from digitalio import DigitalInOut, Direction
9+
10+
sensor_power = DigitalInOut(board.D5)
11+
sensor_power.direction = Direction.OUTPUT
12+
13+
analog_in = AnalogIn(board.A0)
14+
15+
while True:
16+
sensor_power.value = True
17+
print(f"Soil Moisture: {analog_in.value}")
18+
sensor_power.value = False
19+
time.sleep(5)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import time
6+
import board
7+
from analogio import AnalogIn
8+
9+
analog_in = AnalogIn(board.A0)
10+
11+
while True:
12+
print(f"Soil Moisture: {analog_in.value}")
13+
time.sleep(5)

0 commit comments

Comments
 (0)