Posts

Showing posts from December, 2023

ARDUINO IDE CONNECTIONS FOR IOT ENERGY METER

  Connection Guide: Voltage Sensor: Connect VCC to 5V on Arduino Uno. Connect GND to GND on Arduino Uno. Connect OUT to A0 on Arduino Uno. Current Sensor: Connect VCC to 5V on Arduino Uno. Connect GND to GND on Arduino Uno. Connect OUT to A1 on Arduino Uno. ZMPT101B: Connect VCC to 5V on Arduino Uno. Connect GND to GND on Arduino Uno. Connect OUT to A2 on Arduino Uno. 16x2 LCD with I2C Module: Connect VCC to 5V on Arduino Uno. Connect GND to GND on Arduino Uno. Connect SDA to A4 (SDA) on Arduino Uno. Connect SCL to A5 (SCL) on Arduino Uno. ESP32: Connect TX on ESP32 to RX on Arduino Uno. Connect RX on ESP32 to TX on Arduino Uno. Connect GND on ESP32 to GND on Arduino Uno. Connect 3.3V on ESP32 to 3.3V on Arduino Uno.

SUGAR ARDUINO CODE

  #include <LiquidCrystal.h> LiquidCrystal lcd ( 12 , 11 , 5 , 4 , 3 , 2 ) ; // LCD display pins: rs, enable, d4, d5, d6, d7 const int analogPin = A0; const float A = 8 e- 5 ; const float B = 0.1873 ; const float C = 46.131 ; const int numReadings = 10 ; int readings [numReadings]; int readIndex = 0 ; long total = 0 ; void setup () {   lcd . begin ( 16 , 2 ) ;   Serial . begin ( 9600 ) ;   pinMode ( analogPin, INPUT ) ;   for ( int i = 0 ; i < numReadings; i++ ) {     readings [i] = 0 ;   } } void loop () {   int rawValue = analogRead ( analogPin ) ;   total -= readings [readIndex];   readings [readIndex] = rawValue;   total += rawValue;   readIndex = ( readIndex + 1 ) % numReadings;   float averageVoltage = ( float ) total / numReadings * 5.0 ;   float glucoseConcentration = A * pow ( averageVoltage, 2 ) + B * averageVoltage + C;   lcd . clear () ;   lcd . setCursor ...

ARDUINO UNO CODE TO DISPLAY HELLO WORLD !

  #include <Wire.h> #include <LiquidCrystal_I2C.h> // Set the LCD address (usually 0x27 or 0x3F) // You can find the correct address using an I2C scanner sketch #define I2C_ADDR 0x 27 // Define LCD size (rows and columns) #define LCD_ROWS 2 #define LCD_COLS 16 // Create an instance of the LCD class LiquidCrystal_I2C lcd (I2C_ADDR, LCD_COLS, LCD_ROWS) ; void setup () {   // Initialize the LCD   lcd . init ();   // Turn on the backlight (optional)   lcd . backlight ();   // Print "Hello, World!" on the LCD   lcd . print ( "Hello, World!" ); } void loop () {   // Your main code can go here }