Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Power/ Usage sensor - multi channel - local display

Power/ Usage sensor - multi channel - local display

Scheduled Pinned Locked Moved My Project
41 Posts 6 Posters 19.6k Views 7 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J jeti

    @AWI: :smiley: nevermind I will start workin on it
    Thanks again for the great work!

    J Offline
    J Offline
    jeti
    wrote on last edited by jeti
    #26

    was not that much work :smiley:
    this is the modified master-sketch from AWI i am starting to use. The changes i made:
    -deletion of LCD and rotray part
    -deletion of accumulation part
    -modified meterType to meter800, meter1000 and meter2000 this reflects meters with 800imp/khw;1000imp/kwh;2000imp/kwh

    I am using this with only one meter (2000imp/kwh) for now and works pretty nicly second different meter type is on the way.

    As I am a beginner please be gentle with comments :-)

    
    #include <MySensor.h>                   // MySensors network
    #include <SPI.h>
    #include <Time.h> 
    #include <ArduinoJson.h>                // used to parse the simple JSON output of the pulse meter https://github.com/bblanchon/ArduinoJson
    
    // Constants & globals
    const int NO_METERS = 1 ;               // actual meters used (max 12)
    const int NODE_ID = 152 ;                // fixed MySensors node ID
    
    const int JSON_LENGHT = 80 ;            // Maximum json string length
    
    // new V_TEXT variable type (development 20150905)
    const int V_TEXT = 47 ;
    // new S_INFO sensor type (development 20150905)
    const int S_INFO = 36 ;
    
    char lastLCD1[21] = "--                  "; // LCD message line
    
    typedef enum meterTypes: int8_t {meter800, meter1000, meter2000} ;             // metertype meter800, meter1000, meter2000; 
    const char METER_NAMES[NO_METERS][4] = {"PC"} ; // meter names
    const meterTypes METER_TYPES[NO_METERS] = {meter2000};
    
    const unsigned long idleTime = 10000 ;  // Delay time for any of the states to return to idle
    unsigned long idleTimer ;               // Delay timer for idleTime
    
    
    
    union {                                 // used to convert long to bytes for EEPROM storage
        long kWhLongInt;
        uint8_t kWhLongByte[4];
        } kWhLong ;
    
    
    // Possible states for the state machine.
    // Idle: default state, show totals for in/out nett
    // Browse: dive into meter details 
    // Update: update meter value (Wh total)
    // Reset: reset day values
    enum States: int8_t {IDLE, BROWSE, UPDATE, RST} ;
    uint8_t State = IDLE;                   // current state machine state
    
    // meter class, store all relevant meter data (equivalent to struct)
    class pulseMeter              
    {
    public:                                  
        long UsageWh;                       // last (current) usage (in W) from pulse counter
        long UsageAccumWh;                  // usage accumulator (to keep in sync) from pulse counter
        long PowerW;                        // actual power, calculated from pulse "rate"
        long DayUsageWh;                    // daily usage for display
        meterTypes Type;                    // metertype for addition in totals: meter800, meter1000, meter2000; 
        char Name[4] ;                      // meter name for display
    };
    pulseMeter pulseMeters[NO_METERS] ;     // define power meters
    //pulseMeter meter800, meter1000, meter2000; //  pulse/kWh
    unsigned long tempUsageWh ;             // temporary store while manually updating (state UPDATE) 
    
    // Json parser:  define parse object: <10> = number of tokens in JSON: ~10 per m (4 * [key, value] + key_total, value_total))
    // example: "{\"m\":1,\"c\":12,\"r\":120000,\"cA\":12345}"
    char json[JSON_LENGHT] ;        // Storage for serial JSON string (init for example)
    
    // flags & counters 
    bool timeReceived = false;              // controller time
    bool newDay = false;                    // reset at 00:00:00
    unsigned long lastUpdate=0, lastRequest=0, lastDisplay=0, lastSyncKWH=0;  // loop timers for once in while events
    int updateMeter = 0;                    // current meter for update
    bool updateDisplayFlag = true ;         // indicate that display needs to be updated
    int currentMeter = 0;                   // active meter for update & check, cycles through meters (0..NO_METERS-1)
    int lastRotary = 0;                     // last rotary encoder position
    int updateIncrement = 1000 ;            // Interval multiplier for Update 
    int errCount = 0 ;                      // error counter
    // *** Definition and initialisation
    // define the MySensor network
    MySensor gw;                            // pins used RFX24(default 9,10)
        
    // Initialize messages for sensor network
    MyMessage powerMsg(0,V_WATT);           // message to send power in W
    MyMessage usageMsg(0,V_KWH);            // message to send usage in kWH
    MyMessage textMsg(0,V_TEXT);            // message to send/receive text
    
    
    
    // function to reset the Arduino (jump to 0 address)
    void(* resetFunc) (void) = 0;//declare reset function at address 0
    
    void setup(void)
    {
        gw.begin(incomingMessage, NODE_ID, false);              // this node is fixed, no repeat
        //Send the sensor node sketch version information to the gateway
        gw.sendSketchInfo("AWI-12ChannelPulse", "2.0");
        // Initialize the meter names
        
        // Register all Pulse counters to gw (they will be created as child devices from 0 to MAX-1)
        for (int x = 0; x < NO_METERS; x++){ 
            gw.present(x, S_POWER, METER_NAMES[x]);             // present power meters to gateway
            delay(10);                                          // give it some time to process
            }
        
        delay(100);
    
        
        for (int x = 0; x < NO_METERS; x++){                    // initialize previous kWh values from EEPROM and init
            for (int y = 0; y < 4 ; y++){                       // convert from bytes
                kWhLong.kWhLongByte[y]= gw.loadState(x *4 + y) ;// EEPROM position = meter number * 4 bytes
                }                                               // controller is updated later automatically
            pulseMeters[x].UsageWh = kWhLong.kWhLongInt;
            strcpy(pulseMeters[x].Name, METER_NAMES[x] );       // copy string for meter names
            pulseMeters[x].Type = METER_TYPES[x];               // Set type
            }
     }
    
    void loop(void)
    {
        // Before specific states, perform generic tasks
        unsigned long now = millis();                           // Timer in loop for "once in a while" events
        gw.process() ;                                          // process incoming messages
        // If no time has been received yet, request it every 10 second from controller
        if ((!timeReceived && (now-lastRequest > 10*1000)) ||   
            (now-lastRequest > 3600000UL)){                     // request update every hour to keep in sync
            Serial.println(F("requesting time"));               // Request time from controller. 
            timeReceived = false;
            gw.requestTime(receiveTime);  
            lastRequest = now;
        }
        // Check if new day has started (hour == 0) and reset day usage counters of meters
        if (hour()==0 && !newDay){
            newDay = true;
            for (int x = 0; x < NO_METERS; x++){ 
                pulseMeters[x].DayUsageWh = 0 ;                 // reset daily counters
                saveMeters(x);                                  // save meter values to EEPROM
            }   
        } else if(hour() != 0 && newDay)                        // reset newday flag if hour != 0
            { newDay = false;}
         
        // Every 10 seconds update one meter to controller to avoid traffic jams
        if (now-lastSyncKWH > 10000){
        //    printPulsemeter(updateMeter);
            sendPowerUpdate(updateMeter);                               // update the values for currentMeter
            updateMeter++ ;
            if (updateMeter >= NO_METERS){                              // increment and wrap current meter
                updateMeter = 0 ;}
            lastSyncKWH = now ;
            }
            
        // Update sensors every 10 secs
        if (now-lastUpdate > 10000) {
            // get values to be displayed from controller
            
            lastUpdate = now;
        }
        
        // get readings from serial (sent every 10s)
        // format {"m":meter,"c":count,"r":rate, "cA":countAccum}
        // use JSON parser to process (could be replaced by simple split routine, but this works just fine)
        if(readLineJSON(Serial.read(), json, JSON_LENGHT) > 0 ){        //dummySerial(), Serial.read()
        // if(readLineJSON(dummySerial(), json, 80) > 0 ){              //dummySerial(), Serial.read()
            Serial.println(json);
            storeMeterJSON(json);                                       //store the meter reading
            //calcMeterTotals();                                          // update totals
            }
    }
    
    // This is called when a new time value was received
    void receiveTime(unsigned long controllerTime) {
        // Ok, set incoming time 
        Serial.print(F("Time value received: "));
        Serial.println(controllerTime);
        setTime(controllerTime);                                        // set the clock to the time from controller
        timeReceived = true ;
    }
    
    // This is called when a message is received 
    void incomingMessage(const MyMessage &message) {
      // Expect few types of messages from controller, V_VAR1 for messages
        if (message.type==V_TEXT) {
            // if message comes in, update the kWH reading for meter with value since last update
            // Write some debug info
            //Serial.print("Last reading for sensor: ");
            //Serial.print(message.sensor);                
            //Serial.print(", Message: ");
            //Serial.println(message.getString());
    
            }
        }
    
    
    // save Meter to EEPROM when needed
    void saveMeters(int8_t meterNo){
        kWhLong.kWhLongInt = pulseMeters[meterNo].UsageWh ;                     // convert to separate bytes via struct
        for (int y = 0; y < 4 ; y++){
            gw.saveState(meterNo * 4 + y, kWhLong.kWhLongByte[y])  ;            // EEPROM position = meter number * 4 bytes
            }
        }
    
    void sendPowerUpdate(int meterNo)
    // Sends update to controller for current meter 
    {
        gw.send(powerMsg.setSensor(meterNo).set((long)pulseMeters[meterNo].PowerW));            // meterNo * 100 ));
        gw.send(usageMsg.setSensor(meterNo).set((float)pulseMeters[meterNo].UsageWh/1000L ,3)); // send in kWh!
    }
    
    int storeMeterJSON(char *json)
    /* convert JSON to values and store in corresponding meter (if used)
     input: JSON string (can be wrong formatted), with length
     output: changed meter record number or -1 if error
     use JsonParser 
    */
    {
      StaticJsonBuffer<50> jsonBuffer;                          // 4 object  -> 4 + 4*10 = 44
      // char njson[] = "{\"m\":1,\"c\":12,\"r\":120000,\"cA\":12345}";
        JsonObject& root = jsonBuffer.parseObject(json);
      if (!root.success())
        {
            Serial.println(F("JsonParser.parse() failed"));
            errCount++ ;
            return -1;
        }
      int m = (long)root["m"];
      if (m > NO_METERS){                                       // meter value out of range for used meters (m starts at 1)
        return -1 ;
      } else {                                                  // update meter values, Power is momentary, Usage is cumulative
        long newAccumWh = (long)root["cA"] ;
        long newWh = (long)root["c"] ;
        long diffAccumWh = newAccumWh - pulseMeters[m-1].UsageAccumWh;  // check for missed pulses by comparing cA with last stored value
        if (diffAccumWh >= newWh){                              // no difference or missed pulses -> correct: add difference
            pulseMeters[m-1].UsageWh += diffAccumWh;
            pulseMeters[m-1].DayUsageWh += diffAccumWh;
            }
        else {                                                  // negative diff, out of sync -> add pulses only (can be out of range or restart)
            pulseMeters[m-1].UsageWh += newWh;
            pulseMeters[m-1].DayUsageWh += newWh;
            }
        pulseMeters[m-1].UsageAccumWh = newAccumWh;             // always update sync counter (only for sync and error correction(serial))
        if ((long)root["r"] == 0){                              // calculate power from pulse rate (ms) and truncate to whole Watts
          pulseMeters[m-1].PowerW = 0;                          // if overflow assume no Usage
        } else if (pulseMeters[m-1].Type == meter800){
          pulseMeters[m-1].PowerW = long( 3600000000L / (long)root["r"]*0.8); // rate in microseconds for 800 pulse/kWh
          }
          else if (pulseMeters[m-1].Type == meter1000){
          pulseMeters[m-1].PowerW = long( 3600000000L / (long)root["r"]); // rate in microseconds for 1000 pulse/kWh
          }
           else if (pulseMeters[m-1].Type == meter2000){
           pulseMeters[m-1].PowerW = long( 3600000000L / (long)root["r"]/2); // rate in microseconds for 2000 pulse/kWh
          }
          else {
            Serial.println("geht nicht");
            }
        return m ;
      }
    }
    
    int readLineJSON(int readch, char *buffer, int len)
    /* checks for JSON and when started append char tot buffer and checks for line completion 
    usage:
      static char buffer[80];
      if (readline(Serial.read(), buffer, 80) > 0) { // line complete}
      returns simple JSON
      */
    {
      static int pos = 0;
      int rpos;
    
      if (readch > 0) {
        switch (readch) {
          case '\n':                // Ignore new-lines
            break;
          case '\r':                // Return on CR
            rpos = pos;
            pos = 0;                  // Reset position index ready for next time
            return rpos;
          default:
            if (pos < len-1) {
              buffer[pos++] = readch;
              buffer[pos] = 0;
            }
        }
      }
      // No end of line has been found, so return -1.
      return -1;
    }
    
    /*
    int dummySerial()
    // Acts as a dummy JSON serial character generator for debugging
    // input: none
    // output: preset JSON string
    {
      static int pos = 0;
      char json[] = "{\"m\":1,\"c\":12,\"r\":120000,\"cA\":12345}\r{\"m\":2,\"c\":212,\"r\":2120000,\"cA\":212345}\r{\"m\":3,\"c\":212,\"r\":2120000,\"cA\":212345}\n\r";
      if (pos++ >= strlen(json)){
        pos = 0;
      } 
      return json[pos] ;
      
    }
    */
    
    
    /*
    
    void printPulsemeter(int meter)
    // prints the Pulsemeter record to serial out
    {
      Serial.print("m:");
      Serial.print(meter);
      Serial.print("type:");
      Serial.print(pulseMeters[meter].Type);
      Serial.print(", power: ");
      Serial.print(pulseMeters[meter].PowerW);
      Serial.print(", usage: ");
      Serial.print(pulseMeters[meter].UsageWh);
      Serial.print(", day usage: ");
      Serial.println(pulseMeters[meter].DayUsageWh );
    //  Serial.print(", Ca: ");
    //  Serial.println(pulseMeters[meter].UsageAccumWh);
    }
    */
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      MarkV
      wrote on last edited by
      #27

      Good evening,

      After a couple of weeks, again i'm busy with my arduino's, but now i have a rasberry with domoticz near my arduino, so i don't need to send it wireless.
      Is there a possibility to connect the master or slave arduino directly to my rasberry and read out the pulse meters???

      1 Reply Last reply
      0
      • mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by
        #28

        With MySensors version 1.6 (currently in development) you can connect the Arduino to the Raspberry Pi's USB port using a FTDI or CH340G. That type of connection is called a serial gateway. Before 1.6, the gateways do not support local sensors.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MarkV
          wrote on last edited by MarkV
          #29

          So with 1.6 i can install the master software and connect my arduino master directly through usb without the rf24''s? ?

          1 Reply Last reply
          0
          • mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by
            #30

            I am not entirely sure what a master is, but yes, I think you can.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MarkV
              wrote on last edited by MarkV
              #31

              I meen the master sketch like written above.

              I'd want to build a gateway but without the wireless RF part, just connect the master arduino directly through usb to the RasberryPi and readout the measurements.

              So in general:

              Kwh Meters -- cable --> Slave arduino <-- serial --> Master arduino <-- USB --> RasberryPi

              AWIA 1 Reply Last reply
              0
              • M MarkV

                I meen the master sketch like written above.

                I'd want to build a gateway but without the wireless RF part, just connect the master arduino directly through usb to the RasberryPi and readout the measurements.

                So in general:

                Kwh Meters -- cable --> Slave arduino <-- serial --> Master arduino <-- USB --> RasberryPi

                AWIA Offline
                AWIA Offline
                AWI
                Hero Member
                wrote on last edited by
                #32

                @MarkV If you don't want it to be MySensors enabled and not used the display etc. it's easier to readout the slave with the raspberry. The protocol is a simple Json and if you use a nano for the slave you can connect it with usb..

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MarkV
                  wrote on last edited by MarkV
                  #33

                  Last weeks i'm trying to get it to work but without luck. Could you give a manual on how to get it working with json? What should we do? And how? On my rasberry, on the arduino and in domoticz??

                  1 Reply Last reply
                  0
                  • AWIA AWI

                    @FotoFieber To be honest .. a left over from some experiments. Just leave it out... you won't notice the difference.

                    M Offline
                    M Offline
                    MarkV
                    wrote on last edited by MarkV
                    #34

                    @AWI
                    Goodmorning,
                    I've got a question, are you planning to re-write the script for the main and slave Arduino to the new MySensors 2.0 structuur?

                    I've also tryed to look on github if there's a page from you, but didn't find it...

                    AWIA 1 Reply Last reply
                    0
                    • M MarkV

                      @AWI
                      Goodmorning,
                      I've got a question, are you planning to re-write the script for the main and slave Arduino to the new MySensors 2.0 structuur?

                      I've also tryed to look on github if there's a page from you, but didn't find it...

                      AWIA Offline
                      AWIA Offline
                      AWI
                      Hero Member
                      wrote on last edited by AWI
                      #35

                      @MarkV I updated the sketch for main a few months ago to development (pre-2.0). Also changed it a little for stability and removed the (complicated) JSON library The slave has no MySensors dependency.

                      M 1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        MarkV
                        wrote on last edited by
                        #36

                        Super.
                        I've updated everything and it's up and running.
                        But my Master arduino (UNO clone) gives this readout on the USB port:

                        0;255;3;0;14;Gateway startup complete.
                        0;255;3;0;11;AWI-12ChannelPulse
                        0;255;3;0;12;2.0
                        0;0;0;0;13;Groep 1
                        0;1;0;0;13;Groep 2
                        0;2;0;0;13;Groep 3
                        0;3;0;0;13;Groep 4
                        0;4;0;0;13;Groep 5
                        0;5;0;0;13;Groep 6
                        0;20;0;0;36;Usage meter LCD
                        0;20;1;0;47;-
                        0;255;3;0;1;
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        0;255;3;0;1;
                        0;1;1;0;17;0
                        0;1;1;0;18;-0.001
                        0;255;3;0;1;
                        0;2;1;0;17;0
                        0;2;1;0;18;-0.001
                        0;255;3;0;1;
                        0;3;1;0;17;0
                        0;3;1;0;18;-0.001
                        0;255;3;0;1;
                        0;4;1;0;17;0
                        0;4;1;0;18;-0.001
                        0;20;2;0;47;
                        0;255;3;0;1;
                        0;5;1;0;17;0
                        0;5;1;0;18;-0.001
                        0;255;3;0;1;
                        0;0;1;0;17;0
                        0;0;1;0;18;-0.001
                        

                        Is this correct?
                        Because Domoticz doesn't change the values.
                        Also this is not the format, wich is past through in the JSON code from the slave to master duino??

                        1 Reply Last reply
                        0
                        • AWIA AWI

                          @MarkV I updated the sketch for main a few months ago to development (pre-2.0). Also changed it a little for stability and removed the (complicated) JSON library The slave has no MySensors dependency.

                          M Offline
                          M Offline
                          MarkV
                          wrote on last edited by
                          #37

                          @AWI
                          How is it that i get the readings like above? And after a while the sensor also stops with sending data, last connection stays on that time and date.

                          I've uploaded your github sketch and done a serial readout of the measuring arduino and that one functions proberbly. No faulty low voltage errors etc.

                          AWIA 1 Reply Last reply
                          0
                          • M MarkV

                            @AWI
                            How is it that i get the readings like above? And after a while the sensor also stops with sending data, last connection stays on that time and date.

                            I've uploaded your github sketch and done a serial readout of the measuring arduino and that one functions proberbly. No faulty low voltage errors etc.

                            AWIA Offline
                            AWIA Offline
                            AWI
                            Hero Member
                            wrote on last edited by
                            #38

                            @MarkV Ok, one step at a time.. the output looks like the output of your (serial) gateway. Have you tried to switch on the "Master node" debug Serial.print() statements?

                            M 1 Reply Last reply
                            0
                            • AWIA AWI

                              @MarkV Ok, one step at a time.. the output looks like the output of your (serial) gateway. Have you tried to switch on the "Master node" debug Serial.print() statements?

                              M Offline
                              M Offline
                              MarkV
                              wrote on last edited by
                              #39

                              @AWI
                              It the serial output from the gateway arduino, wich i've got connected through usb.
                              I don't have a rotaryswitch connected and yesterday evening i connected a I2c Display just to see if something changes on that.

                              I noticed one thin, when i check the serial output, the timer on the display is reset. Further more when i stop the serial readout, the counter also stops, like if the hole thing go's into a idle or stop.

                              I've uncommented the debug informatie wich i could find:

                              // Handle incoming messages from the MySensors Gateway
                              void receive(const MyMessage &message) {  // Expect few types of messages from controller, V_VAR1 for messages
                                if (message.type==V_TEXT) {
                                  // if message comes in, update the kWH reading for meter with value since last update
                                  // Write some debug info
                                  Serial.print("Last reading for sensor: ");
                                  Serial.print(message.sensor);                
                                  Serial.print(", Message: ");
                                  Serial.println(message.getString());
                                  if (message.sensor == LCD1_CHILD ) {
                                    strcpy(lastLCD1, message.getString());  // read payload in LCD string
                                  }
                                }
                              }
                              

                              Were could i read this debug information?
                              At this moment i got my arduino hooked up through usb to my rasberry to see if it keeps sending information.

                              I also changed all the cables to the meters.

                              This is how one meter looks like:
                              0_1462289685255_upload-a785d675-02ea-45c7-9888-2616d6a5c4f4

                              And a other one:
                              0_1462289751196_upload-ac4e8673-e392-43ac-aeea-1be31416479a

                              All the meters are showing also strange values on the axis.

                              Sorry for being such a noob at this.. :-S

                              AWIA 1 Reply Last reply
                              0
                              • M MarkV

                                @AWI
                                It the serial output from the gateway arduino, wich i've got connected through usb.
                                I don't have a rotaryswitch connected and yesterday evening i connected a I2c Display just to see if something changes on that.

                                I noticed one thin, when i check the serial output, the timer on the display is reset. Further more when i stop the serial readout, the counter also stops, like if the hole thing go's into a idle or stop.

                                I've uncommented the debug informatie wich i could find:

                                // Handle incoming messages from the MySensors Gateway
                                void receive(const MyMessage &message) {  // Expect few types of messages from controller, V_VAR1 for messages
                                  if (message.type==V_TEXT) {
                                    // if message comes in, update the kWH reading for meter with value since last update
                                    // Write some debug info
                                    Serial.print("Last reading for sensor: ");
                                    Serial.print(message.sensor);                
                                    Serial.print(", Message: ");
                                    Serial.println(message.getString());
                                    if (message.sensor == LCD1_CHILD ) {
                                      strcpy(lastLCD1, message.getString());  // read payload in LCD string
                                    }
                                  }
                                }
                                

                                Were could i read this debug information?
                                At this moment i got my arduino hooked up through usb to my rasberry to see if it keeps sending information.

                                I also changed all the cables to the meters.

                                This is how one meter looks like:
                                0_1462289685255_upload-a785d675-02ea-45c7-9888-2616d6a5c4f4

                                And a other one:
                                0_1462289751196_upload-ac4e8673-e392-43ac-aeea-1be31416479a

                                All the meters are showing also strange values on the axis.

                                Sorry for being such a noob at this.. :-S

                                AWIA Offline
                                AWIA Offline
                                AWI
                                Hero Member
                                wrote on last edited by
                                #40

                                @MarkV Hi Mark It is a rather complicated sketch, so not easy to debug remote.
                                You need to connect the master arduino to your USB and check with the serial monitor.
                                then add some Serial.print() statements starting form where the data is read.

                                The piece you commented out is where the node should receive information from the controller. I expect you didn't come far enough to set that up.

                                (as I noticed you are Dutch, we can use the chat function on the forum to get this working...please don't expect immediate answers..)

                                M 1 Reply Last reply
                                0
                                • AWIA AWI

                                  @MarkV Hi Mark It is a rather complicated sketch, so not easy to debug remote.
                                  You need to connect the master arduino to your USB and check with the serial monitor.
                                  then add some Serial.print() statements starting form where the data is read.

                                  The piece you commented out is where the node should receive information from the controller. I expect you didn't come far enough to set that up.

                                  (as I noticed you are Dutch, we can use the chat function on the forum to get this working...please don't expect immediate answers..)

                                  M Offline
                                  M Offline
                                  MarkV
                                  wrote on last edited by
                                  #41

                                  @AWI
                                  Goodevening
                                  Oh better, we definitie have to de that. When does it suit you?

                                  Grtz

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  13

                                  Online

                                  11.7k

                                  Users

                                  11.2k

                                  Topics

                                  113.1k

                                  Posts


                                  Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • MySensors
                                  • OpenHardware.io
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular