Comments (9)
I too have issues with messages coming in in rapid succession. In my case, the Arduino completely freezes up. I've narrowed the down to the espduino Library (IOTW: not my code). I'm not entirely sure why it happens, but I suspect it may be related to @hackscribble's issue.
from espduino.
Did you try to increase receive buffer size more than 256 bytes?
from espduino.
@tuanpmt No, I did not try that, but thank you for your reply as it led me to a solution.
I looked around in the espduino code for the default buffer size. I think I found it, and I believe it was 512 bytes (?). Which should have been sufficient for my needs.
In debugging my sketch, I found that my available memory was less than 400 bytes. I rearranged some object allocations to free up memory, and now hover around 900 bytes free. I would assume that the 512 bytes for the buffer are allocated only once. Freeing up more memory, however, DID seem to solve the problem for me.
I ran some more tests to see what happened when I sent multiple messages in rapid succession. My sketch no longer crashes. The worst result I got was a momentary freezing of the loop(), followed by an invalid CRC error. It then recovered on it's own. The messages I receive are not mission critical. It will be rare for me that many messages come in rapid succession, and if the worst I get is a random invalid CRC, so-be-it. Good enough for my needs.
from espduino.
Thanks @tuanpmt for the suggestions about memory. I tried those but it did not help. And reducing the size of my topic titles and data made no difference either.
But that go me thinking that maybe I was seeing a timing problem, not a memory problem. The symptoms were consistent with the code not being able to keep up with the speed at which new messages arrive.
So I looked at the mqttData
callback. It had several calls to SoftwareSerial. Also, I am running the debug version of the firmware, so that sends its own messages to SoftwareSerial. I commented out a couple of my debug print statements and the problem has gone away.
I'll experiment with the no debug firmware and putting my print statements back in. But I'm going to close this issue.
Many thanks.
from espduino.
@hackscribble Good call. I have quite a few Serial print statements in the same place, and I too am running the debug version of the firmware.
from espduino.
@tuanpmt , hello!
I have faced with quite a similar problem. I am sending mqtt messages from Arduino with ESP as a bridge and after successful 2-3 messages in a row connection between device and broker is lost.
I have increased time delay between messages from 1 second to 20 but same situation appeared. I have tried to clear some more space in Arduino sketch but that didn't help either.
Is there any command to clear buffer on ESP because it seems to me that the problem is on that side? Any suggestions?
Thank you!
from espduino.
@hackscribble @eschlenz @tuanpmt
Was running into the same issue using a Nano and debug software. Due to the number of sensors I must support I had the hardest time getting memory consumption low. Eventually I also got the CRC error in the loop and then it would process again. Thus it would lock up intermittently and then process again. I tried the following serial buffer sizes 16,32,64,128,256,512, I also removed a lot of debug statements.
I suspect my problem was exasperated due to the amount of other libraries in my sketch.
I suspect the debug firmware and debug output statements might be causing an issue where the serial buffers are causing the arduino to wait for some end of line/end of packets this buffer keeps on getting filled and when the arduino finally get the missing eol character it does a crc check. This crc check fails but since the message is complete the arduino can then processes as per normal.
When I changed over to the production version of the firmware the problem seems to not occur. I will do some more testing.
This is all just a hunch though.
from espduino.
@Namphibian
I have switched to production version of firmware and increased both HardwareSerial and SoftwareSerial up to 512 as well. But the problem still occurs after 20 minutes of sending information each second.
As for me it is almost fine but however I want to see completely running device without any mistakes
from espduino.
I was using the ESP-01 variant for initial testing as it is just easier to connect. I have now moved to the ESP-07 variant and this problem seems to have vanished. Well based on my tests now I cannot see the system freezing when sending/receiving messages in a 1 second interval for 15 minutes there was a slow down and things got queued but nothing like the lock ups I saw before. This evidence is only anecdotal and once I have done some more testing I will confirm this.
from espduino.
Related Issues (20)
- Timeout with local http servers (Python, Ruby, Node) HOT 3
- MQTT Topic depth? HOT 3
- When I upload software to esp8266 I get an error that is below. Please help me !!!. HOT 2
- Error "'ESP' does not name a type ESP *esp;" HOT 3
- HTTPS Rest API HOT 6
- ESPDuino hang on ESP:process HOT 12
- Using both REST and MQTT results in error HOT 1
- Is there any timeline for the WiFi AP portion? HOT 2
- mqtt.publish from the call back void mqttData(void* response) gives unpredictable result
- malloc assert! HOT 2
- SoftwareSerial as esp serial? HOT 1
- Unable to communicate HOT 6
- Help sending multiple publish (MQTT,Bridge) HOT 2
- AT Command Not Working
- Unable to Set Qos 1 or 2 while Subscribing. HOT 1
- Connect/disconnect loop without pulling down any change info;
- Getting Garbage after esp.ready() HOT 2
- does not work
- How to read MAC of ESP8266?
- How to work on Arduino Mega.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from espduino.