-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SoftwareSerial: wdt reset #1426
Comments
Ah, too bad, also when I use I think I can better leave the github version for now, 2.0.0 is more stable on this. |
Please supply some code and information about baud rate and traffic volume |
After more investigation, the title can be changed to "SoftwareSerial wdt reset".
Pin D2 is connected to my "Smart Meter", which generates a 27 lines, all terminated with \r\n. Sometimes there is some garbage, and sometimes no \r\n is received, so I have a timeout (2mSec) and a filter (c = 32-127). Earlier I tried ReadBytsUntil, it also crashed. Also tried with a shorter timeout, using micros() and a value of 500. After running for a couple of minutes, mostly less then an hour, it crashes with a WDT reset. |
This is a rather large burst of interrupts. Try using something like the code below which intends to read all the lines into a buffer and then treat the lines in the buffer afterwards
|
BTW, which version are you using? |
I think when I read all lines into one large buffer, it will still going to crash after some time. BTW: When I use DE 1.6.5 with esp8266 2.0.0 Stable, it runs fine for as long as I let it run. (I think, not for sure, I started with softwareserial 2.1.1 or 2.2) |
I have changed the code, to get the whole telegram before continuing:
No luck after a while:
Second attempt, boot mode:(1,6) |
Having the resets with: Works with SoftwareSerial 2.1 and all IDE, and all ESP libs. |
@plerup I also tried your code example from 2 days ago. It was running for over an hour without a reset. (perhaps I should find time to let it run longer)
To:
WDT reset within a couple of minutes. EDIT: Noo, too bad.
|
So today I tried it with a hardware intverter and set the "inverted" flag to "false" in softwareserial. |
Hi,
Into the SoftwareSerial that I use. The SoftwareSerial I have has this constructor:
I have had problems using SoftwareSerial library. What is the fourth argument used in this builder - MAX_SIZE ? |
I use the latest mentioned here: https://github.com/esp8266/Arduino/blob/master/doc/libraries.md#softwareserial
|
Thanks. |
@odilonafonso The SoftwareSerial you are referring to is the AVR version. If you are using the staging release of esp8266/arduino you will automatically get the correct version |
@supersjimmie The only reason I can think of for your problem is if there are a lot of data coming in a burst or if there are some noise on the GPIO pin. In those cases there will be constant calls to the interrupt routine and yielding will not occur before the watchdog resets the chip. You could try disabling the watchdog but then your WiFi will probably be flaky. |
I don't think it is noise, but you may be right that it has something to do with the amount of data. If it was noise, the data would be corrupted but it is very clear data. As far as I understand now, the crashes occur if I do just any small other thing while there is data coming in. Even just printing the received character makes it all instable.
I also noticed that I had to use enableRX(false) to avoid the interrupts when my code it doing something else (like sending data the the logging server) while new data is coming in on the line. |
@supersjimmie if you are using SoftwareSerial (and your reference to D2 rather than GPIO X) does that mean you are using an ESP with an Arduino rather than the ESP as an Arduino? |
No I only use an ESP8266. Here to be precise: https://github.com/esp8266/Arduino/blob/master/variants/nodemcu/pins_arduino.h#L37-L59 |
So neither Arduino with ESP or ESP Standalone, more a hybrid the NodeMCU? |
NodeMCU is just an ESP12 on a board with some extra features. |
@plerup disabling the WDT before this function and re-enabling it afterwards does not solve it, it even seems worse. |
Same problem occurs here, though that may be explained given that I run a modified version of supersjimmie's code. Reboots mostly with error "rst cause:4, boot mode:(3,6) wdt reset". My environment is the latest github release of the esp8266 framework and espsoftwareserial 2.2, compiled with the platformio IDE environment. The board I use is an Wemos D1 Mini. |
@supersjimmie - maybe you've already ensured power, but don't take the power requirements lightly. I was able to perform firmware updates and program my ESPs without problem. Running them is a different story! :-P I cannot stress enough, make sure you have plenty of power to your ESP. I don't feel an Arduino can supply the needed power. I also order 5v - 3.3v converters so I could use the Arduino's power connectors. Very hit and miss. Sometimes it worked, other times it fails and that tends to lead to experimentation with the sketch or pin connections. Of course, ESPs are rated at 2.7v to 3.3v or something like that, but they draw upwards of 250ma. The Arduino cannot supply that. Also, many FTDI adapters only pull 100ma from the USB conn. Some pull 500ma. I forget what the determination is there... I ordered some power supply units for my breadboards. Several types that I wanted to try out. They would not all work - I received the same wdt resets you are getting. Replace the power supply with an a different one and it works fine. A sure fire way for me was with a regular 9-volt battery. After I realized how power-hungry these ESPs are I've been making sure my power supply is always adequate. I can't tell you how much more reliable things have been in the regards to unwanted resets and non-responsive ESPs. Despite this, I still have to make 3, 4, or even 5 attempts to get a sketch uploaded to them. They work fine - but they really are buggy. Keep that in mind. The wdt reset problem though may be due to power. Just a thought! |
@rwkiii Yes I know about power. The ESP can run fine for hours and even multipe days when I work-around the problem and it will fail within minutes when I use the problematic code. There is much more code running on it, it just files here and nowhere else. |
Yes, let's to bring this thread on track. These are the facts: SoftwareSerial is depending on interrupts on the Rx pin. If these are coming in constantly e.g. during a burst of many characters, all cpu time will be spent in the interrupt routine. Subsequently the hardware watchdog will not be feed and hence will reset the ESP once the its max time has elapsed. To my knowledge there is no way to disable the hardware watchdog, only the software one. The only solution I can think of would be to let SoftwareSerial disable the interrupts after a certain time, or when the buffer gets full. Either way characters will be lost. If anyone has any better solution feel free to send pull requests. I guess we all have to look forward to the ESP32 where all WiFi and BT communication will be handled in a separate cpu. |
Is this really such a big burst then?
350 chars at 115k2 would be just about 3mSec, that's not really long? But what's strange, or may bring a solution, it seemed to be working with the Stable 2.0.0 core esp8266/arduino. But I'm not absolutely sure about that (must think about a thorough easy way to test that again). |
Note that the HW watchdog is set to trigger in 6 seconds by default, so these watchdog resets you are seeing are not directly caused by a long chain of interrupts. Looks more like some lock-up, i.e. an endless loop within an interrupt. |
As you can see in the crashing examples above, I don't think there is a problematic loop? |
I also can confirm softwareserial is causing my esp to have watchdog timeouts every several hours. It occurs with read and write of software serial. logging: ets Jan 8 2013,rst cause:4, boot mode:(1,6) wdt reset |
@jeroenst, do you still have issues when using SoftwareSerial? I did what @LuisVSa recommended and it works like a charm. Until now, it has been working for more than 2 days in a row without any crash. Can you confirm that your system crashes also when sending? |
@alexgrauer Allen |
Thanks @allene222. My system is actually using Hardware Serial for debugging, and two different Software Serials two connect to different peripherals. So far, so good! |
@alexgrauer I don't know as I quit using SWSerial both Tx and Rx at the same time. |
I switched to hardware serial which solved all my problems, I now have an uptime of 20 days. |
That's great @jeroenst. |
That is great news!! |
@alexgrauer Perhaps I misread your post. You said it has been working for 2 weeks but the "until now" made me think it is no longer working. Working until now... Perhaps you are saying it is working fine and has for 2 weeks. Just to be clear, you are using the @LuisVSa for Rx and SW Serial for Tx and everything works fine. I think I am out of IO pins so I will continue to share Serial 1 for debug and my Tx needs. But the next project might be different so I try and keep up on what works and what doesn't. |
@allene222, sorry about the confusion. Im a Spanish speaker trying to make sense in English, haha.
I read the entire file, and setting Rx to -1 makes every piece of code related to Rx not to run. |
Hi everybody, |
Hi @tzanampeths, This is the way I've done it. Not sure if its the most efficient one, but it works. (BaudRate: 9600)
pinMode(SIM5320_SERIAL_RX_PIN, INPUT_PULLUP); timer1_attachInterrupt(onTimerISR);
#define SOFTWARE_SERIAL_BUFFER_SIZE 500 char. SOFTWARE_Serial_Rx_Buffer[SOFTWARE_SERIAL_BUFFER_SIZE]; uint8_t SOFTWARE_Serial_Bits_Received = 0;
void ICACHE_RAM_ATTR onTimerISR(){ void NODEMCU_External_Interrupt_Handle() { Let me know if you have any doubt. |
Thank you very much @alexgrauer ! |
Sorry for my miscommunication, but what mean "SOFTWARE_Serial_Active_Pin"? I use GPIO 13 as SIM5320_SERIAL_RX_PIN and GPIO15 as SIM5320_SERIAL_TX_PINK, but where active pin? Sorry for dummy question. I am a beginner. |
Sorry about that. The SOFTWARE_Serial_Active_Pin is there because I was trying to use this method for two different SoftwareSerial communications at the same time. Change all occurences of SOFTWARE_Serial_Active_Pin for SIM5320_SERIAL_RX_PIN. Good luck, and let me know if it worked. |
@alexgrauer when I change Sowtware_active_pin on RxPin, but data transfer from the GPS module does not occur. Me only need to receive the data. Can you explain why? |
Hi @mike89klein.
|
Hi @alexgrauer |
Have you tried using the NEO-6M module using the software serial library, without using my code? You should go for that first and get it working. Once that works go for my code. https://www.youtube.com/watch?v=iWd0gCOYsdo https://www.instructables.com/id/How-to-Interface-GPS-Module-NEO-6m-With-Arduino/ |
@alexgrsuder Yes, I use this module early with library TinyGPS, but for my programm need parsing without special library. And when I create project and run the programm, after some time get error: rst cause 4, boot mode (1,6). I use your fix, but in line "SoftwareSerial SIM5320_Serial(-1, SIM5320_SERIAL_TX_PIN)" instead of "-1", I wet SIM5320_SERIAL_RX_PIN. I use one Softserial. |
You can not use: If you want to use the code I've made, then you have to use The code is actually doing the job of receiving the serial information instead of the library. |
@alexgraurer you use code with SoftwareSerial library by plerup or Arduino integrated? And if eds dont receive information from gps with this code, then me need change some parametres NEO-6M? |
Honeslty, its hard to help without seeing any code. |
@alexgraurer can I ask your mail? |
//edit by devyte |
Agreed. Closing due to age. |
I use both SoftwareSerial and WiFiClient.
During normal operations, it sometimes works for many hours but other times it gives a wdt reset.
This looks like it has a relation between SoftwareSerial and WiFiClient.
If I use mySerial.enableRX(false) before starting the function with the WiFiClient, it seems to keep working, otherwise it looks like to crash on different places.
ets Jan 8 2013,rst cause:4, boot mode:(3,6) wdt reset
This was during client.print() operations, the first client.print with the data succeeded, then just after that, only when sending an empty line with
client.print("\r\n")
it gave the wdt reset.But earlier, it was just during receiving data on the SoftwareSerial:
`ets Jan 8 2013,rst cause:4, boot mode:(1,6)``
And a couple of other times also during normal receiving on the serial:
ets Jan 8 2013,rst cause:4, boot mode:(3,7)
So many different boot modes, they all seem only to occur if I don't use the
mySerial.enableRX(false)
.Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: