Code Monkey home page Code Monkey logo

Comments (9)

eschlenz avatar eschlenz commented on July 25, 2024

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.

tuanpmt avatar tuanpmt commented on July 25, 2024

Did you try to increase receive buffer size more than 256 bytes?

from espduino.

eschlenz avatar eschlenz commented on July 25, 2024

@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.

 avatar commented on July 25, 2024

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.

eschlenz avatar eschlenz commented on July 25, 2024

@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.

hukm avatar hukm commented on July 25, 2024

@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.

Namphibian avatar Namphibian commented on July 25, 2024

@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.

hukm avatar hukm commented on July 25, 2024

@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.

Namphibian avatar Namphibian commented on July 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.