OTGW does not respond to commands

This Forum is about the Opentherm gateway (OTGW) from Schelte

Moderator: hvxl

Post Reply
mvdnes
Starting Member
Starting Member
Posts: 4
Joined: Sun Aug 07, 2022 12:38 pm

OTGW does not respond to commands

Post by mvdnes »

I have a problem with my OTGW that I cannot seem to figure out.

My OTGW PIC does not seem to respond to any commands received from the serial input... sometimes. Serial output works fine. Running otmonitor I get regular updates from my thermostat and boiler. However, sending a command such as PR=A does not produce any response, not even an error message.

Powercycling the device sometimes restores the behaviour, and I will get the expected responses to commands for a while. Shorting the reset pins seems to be a more reliable method of restoring full communication.

I tried to troubleshoot the issue by connecting an FTDI cable directly to the input pin of the PIC, while also having it connected to an ESP8266. Although the PIC did not respond that time, I could see that it received the commands physically at the correct baud rate.

Suspecting a hardware fault, I already replaced my P16F88 running 5.4 with a P16F1847 running 6.1. This did not have any observable effect.

My setup is a V2 gateway from NodoShop (bought in 2017, revision 0.9.9.3), and I normally have it connected via a NodeMCU.
Connecting it directly via an FTDI cable gave mixed results. One time, it just produced an endless stream of 'SE' messages, without even having sent a command, but other times (after resetting) it does work as expected.

I think I already came across this issue at least a year ago, but it became more noticeable last month as the Home Assistant integration now refuses to work without receiving a response.

Can anyone help me troubleshoot this issue?
hvxl
Senior Member
Senior Member
Posts: 1965
Joined: Sat Jun 05, 2010 11:59 am
Contact:

Re: OTGW does not respond to commands

Post by hvxl »

This sounds like the serial receiver may have stopped working, possibly due to some error resulting from noise on the line. It would be interesting to figure out what the RCSTA register contains when the problem happens. To investigate that, use the DP=18 (P16F88) or DP=19D (P16F1847) command. Clearly, you will have to issue that command when the OTGW still works. Then wait for the problem to happen again.
Schelte
mvdnes
Starting Member
Starting Member
Posts: 4
Joined: Sun Aug 07, 2022 12:38 pm

Re: OTGW does not respond to commands

Post by mvdnes »

Thank you for your response.

When it works, I receive '19D=90'.
Unfortunately, the debug output is not available after a power-cycle. I guess it is not possible to trigger a debug flag on boot, or via a GPIO?

Removing power from the PIC and then powering it again seems to be the most reliable method of reproducing the issue, but then I do not have the debug output.
Resetting the PIC by shorting the RST to ground seems to be a good method in fixing it. Could there be something that is not properly initialized during first boot, or some code that is not run properly when power is first applied?

I will run the the unit for a bit with the debug enabled, but it might take a while in this state, if ever, for it to work.
hvxl
Senior Member
Senior Member
Posts: 1965
Joined: Sat Jun 05, 2010 11:59 am
Contact:

Re: OTGW does not respond to commands

Post by hvxl »

When an ESP8266 boots, it sends some debug messages at a very weird baud rate of 74880. I know the OTGW doesn't like that. I haven't taken the time to investigate why the code I thought should handle such situations doesn't work properly.

What firmware do you use on the NodeMCU? Both my otgwmcu firmware and Robert van den Breemen's NodeMCU firmware work around the issue by resetting the PIC during the ESP8266 program startup. If configured correctly, the ESPEasy firmware will also reset the PIC. You specifically need the "Reset target after boot" setting.

If the ESP8266 firmware you use doesn't reset the PIC, then you will likely see the issue on power up, and when the ESP8266 boots for some other reason. Does that match your observations?
Schelte
mvdnes
Starting Member
Starting Member
Posts: 4
Joined: Sun Aug 07, 2022 12:38 pm

Re: OTGW does not respond to commands

Post by mvdnes »

The firmware I was running was a program I made myself in the Arduino IDE, as I wanted to combine it with something else.
Adding in a few statements to assert and release the reset line via GPIO 14 seems to have fixed the problem.

Thank you very much for the help and the pointers to this direction!
hvxl
Senior Member
Senior Member
Posts: 1965
Joined: Sat Jun 05, 2010 11:59 am
Contact:

Re: OTGW does not respond to commands

Post by hvxl »

Your question pushed me to finally investigate what is going on with the ESP8266 debug output.

What happens is that after a power up, the OTGW waits one second for a self-programming start character. Within this one second, the ESP8266 starts spewing its debug messages at 74880 baud. This causes a framing error. But the self-programming code doesn't check that. It just finds a character that is not the self-programming start character and returns. The normal OTGW code then starts. When the PIC initialization code has finished, the ESP8266 has already sent more data, which was not handled in time, resulting in an overrun error. This prevents any more data being received. The interrupt flag never gets set anymore, so the code to handle the framing error doesn't get executed.

I could reproduce the problem every time on power up, but never by just resetting only the ESP8266. So it seems that the code for handling framing errors works in principle. There is only a problem when the framing error happens in the self-programming code. This is easily rectified: The normal OTGW code just has to clear the RCSTA register, resetting the UART, before it (re-)configures the serial interface. With that change, the OTGW now starts correctly, even without the ESP8266 resetting the PIC.
Schelte
mvdnes
Starting Member
Starting Member
Posts: 4
Joined: Sun Aug 07, 2022 12:38 pm

Re: OTGW does not respond to commands

Post by mvdnes »

Great to hear!
This coincides with my experience, that it only seems to occur when both the PIC and ESP boot at the same time.
Post Reply

Return to “Opentherm Gateway Forum”