Arduino Code
/*
* Project name:
Analog Soil Moisture Sensor
* Copyright
(c) Researchdesignlab.com
* Description:
* Test configuration:
MCU: ATMEGA328
Dev.Board: Arduino uno
Oscillator: 16 MHz
Software: Arduino
*/
/*
Analog input, LCD output
Reads an analog input pin, prints the results to the LCD dislay(16x2)
The circuit:
* A-out of Analog/digital Soil moisture sensor is connected to analog pin A5.
+5V and GND of the Soil moisture is connected to the respective pins of Arduino.
* LCD Shield/LCD display is connected according to the connections mentioned.
created 28 Nov. 2014
modified 28 Nov. 2014
by DD.
This example code is in the public domain in Researchdesignlab.com.
*/
/*
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A5; // Analog input pin that the Sensor is attached to
int sensorValue = 0; // value read from the Soil Moisture
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
delay(100);
}
void loop() {
lcd.clear();
lcd.print("Soil Moisture:");// print the results to the LCD Display:
sensorValue = analogRead(analogInPin);// read the analog in value:
lcd.setCursor(0, 1);
lcd.print(sensorValue);
// wait 300 milliseconds before the next loop for the
//analog-to-digital converter to settle after the last reading:
delay(300);
}