Simple voltage meter.
// MAX471 Power Meter by speed57 and Costas 02.11.2017
/*
Value widget = V1
Terminal Widget = V5
*/
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#define VT_PIN A0
int vt_read = analogRead(VT_PIN);
char auth[] = "xxxxxxx";
char ssid[] = "xxxxxxx";
char pass[] = "xxxxxxx";
SimpleTimer timer;
WidgetTerminal terminal(V5);
void setup()
{
Serial.begin(9600);
WiFi.mode(WIFI_STA);
Blynk.begin(auth, ssid, pass);
while (Blynk.connect() == false) {}
terminal.println(F(" Blynk v"BLYNK_VERSION ":MAX471 Power Meter"));
terminal.flush();
timer.setInterval(1000L, PowerMeter);
}
void PowerMeter()
{
int vt_read = analogRead(VT_PIN);
float voltage = vt_read * (3.2 / 1024.0) * 5.0;
Blynk.virtualWrite(V1, voltage);
terminal.println("Volts: ");
terminal.println(voltage, 3);
terminal.flush();
Serial.print("Volts: ");
Serial.print(voltage, 3);
}
void loop()
{
Blynk.run();
timer.run();
}