UART2 on WROOM driving me crazy
Posted: Thu Jun 24, 2021 8:28 pm
Dear reader,
I have a working ESP8266 reading out my digital electricity meter at 115200 8N1 with softwareserial in mode 'inverted signaling'
There is a hardware inverter installed between meter and ESP8266 ( by means of and BS170 mosfet and a 10k resistor)
As serial bits are inverted by hardware, software serial needs the 'inverted signaling' parameter ON
As said, this is working
As softwareserial isn't the best solution at 115200 baud, I'm missing most of the time a (set of) bits(s), so my checksum (luckly there is one at the end of each stream) is mostly invalid. So 80%-90% of the readings are not usable.
So i'm trying to switch to an ESP32 as these have 3 UART's, so I can use hardware serial. I'm trying to use UART3 (serial2) on standard port GPIO16, as 1 is connected to the USB chip and 2 connected to the flash chip
As hardware serial hasn't the 'inverted signaling' option, I'm not using an hardware inverter ( but a BS170 with 2 resistors as level shifter from 5V to 3V )
As test, I'm copying out each received byte at serial2 to serial(0) so I can monitor via Putty on my PC :
void loop() {
while (Serial2.available()) {
Serial.print(char(Serial2.read()));
}
ArduinoOTA.handle();
}
I receive the stream ( I see it each second appearing in Putty ) but it is completely human unreadable (should be readable). I see it has each time the same ending.
( as example, last bytes :
8b 99 9d a3 97 a3 9f af 8d 8d 8d ab 7d ad e5 eb 9f a5 9f 8b 8d 93 a3 9d 99 a3 9f af ad e5 eb 9f a5 9d 8b 9b 97 a3 9d a3 9f af 9f 9f 99 ad e5 eb 9f a5 9d 8b 8d 93 a3 9d a3 9d af 99 91 97 93 97 79 97 73 99
showing as ‹™£—£Ÿ¯«}å럥Ÿ‹“£™£Ÿ¯å럥‹›—££Ÿ¯ŸŸ™å럥‹“££¯™‘—“—y—s™ )
Does someone has a idea here what is wrong or going on ?
Thanks for any reply !
I have a working ESP8266 reading out my digital electricity meter at 115200 8N1 with softwareserial in mode 'inverted signaling'
There is a hardware inverter installed between meter and ESP8266 ( by means of and BS170 mosfet and a 10k resistor)
As serial bits are inverted by hardware, software serial needs the 'inverted signaling' parameter ON
As said, this is working
As softwareserial isn't the best solution at 115200 baud, I'm missing most of the time a (set of) bits(s), so my checksum (luckly there is one at the end of each stream) is mostly invalid. So 80%-90% of the readings are not usable.
So i'm trying to switch to an ESP32 as these have 3 UART's, so I can use hardware serial. I'm trying to use UART3 (serial2) on standard port GPIO16, as 1 is connected to the USB chip and 2 connected to the flash chip
As hardware serial hasn't the 'inverted signaling' option, I'm not using an hardware inverter ( but a BS170 with 2 resistors as level shifter from 5V to 3V )
As test, I'm copying out each received byte at serial2 to serial(0) so I can monitor via Putty on my PC :
void loop() {
while (Serial2.available()) {
Serial.print(char(Serial2.read()));
}
ArduinoOTA.handle();
}
I receive the stream ( I see it each second appearing in Putty ) but it is completely human unreadable (should be readable). I see it has each time the same ending.
( as example, last bytes :
8b 99 9d a3 97 a3 9f af 8d 8d 8d ab 7d ad e5 eb 9f a5 9f 8b 8d 93 a3 9d 99 a3 9f af ad e5 eb 9f a5 9d 8b 9b 97 a3 9d a3 9f af 9f 9f 99 ad e5 eb 9f a5 9d 8b 8d 93 a3 9d a3 9d af 99 91 97 93 97 79 97 73 99
showing as ‹™£—£Ÿ¯«}å럥Ÿ‹“£™£Ÿ¯å럥‹›—££Ÿ¯ŸŸ™å럥‹“££¯™‘—“—y—s™ )
Does someone has a idea here what is wrong or going on ?
Thanks for any reply !