So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By bdepauw
#85426 Hello All,

Im using an LoLIn ESP8266 nodemcu to read out my digital (electricity and gas) meter via
#define SERIAL_RX D7 // pin for SoftwareSerial RX
SoftwareSerial mySerial(SERIAL_RX, -1, true, MAXLINELENGTH); // (RX, TX. inverted, buffer)

But most of the readings ( 1 per second and software serial speed is 115200 ) always contain one or some mis readings. I only have 1 correct reading in about 10 to 30 readings ( luckly there is a CRC)

See example below :
0-1:24.1.0(0p3)
should have been
0-1:24.1.0(003)
( in human language : current consumptions is 003 amperes )

One compleet reading looks like this (I removed or modified some lines as these are id's ) :

1-0:1.8.1(000155.825*kWh)
1-0:1.8.2(000115.526*kWh)
1-0:2.8.1(000029.778*kWh)
1-0:2.8.2(000013.810*kWh)
0-0:96.14.0(0001)
1-0:1.7.0(00.562*kW)
1-0:2.7.0(00.000*kW)
1-0:32.7.0(228.0*V)
1-0:31.7.0(002*A)
0-0:96.3.10(1)
0-0:17.0.0(999.9*kW)
1-0:31.4.0(999*A)
0-0:96.13.0()
0-1:24.1.0(0p3)
0-1:96.1.1(123456789)
0-1:24.4.0(1)
0-1:24.2.3(123456789)(00161.732*m3)
!4249
===INVALID CRC FOUND!===

I know software serial isn't ideal for such high speeds, but as far as I untherstood I don't have an alternative here as the uart is used/connected by/to the USB chip ( and swapping to the uart data control lines didn't work for me)

Do you thing I'm running here to the limit of the software serial capacity ?
Or should there still be somewhere a solutions ?
Seems to me that timing isn't just correct or a bit off ?

PS : my sketch is a deriviate from
https://github.com/jantenhove/P1-Meter-ESP8266/blob/master/P1Meter.ino
( Thanks Jan ! Bedankt Jan Ten Hove voor dit mooi stukje programeerwerk !)

Already thanks for all reactions and replys !
User avatar
By StanJ
#85665 You're probably experiencing a difference in baud rate between the two devices. Serial must have the two data rates within ~5% of each other or it can't sync reliably.

I haven't investigated the serial port yet, but try knobbing the baud rate up or down in 1% increments until you see stable data. If it's worse a bit higher, then start heading lower. You should find a range that they'll reliably talk at, so set the baud rate to the middle of that range. That's the best you can do without an oscilloscope (preferred) or decent logic analyzer to see what's going on there.

The problem could be either the power meter -or- the cheap crystal on the ESP8266 module. You can't change the power meter, so start with the bits you CAN change. It's been a SERIOUSLY long time since I've seen two serial devices that wouldn't communicate, but then again all of my designs used crystals from prime manufacturers with *real* specs, not from some unknown garage-operation in Shenzen.

Additionally, at 115K you'll have to keep the wire length below two meters, I'd have to guess. Don't even think about trying to push 115K down 10 meters of wire: it won't get there. If your wire is wonky or high capacitance, that'll mess up the data as well.