fliphess / esp8266_p1meter

dsmr 4.2 P1 meter to mqtt using esp8266 nodemcu
GNU General Public License v3.0
69 stars 114 forks source link

Switch to HardwareSerial for DSMR5 #9

Closed daniel-jong closed 3 years ago

daniel-jong commented 3 years ago

This change should add support for newer meters using the DSMR5 protocol. See https://github.com/fliphess/esp8266_p1meter/issues/7

This PR also contains:

daniel-jong commented 3 years ago

Before merging this back maybe we should create a branch of the current master? Because of changes to the pinout it might be nice to maintain that source and README. That way we can update the changed Readme after this PR to include a link to that branch.

fliphess commented 3 years ago

Hey @daniel-jong, thanks a lot for merging this back to me, it's a great improvement over the old sketch :)

I've created a dsmr2.2 branch for the older version and created a tag (0.0.1) containing the current state.

I'll have a look and do some testing with a long power cable running through the hall to see if it works :)

fliphess commented 3 years ago

I've merged your changes into the development branch so I can do some testing. Question: Are you disconnecting your resistor when uploading a sketch? I'm experiencing some issues uploading to a nodemcu as the serial port seems to be buggy while uploading.

daniel-jong commented 3 years ago

I mostly have been using over the air updates for the last couple of updates. Maybe we should update the code to wait a couple of seconds before setting the Hardware serial as inverted. I can imagine the serial inversion on de RX causing issues if the nodemcu has not properly been put into its bootloader mode.

I'll try this weekend to see how/if this works on my hardware...

fliphess commented 3 years ago

I think it has something to do with the differences between the D1 and the nodemcu, as the D1 has 2 fully functional uart ports and the nodemcu only one and a semi functional one.

I'll see if I can get it to work on the nodemcu using a similar mechanism you found to swap the serials and otherwise I'll update the instructions to use a D1 instead, which is fine too.

daniel-jong commented 3 years ago

I've tried to reproduce the upload issue you ran into but have not been able to reproduce it so far.

Regardless it should be easy to change the code a bit so that the inversion of the RX is done at a later time. Like at the end of the setup() method, maybe even after a small sleep period. This might help this to enter flash mode.

Let me know if any of this helps, else I might look into buying a NodeMcu to investigate a bit more. This is an interesting issue and those boards are quite inexpensive.

daniel-jong commented 3 years ago

Small update: I've bought an nodemcu v2 with cp2102 for its usb. It should arrive in about a month, after whitch I'll inventigate this.