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. Smartmeter sensors

Smartmeter sensors

Scheduled Pinned Locked Moved My Project
17 Posts 8 Posters 7.7k Views 8 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.
  • JapioJ Offline
    JapioJ Offline
    Japio
    Hardware Contributor
    wrote on last edited by
    #6

    @sincze : Good to see you used my program! :smiley: 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.

    sinczeS 1 Reply Last reply
    0
    • sinczeS sincze

      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

      GertSandersG Offline
      GertSandersG Offline
      GertSanders
      Hardware Contributor
      wrote on last edited by
      #7

      @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 ?

      hekH 1 Reply Last reply
      0
      • GertSandersG GertSanders

        @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 ?

        hekH Offline
        hekH Offline
        hek
        Admin
        wrote on last edited by
        #8

        @GertSanders

        Yes, to almost all of your questions.
        https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html

        sinczeS 1 Reply Last reply
        0
        • hekH hek

          @GertSanders

          Yes, to almost all of your questions.
          https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html

          sinczeS Offline
          sinczeS Offline
          sincze
          MySensors Evangelist
          wrote on last edited by
          #9

          @hek haha you are fast!.

          I would say @GertSanders I read these articles and was convinced altsoftserial it was for the nano.

          https://hackaday.io/project/95-altsoftserial-arduino-library
          http://forum.arduino.cc/index.php?topic=152122.0
          https://www.arduino.cc/en/Reference/SoftwareSerial
          http://hackaday.com/2012/02/13/altsoftserial-looks-to-speed-up-arduino-software-uart/

          1 Reply Last reply
          0
          • JapioJ Japio

            @sincze : Good to see you used my program! :smiley: 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.

            sinczeS Offline
            sinczeS Offline
            sincze
            MySensors Evangelist
            wrote on last edited by
            #10

            @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) :lollipop: 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.

            1 Reply Last reply
            0
            • JapioJ Offline
              JapioJ Offline
              Japio
              Hardware Contributor
              wrote on last edited by
              #11

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

              |t currently already is 2.0.0.

              Enjoy it!

              1 Reply Last reply
              0
              • rwanrooyR Offline
                rwanrooyR Offline
                rwanrooy
                wrote on last edited by
                #12

                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?

                1 Reply Last reply
                0
                • JapioJ Offline
                  JapioJ Offline
                  Japio
                  Hardware Contributor
                  wrote on last edited by
                  #13

                  @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.

                  1 Reply Last reply
                  0
                  • rwanrooyR Offline
                    rwanrooyR Offline
                    rwanrooy
                    wrote on last edited by
                    #14

                    @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.

                    1 Reply Last reply
                    0
                    • sinczeS Offline
                      sinczeS Offline
                      sincze
                      MySensors Evangelist
                      wrote on last edited by
                      #15

                      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

                      1 Reply Last reply
                      0
                      • alowhumA Offline
                        alowhumA Offline
                        alowhum
                        Plugin Developer
                        wrote on last edited by
                        #16

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

                        1 Reply Last reply
                        0
                        • electrikE Offline
                          electrikE Offline
                          electrik
                          wrote on last edited by electrik
                          #17

                          There are many examples...
                          https://forum.mysensors.org/topic/3764/p1-smart-meter-nta8130-readout-using-mysensors/7

                          Or on GitHub, needs some tinkering to integrate in mysensors

                          https://github.com/search?l=C%2B%2B&q=P1+meter&type=Repositories

                          Edit
                          There is also a library available
                          https://github.com/matthijskooijman/arduino-dsmr

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


                          6

                          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