My hardware is on photo. I prepare hardware from emoncms site for 3 phases. My sketh working good so far about 3 weeks. My controler is pidome and send values to emoncms on mys NAS.
My hardware is on photo. I prepare hardware from emoncms site for 3 phases. My sketh working good so far about 3 weeks. My controler is pidome and send values to emoncms on mys NAS.
This is my last and my final sketch
#include <SPI.h>
#include <MySensor.h>
#include "EmonLib.h" // Include Emon Library
EnergyMonitor emon1; // Create an instance
EnergyMonitor emon2; // Create an instance
EnergyMonitor emon3; // Create an instance
#define CHILD_ID 0
#define CHILD_ID2 1
#define CHILD_ID3 2
MySensor gw;
unsigned long lastSend;
unsigned long SEND_FREQUENCY = 10000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
unsigned long lastSend2;
unsigned long SEND_FREQUENCY2 = 300000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
MyMessage realPowerMsg(CHILD_ID,V_VAR1);
MyMessage apparentPowerMsg(CHILD_ID,V_VAR2);
MyMessage powerFActorMsg(CHILD_ID,V_VAR3);
MyMessage supplyVoltageMsg(CHILD_ID,V_VAR4);
MyMessage IrmsMsg(CHILD_ID,V_VAR5);
MyMessage realPowerMsg2(CHILD_ID2,V_VAR1);
MyMessage apparentPowerMsg2(CHILD_ID2,V_VAR2);
MyMessage powerFActorMsg2(CHILD_ID2,V_VAR3);
MyMessage supplyVoltageMsg2(CHILD_ID2,V_VAR4);
MyMessage IrmsMsg2(CHILD_ID2,V_VAR5);
MyMessage realPowerMsg3(CHILD_ID3,V_VAR1);
MyMessage apparentPowerMsg3(CHILD_ID3,V_VAR2);
MyMessage powerFActorMsg3(CHILD_ID3,V_VAR3);
MyMessage supplyVoltageMsg3(CHILD_ID3,V_VAR4);
MyMessage IrmsMsg3(CHILD_ID3,V_VAR5);
void setup()
{
gw.begin(NULL, 4, false, 0);
Serial.begin(115200); // opens serial port, sets data rate to 9600 bps
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Energy Meter x 3v2", "1.2");
// Register this device as power sensor
gw.present(CHILD_ID, S_POWER);
gw.present(CHILD_ID2, S_POWER);
gw.present(CHILD_ID3, S_POWER);
emon1.voltage(A3, 116.26, 1.7); // Voltage: input pin, calibration, phase_shift
emon1.current(A0, 29.0); // Current: input pin, calibration.
emon2.voltage(A4, 116.66, 1.7); // Voltage: input pin, calibration, phase_shift
emon2.current(A1, 29.0); // Current: input pin, calibration.
emon3.voltage(A5, 115.91, 1.7); // Voltage: input pin, calibration, phase_shift
emon3.current(A2, 29.0); // Current: input pin, calibration.
}
void loop()
{
gw.process();
unsigned long now = millis();
emon1.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
//emon1.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
emon2.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
//emon2.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
emon3.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
//emon3.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
bool sendTime = now - lastSend > SEND_FREQUENCY;
if (sendTime) {
float realPower = emon1.realPower; //extract Real Power into variable
float realPower2 = emon2.realPower; //extract Real Power into variable
float realPower3 = emon3.realPower; //extract Real Power into variable
if(realPower > 0 && realPower < 10000){
gw.send(realPowerMsg.set(realPower,1));
}
if(realPower2 > 0 && realPower2 < 10000){
gw.send(realPowerMsg2.set(realPower2,1));
}
if(realPower3 > 0 && realPower3 < 10000){
gw.send(realPowerMsg3.set(realPower3,1));
}
lastSend = now;
}
bool sendTime2 = now - lastSend2 > SEND_FREQUENCY2;
if(sendTime2){
float apparentPower = emon1.apparentPower; //extract Apparent Power into variable
float powerFactor = emon1.powerFactor; //extract Power Factor into Variable
float supplyVoltage = emon1.Vrms; //extract Vrms into Variable
float Irms = emon1.Irms; //extract Irms into Variable
float apparentPower2 = emon2.apparentPower; //extract Apparent Power into variable
float powerFactor2 = emon2.powerFactor; //extract Power Factor into Variable
float supplyVoltage2 = emon2.Vrms; //extract Vrms into Variable
float Irms2 = emon2.Irms; //extract Irms into Variable
float apparentPower3 = emon3.apparentPower; //extract Apparent Power into variable
float powerFactor3 = emon3.powerFactor; //extract Power Factor into Variable
float supplyVoltage3 = emon3.Vrms; //extract Vrms into Variable
float Irms3 = emon3.Irms; //extract Irms into Variable
if(apparentPower > 0 && apparentPower < 10000){
gw.send(apparentPowerMsg.set(apparentPower,1));
}
if(powerFactor > 0 && powerFactor < 10000){
gw.send(powerFActorMsg.set(powerFactor,1));
}
if(supplyVoltage > 0 && supplyVoltage < 1000){
gw.send(supplyVoltageMsg.set(supplyVoltage,1));
}
if(Irms > 0 && Irms < 1000){
gw.send(IrmsMsg.set(Irms,1));
}
if(apparentPower2 > 0 && apparentPower2 < 10000){
gw.send(apparentPowerMsg2.set(apparentPower2,1));
}
if(powerFactor2 > 0 && powerFactor2 < 10000){
gw.send(powerFActorMsg2.set(powerFactor2,1));
}
if(supplyVoltage2 > 0 && supplyVoltage2 < 1000){
gw.send(supplyVoltageMsg2.set(supplyVoltage2,1));
}
if(Irms2 > 0 && Irms2 < 1000){
gw.send(IrmsMsg2.set(Irms2,1));
}
if(apparentPower3 > 0 && apparentPower3 < 10000){
gw.send(apparentPowerMsg3.set(apparentPower3,1));
}
if(powerFactor3 > 0 && powerFactor3 < 10000){
gw.send(powerFActorMsg3.set(powerFactor3,1));
}
if(supplyVoltage3 > 0 && supplyVoltage3 < 1000){
gw.send(supplyVoltageMsg3.set(supplyVoltage3,1));
}
if(Irms3 > 0 && Irms3 < 1000){
gw.send(IrmsMsg3.set(Irms3,1));
}
lastSend2 = now;
}
}
You can use one voltage and use few Amps but only on one phase . If you want to measure Amps on other phases you should add another voltage meter on each phases.
You can't to use transformer for power supply because on transformer for measuring is AC voltage and power supply for arduino is DC voltage
This is my last and my final sketch
#include <SPI.h>
#include <MySensor.h>
#include "EmonLib.h" // Include Emon Library
EnergyMonitor emon1; // Create an instance
EnergyMonitor emon2; // Create an instance
EnergyMonitor emon3; // Create an instance
#define CHILD_ID 0
#define CHILD_ID2 1
#define CHILD_ID3 2
MySensor gw;
unsigned long lastSend;
unsigned long SEND_FREQUENCY = 10000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
unsigned long lastSend2;
unsigned long SEND_FREQUENCY2 = 300000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
MyMessage realPowerMsg(CHILD_ID,V_VAR1);
MyMessage apparentPowerMsg(CHILD_ID,V_VAR2);
MyMessage powerFActorMsg(CHILD_ID,V_VAR3);
MyMessage supplyVoltageMsg(CHILD_ID,V_VAR4);
MyMessage IrmsMsg(CHILD_ID,V_VAR5);
MyMessage realPowerMsg2(CHILD_ID2,V_VAR1);
MyMessage apparentPowerMsg2(CHILD_ID2,V_VAR2);
MyMessage powerFActorMsg2(CHILD_ID2,V_VAR3);
MyMessage supplyVoltageMsg2(CHILD_ID2,V_VAR4);
MyMessage IrmsMsg2(CHILD_ID2,V_VAR5);
MyMessage realPowerMsg3(CHILD_ID3,V_VAR1);
MyMessage apparentPowerMsg3(CHILD_ID3,V_VAR2);
MyMessage powerFActorMsg3(CHILD_ID3,V_VAR3);
MyMessage supplyVoltageMsg3(CHILD_ID3,V_VAR4);
MyMessage IrmsMsg3(CHILD_ID3,V_VAR5);
void setup()
{
gw.begin(NULL, 4, false, 0);
Serial.begin(115200); // opens serial port, sets data rate to 9600 bps
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Energy Meter x 3v2", "1.2");
// Register this device as power sensor
gw.present(CHILD_ID, S_POWER);
gw.present(CHILD_ID2, S_POWER);
gw.present(CHILD_ID3, S_POWER);
emon1.voltage(A3, 116.26, 1.7); // Voltage: input pin, calibration, phase_shift
emon1.current(A0, 29.0); // Current: input pin, calibration.
emon2.voltage(A4, 116.66, 1.7); // Voltage: input pin, calibration, phase_shift
emon2.current(A1, 29.0); // Current: input pin, calibration.
emon3.voltage(A5, 115.91, 1.7); // Voltage: input pin, calibration, phase_shift
emon3.current(A2, 29.0); // Current: input pin, calibration.
}
void loop()
{
gw.process();
unsigned long now = millis();
emon1.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
//emon1.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
emon2.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
//emon2.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
emon3.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
//emon3.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
bool sendTime = now - lastSend > SEND_FREQUENCY;
if (sendTime) {
float realPower = emon1.realPower; //extract Real Power into variable
float realPower2 = emon2.realPower; //extract Real Power into variable
float realPower3 = emon3.realPower; //extract Real Power into variable
if(realPower > 0 && realPower < 10000){
gw.send(realPowerMsg.set(realPower,1));
}
if(realPower2 > 0 && realPower2 < 10000){
gw.send(realPowerMsg2.set(realPower2,1));
}
if(realPower3 > 0 && realPower3 < 10000){
gw.send(realPowerMsg3.set(realPower3,1));
}
lastSend = now;
}
bool sendTime2 = now - lastSend2 > SEND_FREQUENCY2;
if(sendTime2){
float apparentPower = emon1.apparentPower; //extract Apparent Power into variable
float powerFactor = emon1.powerFactor; //extract Power Factor into Variable
float supplyVoltage = emon1.Vrms; //extract Vrms into Variable
float Irms = emon1.Irms; //extract Irms into Variable
float apparentPower2 = emon2.apparentPower; //extract Apparent Power into variable
float powerFactor2 = emon2.powerFactor; //extract Power Factor into Variable
float supplyVoltage2 = emon2.Vrms; //extract Vrms into Variable
float Irms2 = emon2.Irms; //extract Irms into Variable
float apparentPower3 = emon3.apparentPower; //extract Apparent Power into variable
float powerFactor3 = emon3.powerFactor; //extract Power Factor into Variable
float supplyVoltage3 = emon3.Vrms; //extract Vrms into Variable
float Irms3 = emon3.Irms; //extract Irms into Variable
if(apparentPower > 0 && apparentPower < 10000){
gw.send(apparentPowerMsg.set(apparentPower,1));
}
if(powerFactor > 0 && powerFactor < 10000){
gw.send(powerFActorMsg.set(powerFactor,1));
}
if(supplyVoltage > 0 && supplyVoltage < 1000){
gw.send(supplyVoltageMsg.set(supplyVoltage,1));
}
if(Irms > 0 && Irms < 1000){
gw.send(IrmsMsg.set(Irms,1));
}
if(apparentPower2 > 0 && apparentPower2 < 10000){
gw.send(apparentPowerMsg2.set(apparentPower2,1));
}
if(powerFactor2 > 0 && powerFactor2 < 10000){
gw.send(powerFActorMsg2.set(powerFactor2,1));
}
if(supplyVoltage2 > 0 && supplyVoltage2 < 1000){
gw.send(supplyVoltageMsg2.set(supplyVoltage2,1));
}
if(Irms2 > 0 && Irms2 < 1000){
gw.send(IrmsMsg2.set(Irms2,1));
}
if(apparentPower3 > 0 && apparentPower3 < 10000){
gw.send(apparentPowerMsg3.set(apparentPower3,1));
}
if(powerFactor3 > 0 && powerFactor3 < 10000){
gw.send(powerFActorMsg3.set(powerFactor3,1));
}
if(supplyVoltage3 > 0 && supplyVoltage3 < 1000){
gw.send(supplyVoltageMsg3.set(supplyVoltage3,1));
}
if(Irms3 > 0 && Irms3 < 1000){
gw.send(IrmsMsg3.set(Irms3,1));
}
lastSend2 = now;
}
}
@GambitukI am very happy with performance. I'm logs power every 10s and voltage every 60s. It is sufficient. I built like on this site http://openenergymonitor.org/emon/buildingblocks/measuring-voltage-with-an-acac-power-adapter
You can use transformer what you like but you must add voltage divider to have voltage max 2,5V on input in arduino if you use arduino 5V
PS Poland/Warsaw
In Emonlib you have example to measure watt etc. without measure voltage.
https://github.com/openenergymonitor/EmonLib
@maglo18 said:
A3 is from transformer and A0 is from CT sensor
Voltage input http://openenergymonitor.org/emon/buildingblocks/measuring-voltage-with-an-acac-power-adapter
CT input http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor-measuring-current-only
I have 3 x voltage input and 3 x ct input.
I use transformer to measure voltage on each from three phases
@chatainsim said:
SCT-013-030
I create custom energy monitor and use mysesnors to send data to server.
http://forum.mysensors.org/topic/703/custom-power-meter/4
My final sketch
#include <SPI.h>
#include <MySensor.h>
#include "EmonLib.h" // Include Emon Library
EnergyMonitor emon1; // Create an instance
EnergyMonitor emon2; // Create an instance
EnergyMonitor emon3; // Create an instance
#define CHILD_ID 0
#define CHILD_ID2 1
#define CHILD_ID3 2
MySensor gw;
unsigned long lastSend;
unsigned long SEND_FREQUENCY = 10000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
unsigned long lastSend2;
unsigned long SEND_FREQUENCY2 = 300000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
MyMessage realPowerMsg(CHILD_ID,V_VAR1);
MyMessage apparentPowerMsg(CHILD_ID,V_VAR2);
MyMessage powerFActorMsg(CHILD_ID,V_VAR3);
MyMessage supplyVoltageMsg(CHILD_ID,V_VAR4);
MyMessage IrmsMsg(CHILD_ID,V_VAR5);
MyMessage realPowerMsg2(CHILD_ID2,V_VAR1);
MyMessage apparentPowerMsg2(CHILD_ID2,V_VAR2);
MyMessage powerFActorMsg2(CHILD_ID2,V_VAR3);
MyMessage supplyVoltageMsg2(CHILD_ID2,V_VAR4);
MyMessage IrmsMsg2(CHILD_ID2,V_VAR5);
MyMessage realPowerMsg3(CHILD_ID3,V_VAR1);
MyMessage apparentPowerMsg3(CHILD_ID3,V_VAR2);
MyMessage powerFActorMsg3(CHILD_ID3,V_VAR3);
MyMessage supplyVoltageMsg3(CHILD_ID3,V_VAR4);
MyMessage IrmsMsg3(CHILD_ID3,V_VAR5);
void setup()
{
gw.begin(NULL, 4, false, 0);
Serial.begin(115200); // opens serial port, sets data rate to 9600 bps
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Energy Meter x 3v2", "1.2");
// Register this device as power sensor
gw.present(CHILD_ID, S_POWER);
gw.present(CHILD_ID2, S_POWER);
gw.present(CHILD_ID3, S_POWER);
emon1.voltage(A3, 116.26, 1.7); // Voltage: input pin, calibration, phase_shift
emon1.current(A0, 29.0); // Current: input pin, calibration.
emon2.voltage(A4, 116.66, 1.7); // Voltage: input pin, calibration, phase_shift
emon2.current(A1, 29.0); // Current: input pin, calibration.
emon3.voltage(A5, 115.91, 1.7); // Voltage: input pin, calibration, phase_shift
emon3.current(A2, 29.0); // Current: input pin, calibration.
}
void loop()
{
gw.process();
unsigned long now = millis();
emon1.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
//emon1.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
emon2.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
//emon2.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
emon3.calcVI(20,2000); // Calculate all. No.of half wavelengths (crossings), time-out
//emon3.serialprint(); // Print out all variables (realpower, apparent power, Vrms, Irms, power factor)
bool sendTime = now - lastSend > SEND_FREQUENCY;
if (sendTime) {
float realPower = emon1.realPower; //extract Real Power into variable
float realPower2 = emon2.realPower; //extract Real Power into variable
float realPower3 = emon3.realPower; //extract Real Power into variable
if(realPower > 0 && realPower < 10000){
gw.send(realPowerMsg.set(realPower,1));
}
if(realPower2 > 0 && realPower2 < 10000){
gw.send(realPowerMsg2.set(realPower2,1));
}
if(realPower3 > 0 && realPower3 < 10000){
gw.send(realPowerMsg3.set(realPower3,1));
}
lastSend = now;
}
bool sendTime2 = now - lastSend2 > SEND_FREQUENCY2;
if(sendTime2){
float apparentPower = emon1.apparentPower; //extract Apparent Power into variable
float powerFactor = emon1.powerFactor; //extract Power Factor into Variable
float supplyVoltage = emon1.Vrms; //extract Vrms into Variable
float Irms = emon1.Irms; //extract Irms into Variable
float apparentPower2 = emon2.apparentPower; //extract Apparent Power into variable
float powerFactor2 = emon2.powerFactor; //extract Power Factor into Variable
float supplyVoltage2 = emon2.Vrms; //extract Vrms into Variable
float Irms2 = emon2.Irms; //extract Irms into Variable
float apparentPower3 = emon3.apparentPower; //extract Apparent Power into variable
float powerFactor3 = emon3.powerFactor; //extract Power Factor into Variable
float supplyVoltage3 = emon3.Vrms; //extract Vrms into Variable
float Irms3 = emon3.Irms; //extract Irms into Variable
if(apparentPower > 0 && apparentPower < 10000){
gw.send(apparentPowerMsg.set(apparentPower,1));
}
if(powerFactor > 0 && powerFactor < 10000){
gw.send(powerFActorMsg.set(powerFactor,1));
}
if(supplyVoltage > 0 && supplyVoltage < 1000){
gw.send(supplyVoltageMsg.set(supplyVoltage,1));
}
if(Irms > 0 && Irms < 1000){
gw.send(IrmsMsg.set(Irms,1));
}
if(apparentPower2 > 0 && apparentPower2 < 10000){
gw.send(apparentPowerMsg2.set(apparentPower2,1));
}
if(powerFactor2 > 0 && powerFactor2 < 10000){
gw.send(powerFActorMsg2.set(powerFactor2,1));
}
if(supplyVoltage2 > 0 && supplyVoltage2 < 1000){
gw.send(supplyVoltageMsg2.set(supplyVoltage2,1));
}
if(Irms2 > 0 && Irms2 < 1000){
gw.send(IrmsMsg2.set(Irms2,1));
}
if(apparentPower3 > 0 && apparentPower3 < 10000){
gw.send(apparentPowerMsg3.set(apparentPower3,1));
}
if(powerFactor3 > 0 && powerFactor3 < 10000){
gw.send(powerFActorMsg3.set(powerFactor3,1));
}
if(supplyVoltage3 > 0 && supplyVoltage3 < 1000){
gw.send(supplyVoltageMsg3.set(supplyVoltage3,1));
}
if(Irms3 > 0 && Irms3 < 1000){
gw.send(IrmsMsg3.set(Irms3,1));
}
lastSend2 = now;
}
}
Yes and yes. first lever repeater should have id 0. All my nodes have static repeater or gateway id. Now i don't have loops after restart gateway.
I have the same situation. My solution is to add manually repeater id in each node.