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 :
should have been
( 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 ) :


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