Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based NPK Soil Sensor with LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based NPK Soil Sensor with LCD Display

Circuit Documentation

Summary

This circuit is designed to interface an Arduino UNO with an LCD display and an NPK soil sensor, with a potentiometer used to adjust the contrast of the LCD. The Arduino UNO reads the analog value from the NPK soil sensor and displays the reading on the LCD. The circuit is powered by the Arduino's 5V output, which also powers the LCD and the potentiometer. Ground connections are shared among all components.

Component List

Arduino UNO

LCD Display (16 pin)

NPK Soil Sensor

Potentiometer

Wiring Details

Arduino UNO

LCD Display (16 pin)

NPK Soil Sensor

Potentiometer

Documented Code

#include <LiquidCrystal.h>

// Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // Set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("NPK Sensor");
  // Initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

void loop() {
  // Read the NPK sensor value
  int sensorValue = analogRead(A0);
  
  // Print the sensor value to the serial monitor
  Serial.print("NPK Sensor Value: ");
  Serial.println(sensorValue);
  
  // Display the sensor value on the LCD
  lcd.setCursor(0, 1); // Move to the second line
  lcd.print("NPK: ");
  lcd.print(sensorValue);
  lcd.print("    "); // Clear any previous value
  
  delay(1000); // Wait for a second before the next loop
}

This code is designed to run on the Arduino UNO. It initializes the LCD display and sets up serial communication. In the main loop, it reads the analog value from the NPK sensor and displays it on both the serial monitor and the LCD. The LCD displays the text "NPK Sensor" on the first line and the sensor value prefixed with "NPK: " on the second line. The sensor value is updated every second.