File tree Expand file tree Collapse file tree 6 files changed +79
-0
lines changed Expand file tree Collapse file tree 6 files changed +79
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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 )
Original file line number Diff line number Diff line change
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 )
You can’t perform that action at this time.
0 commit comments