Smartmeter sensors


  • Hardware Contributor

    Energy companies in Holland started the deployment of the so-called Smartmeters for electricity and gas. These meters have the ability to be read out.

    Information on how to do the read-out I use this site for reference.

    Note that the data output of the meter needs to be inverted, there are various possiblities to do this. These can be found here.

    All info on how to connect the meter to your arduino is in the source code:
    0_1470081395831_SmartMeterSensor20.ino

    Enjoy it, and if you have any remarks or improvements, post a response to this topic.


  • Admin

    Maybe you could create a project on openhardware.io to make your sketch a little bit more accessible and easy to find.


  • Mod

    @Japio Welcome to the forum! 👍
    This is for a DSMR P1 meter, right?

    Oh, and we just looooove pictures 😘


  • MySensors Evangelist

    Hi all.
    I am able to read data from the Kampstrup P1 port easily with an FTDI->Serial cable and feed the data into domoticz via a ser2net solution.
    However as I always want to MySensor things.... this thread inspired me.

    I started by looking at the hardware I had for assembly and this website: Domoticx.com P1

    (Based on this Layout] (http://domoticx.com/wp-content/uploads/p1-uitlezen-arduino-BC574-transistor.png)

    It is based upon an NPN transistor (BC547 transistor), as I don't had that one available I used the NPN 2N2222A. It seems to be compatible however the pins are reversed. (Idea read here 2N222A] (https://www.circuitsonline.net/forum/view/115593)

    (BC547 transistor) -> Collector (1), Base (2), Emitter (3)
    (2N2222A) -> Emitter (1), Base (2), Collector (3)

    A well if you just turn it clockwise the pins are the same again 😉

    So far so good.

    In addition I used used:
    1x Arduino NANO
    1x resistor 2K Ohm, dit not have 1k)
    2x resistor 10K Ohm

    And because it did not work. In addition I used used:
    1x Arduino NANO
    2x resistor 2K Ohm (In parralel, to meet the 1k)
    2x resistor 10K Ohm

    I created a P1 cable using ethernetcable. The signal pin drops every 10 seconds or so its voltage so defintely something is pumping through the cable (measured the cable as well. It is working and does not need any additional resistor for Kampstrup P1)

    I studied the altserial library as described here
    Watch out for pins 8,9,10. A well in my case pin 8 as that one has my MySenSors antenne attached to it.
    (easy fix in Mysensors 2.0.0+) -> :

    // Differten PIN to keep Altserial Working ;-)
    #define MY_RF24_CE_PIN 3
    

    After attaching the wires and running nothing happened so I disconnected all MySensor wiring and started with a plain P1 script just to see if data was flowing into my Serial.Window

    #include <AltSoftSerial.h>
    // AltSoftSerial always uses these pins:
    //
    // Board          Transmit  Receive   PWM Unusable
    // -----          --------  -------   ------------
    // Teensy 2.0         9        10       (none)
    // Teensy++ 2.0      25         4       26, 27
    // Arduino Uno        9         8         10
    // Arduino Mega      46        48       44, 45
    // Wiring-S           5         6          4
    // Sanguino          13        14         12
     
    AltSoftSerial altSerial;
    char c;
     
    void setup() {
        Serial.begin(9600);
        altSerial.begin(9600);
    }
     
    void loop() {
        if (altSerial.available()) {
            Serial.println("Serial Available");
            c = altSerial.read();
       
            // --- 7 bits instelling ---
            c &= ~(1 << 7);
            char inChar = (char)c;
     
        Serial.print(c);
        }
         else {
          Serial.println("Serial NOT Available");
      }
    }
    

    As I only receive "Serial Not Available" something else must be wrong. But I don't know what to check,

    The only thing I can see that is odd is the following on the Domoticx.com P1 website.
    The prereq says:

    1. Arduino UNO/NANO/MEGA:
    2. ArduinoIDE software
    3. ArduinoIDE AltSoftSerial library
    4. BC547 transistor
    5. 2x reisistor of 1K Ohm
    6. 1x resistor 10K Ohm

    The building scheme says the opposite.

    1. 1x resistor 1K Ohm
    2. 2x reisistor of 10K Ohm

    Suggestions are welcome. If this basic script works I am sure MySensors will work as well.
    Tnx guys


  • MySensors Evangelist

    @Japio tnx for the inspiration and first version of the program.
    I just had to have this working in my 2.0.0+ Mysensors 😉 and modified it a bit.

    Added some TX/RX/ERR leds and had to move some pins.
    In addtition I apply permanent 5v to receive data packages so removed some things from the initial program.

    /////////////////////////////////////////////////////////////////////////////////////
    // Name: MySensors node for Kamstrup smartmeter
    // Version: 1.0
    // Date: Aug 1, 2016
    // Author: Jaap van Alphen
    // Description:
    // Exposes the following sensors:
    // Id   Name                              Additional info
    //  1   +T1                               Updated every hour
    //  2   +T2                               Updated every hour
    //  3   -T1                               Updated every hour
    //  4   -T2                               Updated every hour
    //  5   Tariff                            Updated on change of tariff
    //  6   Current usage electricity         Updated every 10 seconds
    //  7   Current production electricity    Updated every 10 seconds
    //  8   Switch state                      Updated on each change of switch state
    //  9   Gas reading                       Updated when time stamp changes (every hour)
    //  10  Gas time stamp                    Time stamp of last gas reading
    //
    // This software comes as-is, you may alter this source code to your wish, but author is in no circumstance 
    // responsible for any damage you make to your smart meter, or any other hardware.
    //
    // Version: 1.1
    // Date: Oct 4th, 2016
    // Author: Jaap van Alphen
    // Modified: Sandor Incze / Michel Schilthuizen
    //
    // Based on the tips: http://gejanssen.com/howto/Slimme-meter-uitlezen/
    // RJ11 Pin layout:   pin 1 request (RTS)   - ARDUINO 5V
    //                    pin 2 GND             - ARDUINO GND
    //                    pin 3 N.C
    //                    pin 4 RxD             - ARDUINO NANO D08
    //
    // AltSoftSerial always uses these pins:
    //
    // Board          Transmit  Receive   PWM Unusable
    // -----          --------  -------   ------------
    // Teensy 2.0         9        10       (none)
    // Teensy++ 2.0      25         4       26, 27
    // Arduino Uno        9         8         10
    // Arduino Mega      46        48       44, 45
    // Wiring-S           5         6          4
    // Sanguino          13        14         12
    
    // D8         Serial input from smartmeter (default port for AltSoftSerial). 
    //            Note that meter output sometimes needs to be inverted.
    //            http://domoticx.com/p1-poort-slimme-meter-uitlezen-hardware/
    /////////////////////////////////////////////////////////////////////////////////////// 
    
    // ADD Some LEDS if you want to monitor Mysensors traffic
    
    /*
     * Wire connections (OPTIONAL):
     * - Inclusion button should be connected between digital pin 3 and GND  
     * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
     *
     * LEDs (OPTIONAL):
     * - To use the feature, uncomment MY_LEDS_BLINKING_FEATURE in MyConfig.h
     * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
     * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
     * - ERR (red) - fast blink on error during transmission error or recieve crc error 
     */
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    #define MY_NODE_ID 20
    
    // Differten PIN to keep Altserial Working ;-) and NANO Happy
    
    #define MY_RF24_CE_PIN 3
    #define MY_RF24_CS_PIN 7 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Set LOW transmit power level as default, if you have an amplified NRF-module and
    // power your radio separately with a good regulator you can turn up PA level. 
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    
    // Enabled repeater feature for this node
    // #define MY_REPEATER_FEATURE
    
    // Flash leds on rx/tx/err
    // enable #define MY_LEDS_BLINKING_FEATURE finction in MyConfig.h
    #define MY_LEDS_BLINKING_FEATURE
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    // Inverses the behavior of leds
    //#define MY_WITH_LEDS_BLINKING_INVERSE
    
    #define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin  RED LED
    #define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin  GREEN LED
    #define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board YELLOW LED
    
    #include <SPI.h>
    #include <MySensors.h>
    #include <AltSoftSerial.h>
    
    //#define NO_RADIO                      (1)       // Define this symbol when no radio is connected
    #define EMETER_TIMEOUT                (600000) // Time between sending the electric meter standings
    
    //  SensorDefinitions
    // #define NODE_ID                       (20)  // Node ID for the Smartmeter node
    #define SENSOR_ID_PLUS_T1             (1)   // Sensor ID for Electric meter, Plus T1
    #define SENSOR_ID_PLUS_T2             (2)   // Sensor ID for Electric meter, Plus T2
    #define SENSOR_ID_MIN_T1              (3)   // Sensor ID for Electric meter, Min T1
    #define SENSOR_ID_MIN_T2              (4)   // Sensor ID for Electric meter, Min T2
    #define SENSOR_ID_CURRENT_TARIFF      (5)   // Sensor ID for Electric Current tariff
    #define SENSOR_ID_CURRENT_USAGE       (6)   // Sensor ID for Electric current usage
    #define SENSOR_ID_CURRENT_PRODUCTION  (7)   // Sensor ID for Electric Electric current production
    #define SENSOR_ID_SWITCH_STATE        (8)   // Sensor ID for Electric meter, switch state
    #define SENSOR_ID_GAS_METER           (9)   // Sensor ID for Gas meter reading
    #define SENSOR_ID_GAS_TIMESTAMP       (10)  // Sensor ID for Gas meter, timestamp of last measurement
    
    #define BUFSIZE 450 // Receive buffer size
    
    
    // Search filters in received data.
    // NOTE: This data remains in Flash!
    const char pT1_Filter[]     PROGMEM ={"1-0:1.8.1("};
    const char pT2_Filter[]     PROGMEM ={"8.2("};
    const char mT1_Filter[]     PROGMEM ={"1-0:2.8.1("};
    const char mT2_Filter[]     PROGMEM ={"1-0:2.8.2("};
    const char cT_Filter[]      PROGMEM ={"0-0:96.14.0("};
    const char cUsageFilter[]   PROGMEM ={"1-0:1.7.0("};
    const char curProdFilter[]  PROGMEM ={"1-0:2.7.0("};
    const char cSwitchSFilter[] PROGMEM ={"0-0:96.3.10("};
    const char cGasMFilter[]    PROGMEM ={"(0-1:24.2.1)(m3)"};
    const char cGasTSFilter[]   PROGMEM ={"0-1:24.3.0("};
    
    AltSoftSerial mySerial;
    
    char buffer[BUFSIZE]; //Buffer for serial data to find.
    
    // Global values
    char          LastGasTimestamp[13];
    int           LastCurTariff=0;
    int           LastSwitchState=0;
    unsigned long lastEMeters=0;
    bool          firstRun=true;
    
    
    // Helper functions
    unsigned long CorrectOverflow(unsigned long newValue, unsigned long compare);
    
    // Gateway send functions
    void SendFloat(int SensorId, int Precision, float Value);
    void SendBool(int SensorId, bool Value);
    void SendString(int SensorId, char* Value);
    
    // Data parse functions
    void ParseCurrentTariff();
    void ParseCurrentUsage();
    void ParseEMeters();
    void ParseGasMeter();
    void ParseSwitchState();
    
    unsigned long CorrectOverflow(unsigned long newValue, unsigned long compare)
    {
      if (newValue < compare)
      {
        return 0;
      }
      else
      {
        return compare;
      }
      
    }
    
    void SendFloat(int SensorId, int Precision, float Value)
    {
      bool bSucceeded = false;
      int ResendCount = 0;
      MyMessage msg(SENSOR_ID_PLUS_T1,V_WATT);
    #ifndef NO_RADIO
      
      while (bSucceeded ==false)
      {
        bSucceeded =  send(msg.setSensor(SensorId).set(Value,Precision));
        if (bSucceeded == false)
        {
          if (ResendCount < 10)
          {
            delay(50);
            ResendCount++;
          }
          else
          {
            bSucceeded = true;
          }
        }
      }
    #endif
      
    }
    
    void SendBool(int SensorId, bool Value)
    {
      bool bSucceeded = false;
      int ResendCount = 0;
      int IntValue=0;
      MyMessage msg(SENSOR_ID_PLUS_T1,V_WATT);
    
    #ifndef NO_RADIO
    
      if (Value == false)
      {
        IntValue = 0;
      }
      else
      {
        IntValue = 1;
      }
    
      while (bSucceeded ==false)
      {
        bSucceeded =  send(msg.setSensor(SensorId).set(IntValue));
        if (bSucceeded == false)
        {
          if (ResendCount < 10)
          {
            delay(50);
            ResendCount++;
          }
          else
          {
            bSucceeded = true;
          }
        }
      }
    #endif
      
    }
    
    void SendString(int SensorId, char* Value)
    {
      bool bSucceeded = false;
      int ResendCount = 0;
      MyMessage msg(SENSOR_ID_PLUS_T1,V_WATT);
    
    #ifndef NO_RADIO
      
      while (bSucceeded ==false)
      {
        bSucceeded =  send(msg.setSensor(SensorId).set(Value));
        if (bSucceeded == false)
        {
          if (ResendCount < 10)
          {
            delay(50);
            ResendCount++;
          }
          else
          {
            bSucceeded = true;
          }
        }
      }
    #endif
    
    }
    
    void ParseCurrentTariff()
    {
      int  curTariff = 0;
      char* index=0;
    
      index = strstr_P(buffer, cT_Filter);
      if (index != 0)
      {
        index+=strlen_P(cT_Filter);
    
        if (sscanf(index,"%d%%*s" , &curTariff) >0 ) 
        {
          Serial.print(F("Huidig tarief:  "));
          Serial.println(curTariff);
          if ((curTariff != LastCurTariff) || (firstRun==true))
          {
            LastCurTariff = curTariff;
            if (curTariff = 0)
            {
              SendBool(SENSOR_ID_CURRENT_TARIFF, false);
            }
            else
            {
              SendBool(SENSOR_ID_CURRENT_TARIFF, true);
            }
            
          }
        }
     
      }
    
    }
    void ParseCurrentUsage()
    {
      long curUsage = 0;
      char* index=0;
      long tl = 0;
      long tld =0;
      MyMessage msg(SENSOR_ID_CURRENT_USAGE,V_WATT);
    
      index = strstr_P(buffer, cUsageFilter);
    
      if (index != 0)
      {
        index+=strlen_P(cUsageFilter);
    
        // 1-0:1.7.0 = Electricity usage (W)
       if (sscanf(index,"%ld.%ld%*s" , &tl , &tld) >0 ) 
       {
         curUsage = tl * 1000 + tld * 10;
         Serial.print(F("Elektra - actueel verbruik (W): "));
         Serial.println(curUsage);
         SendFloat(SENSOR_ID_CURRENT_USAGE, 0, curUsage);
    //     gw.send(msg.setSensor(SENSOR_ID_CURRENT_USAGE).set(curUsage,0));  // Send sensor info
       }
      }
    
      index = strstr_P(buffer, curProdFilter);
      if (index != 0)
      {
        index+=strlen_P(curProdFilter);
    
        // 1-0:2.7.0 = Electricity production (W)
       if (sscanf(index,"%ld.%ld%*s" , &tl , &tld) >0 ) 
       {
         curUsage = tl * 1000 + tld * 10;
         Serial.print(F("Elektra - actueel productie (W): "));
         Serial.println(curUsage);
         SendFloat(SENSOR_ID_CURRENT_PRODUCTION, 0, curUsage);
    //     gw.send(msg.setSensor(SENSOR_ID_CURRENT_PRODUCTION).set(curUsage,0));  // Send sensor info
       }
      }
      
    }
    
    void ParseEMeters()
    {
      float fT = 0.0; //Meter reading Electrics - consumption low tariff
      char* index=0;
      long tl = 0;
      long tld =0;
      MyMessage msg(SENSOR_ID_PLUS_T1,V_WATT);
    
      index = strstr_P(buffer, pT1_Filter);
      if (index != 0)
      {
        index+=strlen_P(pT1_Filter);
    
        // 1-0:1.8.1 = Electricity consumption low tariff (DSMR v4.0)
        
        if (sscanf(index,"%ld%.%ld%*s" , &tl, &tld) >0 ) 
        {
          fT = (tl*1000 + tld) / 1000;
             Serial.print(F("Elektra - meterstand +T1 (Wh): "));
             Serial.println(fT);
          SendFloat(SENSOR_ID_PLUS_T1, 1, fT);   
          //gw.send(msg.setSensor(SENSOR_ID_PLUS_T1).set(fT,1));  // Send sensor info
        }
     
      }
      index = strstr_P(buffer, pT2_Filter);
      if (index != 0)
      {
        index+=strlen_P(pT2_Filter);
    
        // 8.2 = Electricity consumption high tariff (DSMR v4.0)
        if (sscanf(index,"%ld%.%ld%*s" , &tl, &tld) >0 ) 
        {
          fT = (tl * 1000 + tld) / 1000;
          Serial.print(F("Elektra - meterstand +T2 (Wh): "));
          Serial.println(fT);
          SendFloat(SENSOR_ID_PLUS_T2, 1, fT);   
          //gw.send(msg.setSensor(SENSOR_ID_PLUS_T2).set(fT,1));  // Send sensor info
        }
      }
      index = strstr_P(buffer, mT1_Filter);
      if (index != 0)
      {
        index+=strlen_P(mT1_Filter);
    
        // 8.2 = Electricity production high tariff (DSMR v4.0)
        if (sscanf(index,"%ld%.%ld%*s" , &tl, &tld) >0 ) 
        {
          fT = (tl * 1000 + tld)/1000;
          Serial.print(F("Elektra - meterstand -T1 (Wh): "));
          Serial.println(fT);
          SendFloat(SENSOR_ID_MIN_T1, 1, fT);   
          //gw.send(msg.setSensor(SENSOR_ID_MIN_T1).set(fT,1));  // Send sensor info
        }
     
      }
    
      index = strstr_P(buffer, mT2_Filter);
      if (index != 0)
      {
        index+=strlen_P(mT2_Filter);
    
        // 8.2 = Electricity production high tariff (DSMR v4.0)
        if (sscanf(index,"%ld%.%ld%*s" , &tl, &tld) >0 ) 
        {
          fT = (tl * 1000 + tld)/1000;
          Serial.print(F("Elektra - meterstand -T2 (Wh): "));
          Serial.println(fT);
          SendFloat(SENSOR_ID_MIN_T2, 1, fT);
          //gw.send(msg.setSensor(SENSOR_ID_MIN_T2).set(fT,1));  // Send sensor info
        }
      }
    }
    
    void ParseGasMeter()
    {
      char* index=0;
      float fT = 0.0; //Meter reading Electrics - consumption low tariff
      long tl = 0;
      long tld =0;
      bool bSucceeded=false;
      int ResendCount=0;
      char gasTimestamp[13];
    
      memset(gasTimestamp, '\0', 13);
      
      MyMessage msg(SENSOR_ID_PLUS_T1,V_WATT);
    
      index = strstr_P(buffer, cGasMFilter);
      if (index != 0)
      {
        index+=strlen_P(cGasMFilter);
        index = strstr(index, "(");
        index+=strlen("(");
      // (0-1:24.2.1)(m3)\n( = Gasmeter stand
       if (sscanf(index,"%ld.%ld)" , &tl , &tld) >0 ) 
       {
         fT = (tl * 1000 + tld)/1000;
         Serial.print(F("Gas - stand (m3): "));
         Serial.println(fT);
       }
      }  
      index = strstr_P(buffer, cGasTSFilter);
      if (index != 0)
      {
        index+=strlen_P(cGasTSFilter);
        strncpy(gasTimestamp, index, 12); 
        Serial.print(F("Gas - TIMESTAMP: "));
        Serial.println(gasTimestamp);
    //    gw.send(msg.setSensor(SENSOR_ID_GAS_TIMESTAMP).set(gasTimestamp));  // Send sensor info
    
         if (strcmp(LastGasTimestamp, gasTimestamp))
         {
          strcpy(LastGasTimestamp, gasTimestamp);
          SendFloat(SENSOR_ID_GAS_METER, 3, fT);
          SendString(SENSOR_ID_GAS_TIMESTAMP, gasTimestamp);
         }
      }
      
    }
    void ParseSwitchState()
    {
      char* index=0;
      long tl = 0;
      long tld =0;
      int switchState=0;
    
      index = strstr_P(buffer, cSwitchSFilter);
      if (index != 0)
      {
        index+=strlen_P(cSwitchSFilter);
    
        if (sscanf(index,"%d%%*s" , &switchState) >0 ) 
        {
          Serial.print(F("Huidig Switch state:  "));
          Serial.println(switchState);
          if ((switchState != LastSwitchState) || (firstRun==true))
          {
            LastSwitchState = switchState;
            SendBool(SENSOR_ID_SWITCH_STATE, switchState);
          }
        }
       }
    }
    
    void setup()
    {
      Serial.begin(9600);                 // Serial Monitor Baudrate
      
      mySerial.begin(9600);                 // P1 baudrate
                                            // Serial console baudrate for Kampstrup
                                            // Serial console baudrate e.g. Landys Gyr E350 (115200)
                                            // parameter    waarde
                                            // Baud rate    9600
                                            // Data bits    7
                                            // Parity       Even
                                            // Stop bits    1
      
      
      Serial.println(F("Smart meter sensor for MySensors"));
      // Startup and initialize MySensors library. Set callback for incoming messages. 
      memset(LastGasTimestamp, '\0', 13); 
    }
    
    void presentation() {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Smartmeter", "0.2");
    
      present(SENSOR_ID_PLUS_T1, S_POWER);
      present(SENSOR_ID_PLUS_T2, S_POWER);
      present(SENSOR_ID_MIN_T1, S_POWER);
      present(SENSOR_ID_MIN_T2, S_POWER);
      present(SENSOR_ID_CURRENT_TARIFF, S_POWER);
      present(SENSOR_ID_CURRENT_USAGE, S_POWER);
      present(SENSOR_ID_CURRENT_PRODUCTION, S_POWER);
      present(SENSOR_ID_SWITCH_STATE, S_POWER);
      present(SENSOR_ID_GAS_METER, S_POWER);
      present(SENSOR_ID_GAS_TIMESTAMP, S_POWER);
    }
           
    void loop() 
    { 
      unsigned long currentMillis;
      char input; // incoming serial data (byte)
      char* StartofLine=buffer;
      static int bufpos = 0;
      int readval=0;
    
      if (mySerial.available()) 
      {
        input = mySerial.read();    
        // --- 7 bits setting ---
        input &= ~(1 << 7);
        char inChar = (char)input;
        // --- 7 bits setting ---u
    
        buffer[bufpos] = inChar;
        bufpos++;
             
        Serial.print(inChar); //Debug
        if (inChar == '!')
        {
          Serial.println("end of frame!");
          Serial.print("Received: ");
          Serial.print(buffer);
          buffer[bufpos] = '\0';
    
          Serial.print("Length of packet: ");
          Serial.println(strlen(buffer));
          if (strlen(buffer) != 0)
          {
            currentMillis=millis();
            lastEMeters = CorrectOverflow(currentMillis, lastEMeters);
            ParseCurrentUsage();
            delay(20);
            ParseGasMeter();
            delay(20);
            ParseCurrentTariff();
            delay(20);
            ParseSwitchState();
            delay(20);
            if ((currentMillis > lastEMeters + EMETER_TIMEOUT) || (firstRun==true))
            {
              ParseEMeters();    
      
              lastEMeters = currentMillis;
            }
            firstRun=false;
          }
            bufpos=0;
      
        }
        
      }
    }
    ```.

  • Hardware Contributor

    @sincze : Good to see you used my program! 😃 I also changed some things, I added some sleeps in between the presentation messages, as I got a lot of failures during presentation. And I removed all the timers between sending updates.

    Now, I send the current usage and production on every new update, and the rest only when the timestamp of the gasmeter changes (at the start of every hour) I also commented out sending the timestamp of the gasmeter and main switch.


  • Hardware Contributor

    @sincze said:

    Domoticx.com P1
    Maybe the problem is that moving to certain pins is not allowed in the altsoftserial library.

    Why is it "alt soft serial", when there is a "soft serial" library. Does the ALT version use interrupts ? Does it need certain comparator pins related to timers of the atmega328p ?


  • Admin


  • MySensors Evangelist


  • MySensors Evangelist

    @Japio can you share your modification with the timers??

    Funny thing as I have solar panels.
    Today I had -1450 Watt on my Smartmeter and the script shows this as 1450 Watt in Domoticz (so positive) 🍭 Have to look into that this weekend. Maybe I need glasses 😉

    Don't worry if your version is Mysensors < 2.0.0. I will convert it as I need the 2.0.0+ version anyway.


  • Hardware Contributor

    @sincze You can find it on: https://github.com/Japio74/MysSmartmeterGateway

    |t currently already is 2.0.0.

    Enjoy it!



  • I tried to get te script working on a landis gyr e350 connected to an arduino mega. I have inverted the signal and connected it to pin 48 of the mega. The inverted signal shows up correctly if connect it directly to my laptops serial interface so that is working. I read that the DSMR4 protocol uses 115200/8/N/1 in stead of 9600/7/E/1. I cannot get the settings right for AltSoftSerial. Can someone help me modify the script to get the things working?


  • Hardware Contributor

    @rwanrooy : I used AltSoftSerial for the smartmeter sensor, because it has only 1 uart for serial communication, which is used for firmware upload/download. That is why I used the software alternative. But if it actually is the arduino MEGA 2560, it has 4 uarts, one for the firmware download (serial 0), but the other 3 are at your service (looking at the documentation, I don't know the details.)

    These hardware ports should better be able to handle the 115200 baud.



  • @Japio: I quit trying to get it working because some users are reporting sync issues with the arduino internal clock. I managed to get it work with a rs232 to ethernet adapter with a transistor used as inverter. I can connect in native tcp mode in domoticz to the ip adres of the adapter.


  • MySensors Evangelist

    Sorry to bump this all thread back to 2018, but I have a question.
    Is it already possible to use MySensors and this all in one P1 domoticz sensor? (usage1,2 / return1,2)

    The examples I can find create 2-4 new sensors in Domoticz. I'm looking forward to the possibilitie if it can be done with one 😉

    0_1528314100556_All in one p1.JPG

    It can be done with a P1 http request but as a MySenors user I want to do it with mysensors.

    The idea is to use this PCB as P1 and Watermeter 😉
    0_1528314499956_Wemos Smar Water meter.jpg


  • Plugin Developer

    @sincze did you manage to create a nice sketch to read out a P1 device? I'm looking for such a sketch.




Log in to reply
 

Suggested Topics

  • 8
  • 1
  • 1
  • 90
  • 3
  • 44

1
Online

11.2k
Users

11.1k
Topics

112.5k
Posts