13. Input Devices¶
This week I tested an Soil humidity sensor using the board I had previously made.
The program¶
I decided I would measure the signal comming from a Soil Humidity sensor, the program itself is really simple, but I had some problem at first while trying to decide which pin was the sensor connected to. I was addressing PA2
as shown in the picture below, but the correct name was simply A2
.
// Max GH 21.04.2022
int measurement;
const int pin = A2;
void setup() {
Serial.begin(9600);
pinMode(pin, INPUT);
}
void loop() {
measurement = analogRead(pin);
Serial.print("Sensor Value: ");
Serial.println(measurement);
delay(500);
}
The setup¶
The sensor was connected to the board, and the board to the UPDI programmer, which carried out the Serial communication.
At first I thought the sensor was wrong, but the problem was much more simple: The sensor measures conductivity, but at the moment, it was just floating in thin air.
Then I touched the two ends of the sensor with my fingers, but apparently the human body is not as conductiv as I thought. Or at least the skin.
Then I dipped the sensor in water, and the results skyrocketed.