Smartmeter sensors
-
@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.
-
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 OhmAnd 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 OhmI 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 3After 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:- Arduino UNO/NANO/MEGA:
- ArduinoIDE software
- ArduinoIDE AltSoftSerial library
- BC547 transistor
- 2x reisistor of 1K Ohm
- 1x resistor 10K Ohm
The building scheme says the opposite.
- 1x resistor 1K Ohm
- 2x reisistor of 10K Ohm
Suggestions are welcome. If this basic script works I am sure MySensors will work as well.
Tnx guys@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 ?
-
@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 ?
Yes, to almost all of your questions.
https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html -
Yes, to almost all of your questions.
https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html@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/ -
@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.
@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.
-
@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?
-
@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.
-
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 ;-)

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 ;-)

-
There are many examples...
https://forum.mysensors.org/topic/3764/p1-smart-meter-nta8130-readout-using-mysensors/7Or 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