Trying to develope a whole house energy meter using My Sensors



  • Hi Folks,
    I've been trying to develop a whole house energy meter similar to Open EM: https://openenergymonitor.org/
    I've got it working with the Arduino serial monitor, but I'd like to be able to see the sensors in Domoticz. I've got the electrical know how, but I'm just not enough of a programmer to figure out the arduino sketch. I'd like to send the data to Domoticz via an Ethernet shield, and exclude the radio interface. I had some printed circuit boards made for the circuit. One is the exact design from Open Energy Monitor's web sight, they have their Gerber files free for download. The other is my own design based on their schematic. If someone with the code know how wants to fix up my sketch and make it work I'll send you some of my custom printed circuit boards in the mail!
    Thanks in advance!
    Here's the sketch that I've got so far:

    #include "EmonLib.h"
    #include "MySensors.h"
    #define MY_GATEWAY_SERIAL
    
    // Create  instances for each CT channel
    EnergyMonitor ct1,ct2,ct3;
    
    // On-board emonTx LED
    const int LEDpin = 9;  
                                                      
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    
    void setup() 
    {
      Serial.begin(11520);
      // while (!Serial) {}
      // wait for serial port to connect. Needed for Leonardo only
      
      //Serial.println("emonTX Shield CT123 Voltage Serial Only example"); 
     // Serial.println("OpenEnergyMonitor.org");
      
      // Calibration factor = CT ratio / burden resistance = (100A / 0.05A) / 33 Ohms = 60.606
      ct1.current(2, 60.606);
      ct2.current(3, 60.606);                                     
      ct3.current(4, 60.606);
      
      
      // (ADC input, calibration, phase_shift)
      ct1.voltage(1, 300.6, 1.7);                                
      ct2.voltage(1, 300.6, 1.7);                                
      ct3.voltage(1, 300.6, 1.7);
      
      
      // Setup indicator LED
      pinMode(LEDpin, OUTPUT);                                              
      digitalWrite(LEDpin, HIGH);                                                                                  
    }
    
    
    void presentation()
    {
        // Present locally attached sensors
    
      sendSketchInfo("KWH_meter", "1.0");
      //present(CHILD_ID, S_WHATEVER);
      present(CHILD_2, S_CT1 KW);
      present(CHILD_3, S_CT2 KW);
      present(CHILD_4, S_CT3 KW);
      present(CHILD_5, S_PT1 VOLTS);
      present(CHILD_6, S_CT1 AMPS);
      present(CHILD_7, S_CT2 AMPS);
      present(CHILD_8, S_CT3 AMPS);
      present(CHILD_9, S_CT1 PF);
      present(CHILD_10, S_CT2 PF);
      present(CHILD_11, S_CT3 PF);
      
      
    }
    
    
    void loop() 
    { 
    // Send locally attached sensor data here
    
    
      
      // Calculate all. No.of crossings, time-out 
      ct1.calcVI(20,2000);                                                  
      ct2.calcVI(20,2000);
      ct3.calcVI(20,2000);
     
        
      // Print power 
       Serial.print(" CT1 KW: ");
      Serial.print(ct1.realPower);     
      Serial.print(" CT2 KW: "); 
      Serial.print(ct2.realPower);
      Serial.print(" CT3 KW: "); 
      Serial.print(ct3.realPower);
      Serial.print(" Volts: "); 
      Serial.print(ct1.Vrms);
      Serial.println(" CT1 Amps: ");
      Serial.print(ct1.Irms);
      Serial.println(" CT2 Amps: ");
      Serial.print(ct2.Irms);
      Serial.println(" CT3 Amps: ");
      Serial.print(ct3.Irms);
      Serial.println(" Power Factor: ");
      Serial.print(ct1.powerFactor);
      
      
        
      // Available properties: ct1.realPower, ct1.apparentPower, ct1.powerFactor, ct1.Irms and ct1.Vrms
    
      delay(5000);
    }
    


  • you could have a look at this example for inspiration:
    https://www.mysensors.org/build/pulse_power



  • @PedroHernandez
    If you build sensor with ethernet connectivity, simply send your data to Domoticz via http call using Domoticz JSON API.



  • This could work. I've never played with JSON before. Thanks!

    @kimot said in Trying to develope a whole house energy meter using My Sensors:

    JSON API


  • Banned

    How can I do my house more energy efficient with this project?



  • It seems to be something nice. How is your project now? Did you understand what to do next?


Log in to reply
 

Suggested Topics

284
Online

9.6k
Users

10.2k
Topics

106.1k
Posts