#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <WiFi.h>
#include <HTTPClient.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Replace with your network credentials
const char* ssid = "root";
const char* password = "radenku.com";
void setup() {
// Initialize the LCD
lcd.init(); // Initialize the LCD
lcd.backlight(); // Turn on the backlight
// Print a message to the LCD
lcd.setCursor(0, 0);
lcd.print("Starting...");
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
lcd.setCursor(0, 0);
lcd.print("Connecting...");
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Connected!");
}
void loop() {
// Example: Display system info from OpenWRT
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin("http://192.168.1.1/cgi-bin/luci/admin/status/overview"); // Replace with your OpenWRT URL
int httpCode = http.GET();
if (httpCode > 0) {
String payload = http.getString();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Sys Info:");
lcd.setCursor(0, 1);
lcd.print(payload.substring(0, 16)); // Display first 16 chars of the response
} else {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("HTTP Error:");
lcd.setCursor(0, 1);
lcd.print(httpCode);
}
http.end();
} else {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("WiFi Disconnected");
}
delay(10000); // Update every 10 seconds
}