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
Posts made by maglo18
-
RE: Custom power meter
-
RE: Custom power meter
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; } }
-
RE: Custom power meter
@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 5VPS Poland/Warsaw
-
RE: SCT-013-030 current monitor sensor
In Emonlib you have example to measure watt etc. without measure voltage.
https://github.com/openenergymonitor/EmonLib -
RE: SCT-013-030 current monitor sensor
@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-onlyI have 3 x voltage input and 3 x ct input.
-
RE: Custom power meter
I use transformer to measure voltage on each from three phases
-
RE: SCT-013-030 current monitor sensor
@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; } }
-
RE: Looped Repeater
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.
-
RE: Looped Repeater
I have the same situation. My solution is to add manually repeater id in each node.
-
RE: Array Relay Button Actuator
In yours sketch state button should high next low then relay change state. I want to have possibility after button HIGH relay state change button LOW state relay change again
-
RE: Array Relay Button Actuator
Could someone tell what i should to modify to use toggle button not flash button?
-
RE: Wrong rpeater Id
Maybe but my node doesn't get any information from gateway
-
Wrong rpeater Id
Could someone explain me why on node i have repeater id "8" but in getaway repeater id is "2". I have 9 nodes and it is first that does not work
Logs from Node:
send: 14-14-8-0 s=255,c=0,t=18,pt=0,l=5,st=fail:1.4.1 send: 14-14-8-0 s=255,c=3,t=6,pt=1,l=1,st=fail:8 send: 14-14-8-0 s=255,c=3,t=11,pt=0,l=9,st=ok:Relay x8 send: 14-14-8-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0 send: 14-14-8-0 s=1,c=0,t=3,pt=0,l=5,st=ok:1.4.1 send: 14-14-8-0 s=2,c=0,t=3,pt=0,l=5,st=fail:1.4.1 Logs from gataway: 01-04-2015 00:04:46: 0;0;3;0;9;read: 4-4-0 s=0,c=1,t=24,pt=7,l=5:83.0 01-04-2015 00:04:46: 0;0;3;0;9;read: 14-2-0 s=7,c=0,t=3,pt=0,l=5:1.4.1 01-04-2015 00:04:46: 0;0;3;0;9;read: 14-2-0 s=5,c=0,t=3,pt=0,l=5:1.4.1 01-04-2015 00:04:46: 0;0;3;0;9;read: 14-2-0 s=3,c=0,t=3,pt=0,l=5:1.4.1 01-04-2015 00:04:46: 0;0;3;0;9;read: 14-2-0 s=1,c=0,t=3,pt=0,l=5:1.4.1 01-04-2015 00:04:46: 0;0;3;0;9;read: 14-2-0 s=255,c=3,t=12,pt=0,l=3:1.0 01-04-2015 00:04:46: 0;0;3;0;9;read: 14-2-0 s=255,c=3,t=11,pt=0,l=9:Relay x8 01-04-2015 00:04:30: 0;0;3;0;9;read: 14-2-0 s=255,c=0,t=18,pt=0,l=5:1.4.1
-
RE: Custom power meter
I use Pidome server and by automation rule send values to emoncms..
-
RE: Custom power meter
@ServiceXp In the box are 3 transformer, one for each phase to measure the voltage
-
RE: Custom power meter
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.
-
Custom power meter
I created a power meter based on emoncms. My code does not work quite correctly. When I run not everything is fine, but after reboot gets below the value of information and does not update.
10-12-2014 12:02:57: 0;0;3;0;9;send: 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,st=fail:0
10-12-2014 12:02:56: 0;0;3;0;9;read: 6-6-255 s=255,c=3,t=7,pt=0,l=0:
10-12-2014 12:02:36: 0;0;3;0;9;send: 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,st=fail:0
10-12-2014 12:02:36: 0;0;3;0;9;read: 6-6-255 s=255,c=3,t=7,pt=0,l=0:
10-12-2014 12:02:16: 0;0;3;0;9;send: 0-0-6-6 s=255,c=3,t=8,pt=1,l=1,st=fail:0My sketch:. If i can improve code help me please
// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3 ***/ #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 = 20000; // 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_[link text](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(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Energy Meter x 3", "2.0"); // 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.1); // Current: input pin, calibration. emon2.voltage(A4, 116.76, 1.7); // Voltage: input pin, calibration, phase_shift emon2.current(A1, 29.1); // Current: input pin, calibration. emon3.voltage(A5, 116.46, 1.7); // Voltage: input pin, calibration, phase_shift emon3.current(A2, 29.1); // 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 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 realPower2 = emon2.realPower; //extract Real Power 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 realPower3 = emon3.realPower; //extract Real Power 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 gw.send(realPowerMsg.set(realPower,1)); gw.send(apparentPowerMsg.set(apparentPower,1)); gw.send(powerFActorMsg.set(powerFactor,1)); gw.send(supplyVoltageMsg.set(supplyVoltage,1)); gw.send(IrmsMsg.set(Irms,1)); gw.send(realPowerMsg2.set(realPower2,1)); gw.send(apparentPowerMsg2.set(apparentPower2,1)); gw.send(powerFActorMsg2.set(powerFactor2,1)); gw.send(supplyVoltageMsg2.set(supplyVoltage2,1)); gw.send(IrmsMsg2.set(Irms2,1)); gw.send(realPowerMsg3.set(realPower3,1)); gw.send(apparentPowerMsg3.set(apparentPower3,1)); gw.send(powerFActorMsg3.set(powerFactor3,1)); gw.send(supplyVoltageMsg3.set(supplyVoltage3,1)); gw.send(IrmsMsg3.set(Irms3,1)); lastSend = now; } }
-
RE: Sensors & Pi Dome Controller - Sensor ID assignment on AUTO mode not completing assignment of ID to sensor
Try to turn off node, restart pidome server. After restart go to drivers management/ drivers.. Turn on node and refresh drivers page. If you see new request about id press apply. You have only few second after power on node to apply new address.
-
RE: RelayWithButtonActuator
I prepare sketch with 2 x button and 2 x relays and 8 x dallas. Could some one look at if it right, because i have problem remote relays after restart node. I don't know it is problem witch sketch or server software.
Log from gataway:
12-10-2014 18:57:55: 0;0;3;0;9;send: 0-0-2-2 s=11,c=1,t=2,pt=0,l=1,st=ok:0
12-10-2014 18:57:55: 0;0;3;0;9;send: 0-0-2-2 s=11,c=1,t=2,pt=0,l=1,st=ok:1
12-10-2014 18:57:54: 0;0;3;0;9;send: 0-0-2-2 s=12,c=1,t=2,pt=0,l=1,st=ok:0
12-10-2014 18:57:54: 0;0;3;0;9;send: 0-0-2-2 s=12,c=1,t=2,pt=0,l=1,st=ok:1
12-10-2014 18:57:53: 0;0;3;0;9;send: 0-0-2-2 s=11,c=1,t=2,pt=0,l=1,st=ok:0
12-10-2014 18:57:52: 0;0;3;0;9;send: 0-0-2-2 s=11,c=1,t=2,pt=0,l=1,st=ok:1
12-10-2014 18:54:39: 0;0;3;0;9;read: 2-2-0 s=0,c=1,t=0,pt=7,l=5:22.6
12-10-2014 18:54:26: 0;0;3;0;9;send: 0-0-203-2 s=11,c=1,t=2,pt=0,l=1,st=fail:0
12-10-2014 18:54:26: 0;0;3;0;9;send: 0-0-203-2 s=12,c=1,t=2,pt=0,l=1,st=fail:0
12-10-2014 18:54:26: 0;0;3;0;9;send: 0-0-203-2 s=12,c=1,t=2,pt=0,l=1,st=fail:1
12-10-2014 18:54:25: 0;0;3;0;9;send: 0-0-203-2 s=11,c=1,t=2,pt=0,l=1,st=fail:1Code:
#include <MySensor.h> #include <SPI.h> #include <Bounce2.h> #include <DallasTemperature.h> #include <OneWire.h> #define RELAY_PIN_2 8 #define RELAY_PIN 7 // Arduino Digital I/O pin number for relay #define BUTTON_PIN_2 4 #define BUTTON_PIN 3 // Arduino Digital I/O pin number for button #define CHILD_ID_2 12 #define CHILD_ID 11 // Id of the sensor child #define RELAY_ON 1 #define RELAY_OFF 0 Bounce debouncer = Bounce(); int oldValue=0; bool state; Bounce debouncer2 = Bounce(); int oldValue2=0; bool state2; //temp #define ONE_WIRE_BUS 5 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 8 unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) unsigned long SEND_FREQUENCY = 30000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway. unsigned long lastSend; unsigned long sendTime; OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); MySensor gw; //temp float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=0; boolean receivedConfig = false; boolean metric = true; MyMessage msg(CHILD_ID,V_LIGHT); MyMessage msg2(CHILD_ID_2,V_LIGHT); MyMessage msg3(0,V_TEMP); void setup() { // Startup OneWire sensors.begin(); gw.begin(incomingMessage, AUTO, true); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Double Relay & Button, Temp", "0.1"); // Fetch the number of attached temperature sensors numSensors = sensors.getDeviceCount(); // Present all sensors to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { gw.present(i, S_TEMP); } // Setup the button pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); // Setup the button pinMode(BUTTON_PIN_2,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN_2,HIGH); // After setting up the button, setup debouncer debouncer.attach(BUTTON_PIN); debouncer.interval(5); debouncer2.attach(BUTTON_PIN_2); debouncer2.interval(5); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID, S_LIGHT); gw.present(CHILD_ID_2, S_LIGHT); // Make sure relays are off when starting up digitalWrite(RELAY_PIN, RELAY_OFF); // Then set relay pins in output mode pinMode(RELAY_PIN, OUTPUT); digitalWrite(RELAY_PIN_2, RELAY_OFF); // Then set relay pins in output mode pinMode(RELAY_PIN_2, OUTPUT); // Set relay to last known state (using eeprom storage) state = gw.loadState(CHILD_ID); digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); state2 = gw.loadState(CHILD_ID_2); digitalWrite(RELAY_PIN_2, state2?RELAY_ON:RELAY_OFF); } /* * Example on how to asynchronously check for new messages from gw */ void loop() { gw.process(); debouncer.update(); debouncer2.update(); // Get the update value int value = debouncer.read(); int value2 = debouncer2.read(); if (value != oldValue && value==0) { gw.send(msg.set(state?false:true), true); // Send new state and request ack back } oldValue = value; if (value2 != oldValue2 && value2==0) { gw.send(msg2.set(state2?false:true), true); // Send new state and request ack back } oldValue2 = value2; unsigned long now = millis(); // Only send values at a maximum frequency or woken up from sleep if ((now - lastSend) > SEND_FREQUENCY) { Serial.print("dziala wysylanie temp"); // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); // Read temperatures and send them to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { // Fetch and round temperature to one decimal float temperature = static_cast<float>(static_cast<int>((gw.getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.; // Only send data if temperature has changed and no error if (lastTemperature[i] != temperature && temperature != -127.00) { // Send in the new temperature gw.send(msg3.setSensor(i).set(temperature,1)); lastTemperature[i]=temperature; } } lastSend=now; } } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. /* if (message.isAck()) { Serial.println("This is an ack from gateway"); } */ if (message.type == V_LIGHT && message.sensor == 11) { // Change relay state state = message.getBool(); digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); // Store state in eeprom gw.saveState(CHILD_ID, state); } else if(message.type == V_LIGHT && message.sensor == 12){ state2 = message.getBool(); digitalWrite(RELAY_PIN_2, state2?RELAY_ON:RELAY_OFF); // Store state in eeprom gw.saveState(CHILD_ID_2, state2); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } }
-
RelayWithButtonActuator
I try to use Relay With Button Actuator 1.4 but I have problem. When i press button everything working well. Problem is when I restart node and want to change status form gateway, it doesn't work then. When i press button only once then i can remote from getaway.
My code:#include <MySensor.h> #include <SPI.h> #include <Bounce2.h> #define RELAY_PIN_2 8 #define RELAY_PIN 7 // Arduino Digital I/O pin number for relay #define BUTTON_PIN_2 4 #define BUTTON_PIN 3 // Arduino Digital I/O pin number for button #define CHILD_ID_2 2 #define CHILD_ID 1 // Id of the sensor child #define RELAY_ON 1 #define RELAY_OFF 0 Bounce debouncer = Bounce(); int oldValue=0; bool state; Bounce debouncer2 = Bounce(); int oldValue2=0; bool state2; MySensor gw; MyMessage msg(CHILD_ID,V_LIGHT); MyMessage msg2(CHILD_ID_2,V_LIGHT); void setup() { gw.begin(incomingMessage, AUTO, true); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Double Relay & Button", "0.1"); // Setup the button pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); // Setup the button pinMode(BUTTON_PIN_2,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN_2,HIGH); // After setting up the button, setup debouncer debouncer.attach(BUTTON_PIN); debouncer.interval(5); debouncer2.attach(BUTTON_PIN_2); debouncer2.interval(5); // Register all sensors to gw (they will be created as child devices) gw.present(CHILD_ID, S_LIGHT); gw.present(CHILD_ID_2, S_LIGHT); // Make sure relays are off when starting up digitalWrite(RELAY_PIN, RELAY_OFF); // Then set relay pins in output mode pinMode(RELAY_PIN, OUTPUT); digitalWrite(RELAY_PIN_2, RELAY_OFF); // Then set relay pins in output mode pinMode(RELAY_PIN_2, OUTPUT); // Set relay to last known state (using eeprom storage) state = gw.loadState(CHILD_ID); digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); state2 = gw.loadState(CHILD_ID_2); digitalWrite(RELAY_PIN_2, state2?RELAY_ON:RELAY_OFF); } /* * Example on how to asynchronously check for new messages from gw */ void loop() { gw.process(); debouncer.update(); debouncer2.update(); // Get the update value int value = debouncer.read(); int value2 = debouncer2.read(); if (value != oldValue && value==0) { gw.send(msg.set(state?false:true), true); // Send new state and request ack back } oldValue = value; if (value2 != oldValue2 && value2==0) { gw.send(msg2.set(state2?false:true), true); // Send new state and request ack back } oldValue2 = value2; } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. /* if (message.isAck()) { Serial.println("This is an ack from gateway"); } */ if (message.type == V_LIGHT && message.sensor == 1 && strlen(msg.getString()) != 0) { // Change relay state state = message.getBool(); digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); // Store state in eeprom gw.saveState(CHILD_ID, state); } else if(message.type == V_LIGHT && message.sensor == 2 && strlen(msg.getString()) != 0){ state2 = message.getBool(); digitalWrite(RELAY_PIN_2, state2?RELAY_ON:RELAY_OFF); // Store state in eeprom gw.saveState(CHILD_ID_2, state2); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } }
-
RE: Arduino 220V AC wattmeter
I don't have energy meter with blinking led that i'm interested too how to build watt meter?
-
RE: Relay With Button Actuator
It is possible to have more than one button and 1 really? I need 4 buttons and 4 relays. Could someone write what i should to change for that?
-
WaterMeterPulseSensor SLEEP_MODE true
Could someone tell how working SLEEP_MODE true. When I have SLEEP_MODE false everything is ok sensor send values but when I changed to true nothing happend on vera. How offen node send value to vera in SLEEP_MODE true?
-
RE: Domoticz full integration
I ask again what is the best way to use mysensor in domoticz software?