Skip to content

Instantly share code, notes, and snippets.

@ItKindaWorks
Created August 1, 2017 04:18
Show Gist options
  • Save ItKindaWorks/a75969cd7b385c440cf86b5a0a68c86e to your computer and use it in GitHub Desktop.
Save ItKindaWorks/a75969cd7b385c440cf86b5a0a68c86e to your computer and use it in GitHub Desktop.
A simple arduino program for measuring and calibrating AC voltage and current sensors.
// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3
#include "EmonLib.h" // Include Emon Library
#define VOLT_CAL 148.7
#define CURRENT_CAL 62.6
EnergyMonitor emon1; // Create an instance
void setup()
{
Serial.begin(9600);
emon1.voltage(1, VOLT_CAL, 1.7); // Voltage: input pin, calibration, phase_shift
emon1.current(0, CURRENT_CAL); // Current: input pin, calibration.
}
void loop()
{
emon1.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
float currentDraw = emon1.Irms; //extract Irms into Variable
float supplyVoltage = emon1.Vrms; //extract Vrms into Variable
Serial.print("Voltage: ");
Serial.println(supplyVoltage);
Serial.print("Current: ");
Serial.println(currentDraw);
Serial.print("Watts: ");
Serial.println(currentDraw * supplyVoltage);
Serial.println("\n\n");
}
@Talyp2002
Copy link

Where is download?

@Elaya1100445
Copy link

Hello, I want to measure the current with the SCT-013-030 sensor and send the data to the ThingSpeak platform using python and an ESP32... does anyone know where I could find information about that, please? Thank you very much in advance

@IhabSan
Copy link

IhabSan commented Jun 20, 2022

Hello, I want to measure the current with the NB-IoT Current Meter75A sensor and send the data to the ThingsBoard platform using python or another language does anyone know where I could find information about that, please? Thank you very much in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment