Test soil sensor
This commit is contained in:
parent
e087e51ecb
commit
12c82944cc
1 changed files with 23 additions and 0 deletions
23
soil-sensor/soil-sensor.ino
Normal file
23
soil-sensor/soil-sensor.ino
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
int soilPin = A0;
|
||||||
|
|
||||||
|
float referenceVoltage = 5;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(9600);
|
||||||
|
Serial.println("Analogue Soil Sensor Test");
|
||||||
|
Serial.println("=========================");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
int rawValue = analogRead(soilPin);
|
||||||
|
float parsedValue = (float)rawValue / 1024 * referenceVoltage;
|
||||||
|
|
||||||
|
Serial.print("Raw Value: ");
|
||||||
|
Serial.print(rawValue);
|
||||||
|
Serial.print(" Parsed Value: ");
|
||||||
|
Serial.print(parsedValue);
|
||||||
|
Serial.println("V");
|
||||||
|
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue