Having difficulty with emonTH firmware baudrate

I’ve uploaded the github firmware to Emonth v2, changing only Serial.begin(9600);

After changing node id and group id, and saving to eeprom, the output from serial port is:

> Executing task: platformio device monitor <

> --- Miniterm on /dev/cu.usbserial-FTGCYDST  9600,8,N,1 ---
> --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
> OpenEnergyMonitor.org
> emonTH FW: V323
> Loaded EEPROM RF confiOpenEnergyMonitor.org
> emonTH FW: V323
> Loaded EEPROM RF config >
> Int RFM...
> RFM Started
> Node: 20 Freq: 433Mhz Network: 200
> Int SI7021..
> SI7021 Started, ID: 21
> SI7021 t: 24.35
> SI7021 h: 58.02
> No DS18B20

> '+++' then [Enter] for RF config mode
> waiting 5s...
> temp:␂␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀�jd�temp:␂␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀��jR�temp:␂␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀��jR�temp:␂␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀�j��temp:␂␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀�j��temp:␂␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀�j��temp:␂␀␀␀␀␀

As you see, the temperature and humidity is read ok, but only on the setup() funcion. After that, the sensor is not found anymore. I suspect because of the power saving routines do not bring it up again.
I’ve tried uploading with the Arduino IDE (which is what I’m used to) and then thought that some libraries would not be updated, so I’ve tried PlatformIO IDE with vscode.
The project builds and uploads correctly, but the emonTH v2 still fails the same way.

I’m confused, because the other emonTH v2s I have, which I’ve not touched, are reporting temp and humidity correctly.
Maybe the code on GitHub is not the same that is preloaded on emonTH?
Has anyone uploaded the code and had no issues?

The reason to change the code is that I’m planning to put a CO2 sensor on the emonTH, so I really need to solve that problem.

Thanks.

It looks like an issue with the serial transmission. Is there a reason why you changed to 9600 baud? Could you try changing back to 115200 baud? Have you got a different USB to UART adapter you could try? What serial terminal are you using?

Either way the data should still be transmitted via RF correctly. Can you receive the data from the emonTH on an emonPi / emonBase to verify if the temp / humidity sensor is indeed working in the loop?

Hi Glyn, and thanks for that rapid response.

You where right, changing back to 115200 resolves the problem.
I’ll try with another adapter I think I have somwhere. Didn’t tried with emonpi, but I’m sure It works. Now I see that the error was in a Serial.print line, not in the SI7021 routines
The reason to change it to 9600 was that I can’t find the way to change baud rate on serial monitor on platformio IDE (with vscode), which defaults to 9600. (if someone knows how to do it, feel free to reply).
Also 9600 is what I’m used to do in ardino ide,

Anyway, I’ve tried with external Serial Tool out from vscode and It works for 115200. This is the data received (as expected)

OpenEnergyMonitor.org
emonTH FW: V323
Loaded EEPROM RF config >
Int RFM…
RFM Started
Node: 20 Freq: 433Mhz Network: 200
Int SI7021…
SI7021 Started, ID: 21
SI7021 t: 24.28
SI7021 h: 49.88
No DS18B20

‘+++’ then [Enter] for RF config mode
waiting 5s…
temp:242,humidity:498,batt:6
temp:242,humidity:499,batt:6
temp:242,humidity:515,batt:6
temp:242,humidity:543,batt:6

If someone has the same issue with 9660, reply, please. I think it shouldn’t matter if it is 9600 or 115200…

I have an issue with Platformio - it moved files and directories around on my machine without asking and without telling me, and that’s completely unacceptable. I can’t use ill-conceived software that behaves in that way. I know it is recommended as the latest and greatest, but I cannot share that opinion. I retain and continue to use the Arduino IDE. If you want installation details for the libraries, feel free to ask.

The problem with 9600 baud vs 115200 is most likely because the 9600 baud transmission simply takes too long (and it uses interrupts) so if something time-critical happens after the “send” routine returns but while the message is still in the process of being sent, then it could well be corrupted.

Ok, Thanks Robert,
I also feel more confortable for the moment with arduino IDE, but sure I’ll give a try. Arduino IDE lacks of some features like code completion that are desiderable to an IDE.
As there are 2 options to use platformio (vscode and atom), can you tell me in what option did you had the problems?

Thanks.

No - I used the defaults.
It would have been acceptable had it asked, or given me an option, or reported what it had done. But it didn’t. That’s malware in my book.

I use an external editor with the Arduino IDE (Geany or even Notepad++ via Wine) and both those are significantly more friendly - or familiar - than the inbuilt one. I’d much prefer not having code completion to having my machine screwed up.

It shouldn’t do this. I have never experienced this. I would be happy to help solve any issues. I have found platformIO to be very well engineered. The PlatformIO community and documentation is fantastic. Best start a new thread.