#define BLYNK_NO_BUILTIN // Disable built-in analog & digital pin operations #include #include // You should get Auth Token in the Blynk App. char auth[] = "*********************************"; // put you blunk auth token here // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "********"; // put your Wifi name here char pass[] = "********"; // put your Password here //Software Serial on Uno, Nano, Pro mini... #include SoftwareSerial EspSerial(9, 10); // RX, TX //Connect TX of ESP8266 to RX and RX of ESP8266 to TX of Software serial. // Your ESP8266 baud rate: ESP8266 wifi(&EspSerial); #include #include #include #include #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); float current=0; float voltage=0; void setup() { pinMode(A0,INPUT); pinMode(A1,INPUT); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32) display.display(); EspSerial.begin(9600); delay(10); Blynk.begin(auth, wifi, ssid, pass); // Clear the buffer. display.clearDisplay(); display.setTextSize(1); display.setCursor(0, 0); display.setTextColor(WHITE); } void loop() { // taking average for stable readings for(int i=0; i<20;i++) { current=current+analogRead(A1); voltage=voltage+analogRead(A0); delay(2); } current=current/20; current=(current*0.068); // calibration value will change depending upon the gain of Op Amp circuit and resistance of the shunt if(current<0) current=0; voltage=voltage/20; voltage=voltage*2.485; // calibration constant depends upon the voltage divider network display.setCursor(0, 0); display.print("Voltage: "); display.print(voltage); display.println(" V"); display.setCursor(0, 10); display.print("Current: "); display.print(current); display.println(" A"); display.setCursor(0, 20); display.print("Power: "); display.print(voltage*current); display.println(" W"); display.display(); //you have to tell the display to...display delay(500); display.clearDisplay(); Blynk.virtualWrite(V5,voltage); Blynk.virtualWrite(V6,current); Blynk.virtualWrite(V7,voltage*current); }