ted korczak

Voltmeter with HOLD button

Discussion created by ted korczak on Mar 8, 2018
Latest reply on Mar 8, 2018 by ted korczak

This voltmeter displays 2 readings on LCD, U and H, currently displaying the same value. Haw to dd HOLD button so U will continue doing a measurement and H will show the reading from moment when putton was pressed.


// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3

#include "EmonLib.h" // Include Emon Library
#include <LiquidCrystal.h>
LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);
EnergyMonitor emon1;
float cur, acur[50], sumc;

void setup()
pinMode(PB4, INPUT_PULLUP);// button pin
pinMode(PA7, INPUT); // I2
lcd.begin(16, 2);


emon1.current(PA7, 2500);

void loop()
emon1.calcVI(20, 2000);

float Irms = emon1.Irms;

lcd.setCursor(0, 1);

lcd.setCursor(0, 0);
lcd.print("H="); //Value to be hold
lcd.print(Irms );