MAX471 voltage meter on D1 mini

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()
  Blynk.begin(auth, ssid, pass);
  while (Blynk.connect() == false) {}
  terminal.println(F(" Blynk v"BLYNK_VERSION ":MAX471 Power Meter"));
  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); 
  Serial.print("Volts: "); 
  Serial.print(voltage, 3);

void loop()

I used this today as a part of my school project so thanks to both of you !
Just a little side note for future users.
float voltage = vt_read * (MAX VOLTAGE PER CELL / 1024.0) * AMOUNT OF CELLS;

you need to adapt the formula according to your battery.
Cheers and thanks again :slight_smile:

Glad if it was helpful :smiley: Thanks for side note.

1 Like

Okay my side note might not be correct. I suggest to everyone using this to just come up with a formula that works for you.