Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. patrick schaerer
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    patrick schaerer

    @patrick schaerer

    6
    Reputation
    32
    Posts
    968
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    patrick schaerer Follow

    Best posts made by patrick schaerer

    • SCT-013-030 Energy Meter

      Hi all
      It's late and I finished the sketch for my Energy Meter. I'ts not tested yet, but the part for sct-reading is tested and works.
      In a few days more nanos arrive, then I can test it.

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * EnergyMeterSCT by Patrick Schaerer
       * This Sketch is a WattMeter used with a SCT-013-030 non invasive PowerMeter
       * see documentation for schematic
       * 
       * Special thanks to Surge, who optimized my code.
       * 
       * updated to mySensors Library 2.0
       */
      
      
      #define MY_RADIO_NRF24
      #define MY_REPEATER_FEATURE
      #define MY_DEBUG
      
      
      #include <SPI.h>
      #include <MySensors.h>  
      #include <EmonLib.h> 
       
      #define ANALOG_INPUT_SENSOR 1  // The digital input you attached your SCT sensor.  (Only 2 and 3 generates interrupt!)
      //#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 1              // Id of the sensor child
      
      EnergyMonitor emon1;
      
      MyMessage wattMsg(CHILD_ID,V_WATT);
      MyMessage kwhMsg(CHILD_ID,V_KWH);
      MyMessage msgKWH(CHILD_ID,V_VAR1);
      unsigned long SLEEP_TIME = 60000 - 3735; // sleep for 60 seconds (-4 seconds to calculate values)
      
      float wattsumme = 0;
      float kwh = 0;
      float wh = 0;
      int minuten = 0;  //vorher 61
      boolean KWH_received=false;
      
      //Humidity Sensor Code
      #include <DHT.h>  
      #define CHILD_ID_HUM 2
      #define CHILD_ID_TEMP 3
      #define HUMIDITY_SENSOR_DIGITAL_PIN 2
      DHT dht;
      float lastTemp;
      float lastHum;
      boolean metric = true; 
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      
      //End of Humidity Sensor Code
      
      
      void setup()  
      {  
        //energy clamp code
        //gw.begin(incomingMessage, AUTO, true,0); 
        
        Serial.begin(115200);
        emon1.current(ANALOG_INPUT_SENSOR, 30);             // Current: input pin, calibration.
      
        
        double Irms = emon1.calcIrms(1480);  // initial boot to charge up capacitor (no reading is taken) - testing
        request(CHILD_ID,V_VAR1);
        //end of energy clamp code
      
      //Humidity Sensor Code
        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);   
        metric = getConfig().isMetric;
        //End of Humidity Sensor Code 
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        // Register this device as power sensor
      sendSketchInfo("Energy Meter SCT013", "2.0");
      present(CHILD_ID, S_POWER);
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
      
      }
      void loop()     
      { 
        
        //process();
      
        //KWH reveived check
        if (!KWH_received) request(CHILD_ID,V_VAR1);
        
        // power used each minute
        if (minuten < 60) {
          double Irms = emon1.calcIrms(1480);  // Calculate Irms only
          if (Irms < 0.3) Irms = 0;
          long watt = Irms*240.0; // default was 230 but our local voltage is about 240
          wattsumme = wattsumme+watt;
          minuten++;
          send(wattMsg.set(watt));  // Send watt value to gw
          
          Serial.print(watt);         // Apparent power
          Serial.print("W I= ");
          Serial.println(Irms);          // Irms   
        }
        // end power used each minute
        
        // hours KW reading
        if (minuten >= 60) {
          wh = wh + wattsumme/60;
          kwh = wh/1000;
          send(kwhMsg.set(kwh, 3)); // Send kwh value to gw 
          send(msgKWH.set(kwh, 3)); // Send kwh value to gw
          wattsumme = 0;
          minuten = 0;
        }
      // end of hourly KW reading
          
      // Humidity Sensor Code
       if (minuten == 15 || minuten == 30 || minuten == 45|| minuten == 60) {
          float temperature = dht.getTemperature();
          if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT");
          } else if (temperature != lastTemp) {
            lastTemp = temperature;
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          send(msgTemp.set(temperature, 1));
          Serial.print("T: ");
          Serial.println(temperature);
          }
        
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
            Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum) {
            lastHum = humidity;
            send(msgHum.set(humidity, 1));
            Serial.print("H: ");
            Serial.println(humidity);
        }
       }
      
       //End of Humidity Sensor Code
       wait(SLEEP_TIME);
      }
      
      void receive(const MyMessage &message) {
        if (message.type==V_VAR1) {  
          kwh = message.getFloat();
          wh = kwh*1000;
          Serial.print("Received last KWH from gw:");
          Serial.println(kwh);
          //send(kwhMsg.set(kwh, 3)); // Send kwh value to gw 
          KWH_received = true;
        }
      }
          
      
      
      

      The schematics for attaching of the sct-013-030 is shown in the picture.

      IMG_20160103_223443.jpg

      posted in My Project
      patrick schaerer
      patrick schaerer
    • RE: irrigation controller arduino mega doesn't work anymore

      I found the problem ...
      due to a defective sensor (light meter) the arduino could not initialize correctly.
      I think that is why it was calling back setup()

      posted in Development
      patrick schaerer
      patrick schaerer
    • RE: SCT-013-030 Energy Meter

      0_1454182054474_Bildschirmfoto 2016-01-30 um 20.26.32.png

      C1 is 100uF

      R1+2 are 15k

      posted in My Project
      patrick schaerer
      patrick schaerer
    • RE: SCT-013-030 Energy Meter

      I alread updated to MySensors 2.0

      This is the update code:

      I also edited the first post.

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * EnergyMeterSCT by Patrick Schaerer
       * This Sketch is a WattMeter used with a SCT-013-030 non invasive PowerMeter
       * see documentation for schematic
       * 
       * Special thanks to Surge, who optimized my code.
       * 
       * updated to mySensors Library 2.0
       */
      
      
      #define MY_RADIO_NRF24
      #define MY_REPEATER_FEATURE
      #define MY_DEBUG
      
      
      #include <SPI.h>
      #include <MySensors.h>  
      #include <EmonLib.h> 
       
      #define ANALOG_INPUT_SENSOR 1  // The digital input you attached your SCT sensor.  (Only 2 and 3 generates interrupt!)
      //#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 1              // Id of the sensor child
      
      EnergyMonitor emon1;
      
      MyMessage wattMsg(CHILD_ID,V_WATT);
      MyMessage kwhMsg(CHILD_ID,V_KWH);
      MyMessage msgKWH(CHILD_ID,V_VAR1);
      unsigned long SLEEP_TIME = 60000 - 3735; // sleep for 60 seconds (-4 seconds to calculate values)
      
      float wattsumme = 0;
      float kwh = 0;
      float wh = 0;
      int minuten = 0;  //vorher 61
      boolean KWH_received=false;
      
      //Humidity Sensor Code
      #include <DHT.h>  
      #define CHILD_ID_HUM 2
      #define CHILD_ID_TEMP 3
      #define HUMIDITY_SENSOR_DIGITAL_PIN 2
      DHT dht;
      float lastTemp;
      float lastHum;
      boolean metric = true; 
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      
      //End of Humidity Sensor Code
      
      
      void setup()  
      {  
        //energy clamp code
        //gw.begin(incomingMessage, AUTO, true,0); 
        
        Serial.begin(115200);
        emon1.current(ANALOG_INPUT_SENSOR, 30);             // Current: input pin, calibration.
      
        
        double Irms = emon1.calcIrms(1480);  // initial boot to charge up capacitor (no reading is taken) - testing
        request(CHILD_ID,V_VAR1);
        //end of energy clamp code
      
      //Humidity Sensor Code
        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);   
        metric = getConfig().isMetric;
        //End of Humidity Sensor Code 
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        // Register this device as power sensor
      sendSketchInfo("Energy Meter SCT013", "2.0");
      present(CHILD_ID, S_POWER);
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
      
      }
      void loop()     
      { 
        
        //process();
      
        //KWH reveived check
        if (!KWH_received) request(CHILD_ID,V_VAR1);
        
        // power used each minute
        if (minuten < 60) {
          double Irms = emon1.calcIrms(1480);  // Calculate Irms only
          if (Irms < 0.3) Irms = 0;
          long watt = Irms*240.0; // default was 230 but our local voltage is about 240
          wattsumme = wattsumme+watt;
          minuten++;
          send(wattMsg.set(watt));  // Send watt value to gw
          
          Serial.print(watt);         // Apparent power
          Serial.print("W I= ");
          Serial.println(Irms);          // Irms   
        }
        // end power used each minute
        
        // hours KW reading
        if (minuten >= 60) {
          wh = wh + wattsumme/60;
          kwh = wh/1000;
          send(kwhMsg.set(kwh, 3)); // Send kwh value to gw 
          send(msgKWH.set(kwh, 3)); // Send kwh value to gw
          wattsumme = 0;
          minuten = 0;
        }
      // end of hourly KW reading
          
      // Humidity Sensor Code
       if (minuten == 15 || minuten == 30 || minuten == 45|| minuten == 60) {
          float temperature = dht.getTemperature();
          if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT");
          } else if (temperature != lastTemp) {
            lastTemp = temperature;
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          send(msgTemp.set(temperature, 1));
          Serial.print("T: ");
          Serial.println(temperature);
          }
        
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
            Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum) {
            lastHum = humidity;
            send(msgHum.set(humidity, 1));
            Serial.print("H: ");
            Serial.println(humidity);
        }
       }
      
       //End of Humidity Sensor Code
       wait(SLEEP_TIME);
      }
      
      void receive(const MyMessage &message) {
        if (message.type==V_VAR1) {  
          kwh = message.getFloat();
          wh = kwh*1000;
          Serial.print("Received last KWH from gw:");
          Serial.println(kwh);
          //send(kwhMsg.set(kwh, 3)); // Send kwh value to gw 
          KWH_received = true;
        }
      }
          
      
      
      posted in My Project
      patrick schaerer
      patrick schaerer

    Latest posts made by patrick schaerer

    • RE: irrigation controller arduino mega doesn't work anymore

      I found the problem ...
      due to a defective sensor (light meter) the arduino could not initialize correctly.
      I think that is why it was calling back setup()

      posted in Development
      patrick schaerer
      patrick schaerer
    • RE: irrigation controller arduino mega doesn't work anymore

      thank you for the link

      18743 MCO:PIM:NODE REG=1	Registration response received, registration status 1
      18746 MCO:BGN:STP	Callback setup()
      

      What is Registration status 1?
      Does Callback setup() reinitialize the node?

      posted in Development
      patrick schaerer
      patrick schaerer
    • irrigation controller arduino mega doesn't work anymore

      Arduino Mega Node not working anymore
      I have an arduino mega used for automated irrigation after a year of service the node is not responding anymore.
      The node runs on mysensor 2.1.1
      The serial monitor shows the following

      0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
      3 TSM:INIT
      4 TSF:WUR:MS=0
      11 TSM:INIT:TSP OK
      13 TSF:SID:OK,ID=5
      15 TSM:FPAR
      51 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      2058 !TSM:FPAR:NO REPLY
      2060 TSM:FPAR
      2096 TSF:MSG:SEND,5-5-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      2910 TSF:MSG:READ,11-11-5,s=255,c=3,t=8,pt=1,l=1,sg=0:3
      2915 TSF:MSG:FPAR OK,ID=11,D=4
      4104 TSM:FPAR:OK
      4105 TSM:ID
      4106 TSM:ID:OK
      4108 TSM:UPL
      4113 TSF:MSG:SEND,5-5-11-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      6120 TSM:UPL
      6125 TSF:MSG:SEND,5-5-11-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      8132 TSM:UPL
      8137 TSF:MSG:SEND,5-5-11-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      8212 TSF:MSG:READ,0-11-5,s=255,c=3,t=25,pt=1,l=1,sg=0:4
      8217 TSF:MSG:PONG RECV,HP=4
      8219 TSM:UPL:OK
      8221 TSM:READY:ID=5,PAR=11,DIS=4
      8246 TSF:MSG:SEND,5-5-11-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
      10255 TSF:MSG:SEND,5-5-11-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
      10297 !TSF:MSG:SEND,5-5-11-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=NACK:11
      12307 TSF:MSG:SEND,5-5-11-0,s=255,c=3,t=11,pt=0,l=12,sg=0,ft=1,st=OK:Bewässerung
      12351 !TSF:MSG:SEND,5-5-11-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=NACK:2.1
      12388 TSF:MSG:SEND,5-5-11-0,s=13,c=0,t=6,pt=0,l=0,sg=0,ft=1,st=OK:
      12396 TSF:MSG:SEND,5-5-11-0,s=14,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      12437 !TSF:MSG:SEND,5-5-11-0,s=15,c=0,t=16,pt=0,l=0,sg=0,ft=0,st=NACK:
      12445 TSF:MSG:SEND,5-5-11-0,s=1,c=0,t=7,pt=0,l=0,sg=0,ft=1,st=OK:
      12465 TSF:MSG:SEND,5-5-11-0,s=9,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      12474 TSF:MSG:SEND,5-5-11-0,s=2,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      12482 TSF:MSG:SEND,5-5-11-0,s=10,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      12492 TSF:MSG:SEND,5-5-11-0,s=3,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      12533 !TSF:MSG:SEND,5-5-11-0,s=11,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=NACK:
      12541 TSF:MSG:SEND,5-5-11-0,s=4,c=0,t=7,pt=0,l=0,sg=0,ft=1,st=OK:
      12582 !TSF:MSG:SEND,5-5-11-0,s=12,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=NACK:
      12590 MCO:REG:REQ
      12614 TSF:MSG:SEND,5-5-11-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=OK:2
      14625 TSF:MSG:SEND,5-5-11-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      16635 TSF:MSG:SEND,5-5-11-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      18647 TSF:MSG:SEND,5-5-11-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      18738 TSF:MSG:READ,0-11-5,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      18743 MCO:PIM:NODE REG=1
      18746 MCO:BGN:STP
      

      after MCO:BGN:STP nothing happens
      what does MCO:BGN:STP mean?
      greets
      patrick

      posted in Development
      patrick schaerer
      patrick schaerer
    • RE: SCT-013-030 Energy Meter

      I alread updated to MySensors 2.0

      This is the update code:

      I also edited the first post.

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * EnergyMeterSCT by Patrick Schaerer
       * This Sketch is a WattMeter used with a SCT-013-030 non invasive PowerMeter
       * see documentation for schematic
       * 
       * Special thanks to Surge, who optimized my code.
       * 
       * updated to mySensors Library 2.0
       */
      
      
      #define MY_RADIO_NRF24
      #define MY_REPEATER_FEATURE
      #define MY_DEBUG
      
      
      #include <SPI.h>
      #include <MySensors.h>  
      #include <EmonLib.h> 
       
      #define ANALOG_INPUT_SENSOR 1  // The digital input you attached your SCT sensor.  (Only 2 and 3 generates interrupt!)
      //#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
      #define CHILD_ID 1              // Id of the sensor child
      
      EnergyMonitor emon1;
      
      MyMessage wattMsg(CHILD_ID,V_WATT);
      MyMessage kwhMsg(CHILD_ID,V_KWH);
      MyMessage msgKWH(CHILD_ID,V_VAR1);
      unsigned long SLEEP_TIME = 60000 - 3735; // sleep for 60 seconds (-4 seconds to calculate values)
      
      float wattsumme = 0;
      float kwh = 0;
      float wh = 0;
      int minuten = 0;  //vorher 61
      boolean KWH_received=false;
      
      //Humidity Sensor Code
      #include <DHT.h>  
      #define CHILD_ID_HUM 2
      #define CHILD_ID_TEMP 3
      #define HUMIDITY_SENSOR_DIGITAL_PIN 2
      DHT dht;
      float lastTemp;
      float lastHum;
      boolean metric = true; 
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      
      //End of Humidity Sensor Code
      
      
      void setup()  
      {  
        //energy clamp code
        //gw.begin(incomingMessage, AUTO, true,0); 
        
        Serial.begin(115200);
        emon1.current(ANALOG_INPUT_SENSOR, 30);             // Current: input pin, calibration.
      
        
        double Irms = emon1.calcIrms(1480);  // initial boot to charge up capacitor (no reading is taken) - testing
        request(CHILD_ID,V_VAR1);
        //end of energy clamp code
      
      //Humidity Sensor Code
        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);   
        metric = getConfig().isMetric;
        //End of Humidity Sensor Code 
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        // Register this device as power sensor
      sendSketchInfo("Energy Meter SCT013", "2.0");
      present(CHILD_ID, S_POWER);
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
      
      }
      void loop()     
      { 
        
        //process();
      
        //KWH reveived check
        if (!KWH_received) request(CHILD_ID,V_VAR1);
        
        // power used each minute
        if (minuten < 60) {
          double Irms = emon1.calcIrms(1480);  // Calculate Irms only
          if (Irms < 0.3) Irms = 0;
          long watt = Irms*240.0; // default was 230 but our local voltage is about 240
          wattsumme = wattsumme+watt;
          minuten++;
          send(wattMsg.set(watt));  // Send watt value to gw
          
          Serial.print(watt);         // Apparent power
          Serial.print("W I= ");
          Serial.println(Irms);          // Irms   
        }
        // end power used each minute
        
        // hours KW reading
        if (minuten >= 60) {
          wh = wh + wattsumme/60;
          kwh = wh/1000;
          send(kwhMsg.set(kwh, 3)); // Send kwh value to gw 
          send(msgKWH.set(kwh, 3)); // Send kwh value to gw
          wattsumme = 0;
          minuten = 0;
        }
      // end of hourly KW reading
          
      // Humidity Sensor Code
       if (minuten == 15 || minuten == 30 || minuten == 45|| minuten == 60) {
          float temperature = dht.getTemperature();
          if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT");
          } else if (temperature != lastTemp) {
            lastTemp = temperature;
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          send(msgTemp.set(temperature, 1));
          Serial.print("T: ");
          Serial.println(temperature);
          }
        
        float humidity = dht.getHumidity();
        if (isnan(humidity)) {
            Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum) {
            lastHum = humidity;
            send(msgHum.set(humidity, 1));
            Serial.print("H: ");
            Serial.println(humidity);
        }
       }
      
       //End of Humidity Sensor Code
       wait(SLEEP_TIME);
      }
      
      void receive(const MyMessage &message) {
        if (message.type==V_VAR1) {  
          kwh = message.getFloat();
          wh = kwh*1000;
          Serial.print("Received last KWH from gw:");
          Serial.println(kwh);
          //send(kwhMsg.set(kwh, 3)); // Send kwh value to gw 
          KWH_received = true;
        }
      }
          
      
      
      posted in My Project
      patrick schaerer
      patrick schaerer
    • RE: openHAB 2.0 binding

      @TimO said:

      @bentrik said:

      I managed to find an addons directory in /usr/share/openhab2/addons, but I can´t find a way to copy the .jar file there, as I get permission denied both through WinSCP in sudo mode and terminal ssh. The folder has permission 0775.

      That is the correct directory if you installed OH2 via .deb. Seems like you are using a user in WinSCP that is not allowed to write to the directory above. To circumvent this:

      1. Copy the binding jar to /tmp.
      2. Login via ssh and execute:
      sudo cp /tmp/org.openhab.binding.mysensors-2.0.0-SNAPSHOT.jar /usr/share/openhab2/addons/
      

      and

      sudo chmod openhab.openhab /usr/share/openhab2/addons/org.openhab.binding.mysensors-2.0.0-SNAPSHOT.jar
      

      OH2 is started/stopped/restarted with

      service openhab2 start/stop/restart
      

      To log into the karaf console do:

      ssh openhab@localhost -p 8101
      

      Password is: habopen

      Follow the guide/wiki from:

      In the console enter feature:install openhab-transport-serial
      

      I have installed openhab with the openhabian image. I could start the mysensors gateway too.
      I followed the github-openhab2 installation instructions.
      To this point

      In the console enter feature:install openhab-transport-serial
      

      I read a lot of posts on this thread but on get this error:

      openhab> install openhab-transport-serial
      Bundle IDs:
      Error executing command: Error installing bundles:
      	Unable to install bundle openhab-transport-serial
      

      the chmod line posted above doesn't work neither. chmod does not accept openhab.openhab

      I dont have any clue how to install the binding for openhab2 ... why isn't that possible from paperui 😞

      posted in OpenHAB
      patrick schaerer
      patrick schaerer
    • RE: openhabian mySensors setup
      sudo apt-get install g++
      

      then I could do "make"

      posted in OpenHAB
      patrick schaerer
      patrick schaerer
    • RE: openhabian mySensors setup

      ok thanks
      i'll try

      posted in OpenHAB
      patrick schaerer
      patrick schaerer
    • openhabian mySensors setup

      Make command doesn't work on openhabian image.

      I installed openhab with the openhabian image and it works.
      I did the following ...

      [15:20:07] pi@openHABianPi:~$ git clone https://github.com/mysensors/MySensors.git
      Cloning into 'MySensors'...
      remote: Counting objects: 13297, done.
      remote: Total 13297 (delta 0), reused 0 (delta 0), pack-reused 13296
      Receiving objects: 100% (13297/13297), 9.34 MiB | 3.35 MiB/s, done.
      Resolving deltas: 100% (7989/7989), done.
      Checking connectivity... done.
      [15:20:54] pi@openHABianPi:~$ cd MySensors
      [15:21:01] pi@openHABianPi:~/MySensors$ ./configure --help
      15:21:10] pi@openHABianPi:~/MySensors$ ./configure --my-transport=nrf24 --my-rf24-irq-pin=15
      [SECTION] Detecting target machine.
      [OK] machine detected: SoC=BCM2836, Type=RPi3, CPU=armv7l, REV=a02082.
      [OK] init system detected: systemd
      [SECTION] Saving configuration.
      [SECTION] Cleaning previous builds.
      ./configure: line 505: make: command not found
      [OK] Finished.
      [15:22:49] pi@openHABianPi:~/MySensors$ make
      -bash: make: command not found
      [15:29:14] pi@openHABianPi:~$ sudo apt-get install make
      E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
      [15:29:22] pi@openHABianPi:~$ sudo dpkg --configure -a
      Setting up libpng12-0:armhf (1.2.50-2+deb8u2) ...
      Setting up libfontenc1:armhf (1:1.1.2-1) ...
      Processing triggers for libc-bin (2.19-18+deb8u6) ...
      [15:29:49] pi@openHABianPi:~$ sudo apt-get install make
      Reading package lists... Done
      Building dependency tree
      Reading state information... Done
      Suggested packages:
        make-doc
      The following NEW packages will be installed:
        make
      0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
      Need to get 333 kB of archives.
      After this operation, 1,047 kB of additional disk space will be used.
      Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main make armhf 4.0-8.1 [333 kB]
      Fetched 333 kB in 0s (758 kB/s)
      error: unable to resolve reference HEAD: Invalid argument
      fatal: cannot lock HEAD ref
      warning: etckeeper failed to commit changes in /etc using git
      Selecting previously unselected package make.
      (Reading database ... 26337 files and directories currently installed.)
      Preparing to unpack .../make_4.0-8.1_armhf.deb ...
      Unpacking make (4.0-8.1) ...
      Processing triggers for man-db (2.7.0.2-5) ...
      Setting up make (4.0-8.1) ...
      error: unable to resolve reference HEAD: Invalid argument
      fatal: cannot lock HEAD ref
      warning: etckeeper failed to commit changes in /etc using git
      Updating FireMotD available updates count ...
      [15:31:13] pi@openHABianPi:~$ cd MySensors
      [15:31:21] pi@openHABianPi:~/MySensors$ make
      gcc -MT build/drivers/Linux/log.o -MMD -MP -march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -DMY_RADIO_NRF24 -DMY_GATEWAY_LINUX -DMY_DEBUG -D__RPI_BPLUS -DLINUX_ARCH_RASPBERRYPI -DMY_RX_MESSAGE_BUFFER_FEATURE -DMY_RF24_IRQ_PIN=15  -Ofast -g -Wall -Wextra  -I. -I./core -I./drivers/Linux -I./drivers/RPi -c drivers/Linux/log.c -o build/drivers/Linux/log.o
      make: gcc: Command not found
      Makefile:102: recipe for target 'build/drivers/Linux/log.o' failed
      make: *** [build/drivers/Linux/log.o] Error 127
      

      What's wrong?

      posted in OpenHAB
      patrick schaerer
      patrick schaerer
    • RE: SCT-013-030 Energy Meter

      @m1rk0
      In Line 95 is the following expression:
      if (Irms < 0.3) Irms = 0;

      Irms is RMS current. The expression sets all current smaller than 0.3 as 0.
      You can delete this line for smaller values.
      I suggest to use a SCT-013-005 instead of a SCT-013-030.

      posted in My Project
      patrick schaerer
      patrick schaerer
    • RE: SCT-013-030 Energy Meter

      I optimized my code with the help of Surge.
      I added a KWH reading on a restart of the node.
      Now it's Version 1.3

      posted in My Project
      patrick schaerer
      patrick schaerer