JACK
Published

ESP32 Analog Read

In this Article, we learn about how to make Wireless ESP32 Analog Sensor Monitoring System with LCD Display and Web Interface.

ExpertFull instructions provided2 hours352
ESP32 Analog Read

Things used in this project

Hardware components

ESP32
Espressif ESP32
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
Breadboard (generic)
Breadboard (generic)
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

screenshot_(218)_2OEFVNNWoI.png

Code

Untitled file

C/C++
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <WiFi.h>
#include <WebServer.h>

const char* ssid = "Microsolutions";
const char* password = "@1yahoo.com";

WebServer server(80);

const int analogPin = 34;
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD I2C address

void setup() {
  Serial.begin(115200);
  lcd.init(); // Initialize the LCD
  lcd.backlight();

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");
  Serial.print("IP Address: ");
  Serial.println(WiFi.localIP());

  server.on("/", HTTP_GET, []() {
    server.send(200, "text/html", getHTML());
  });
  server.begin();
}

void loop() {
  server.handleClient();
  displayAnalogValue();
}

String getHTML() {
  int analogValue = analogRead(analogPin);
  String html = "<html><head></head><body>";
  html += "<h1>ESP32 Analog Sensor</h1>";
  html += "<p>Analog Value: " + String(analogValue) + "</p>";
  html += "</body></html>";
  return html;
}

void displayAnalogValue() {
  int analogValue = analogRead(analogPin);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Analog Value:");
  lcd.setCursor(0, 1);
  lcd.print(analogValue);
  delay(1000); // Update the display every second
}

Credits

JACK
21 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.