Arduino MEGA lost connection to Thinger once in a while

Hi, I am new to this Thinger platform, and I have met with this problem which is sometimes the connection with Thinger will be lost once in a while.

I am using MEGA + ESP8266 as WiFi module. Basically what I am doing is to collect information from a bunch of sensors for some time. I did not notice this problem until I checked with the data after I left the MEGA overnight.

Example showing the problems I faced is here. Can anyone help to explain?

Also, when I left the MEGA for a long time, sometimes, the dashboard will freeze, there will be a time on the top right corner of my widget, and when i click on the widget, the MEGA would not respond. Sometimes refreshing the browser solves the problem, but most of the time I need to give the MEGA a reset to solve the freezing issue. Does anyone face this as well? Could it be problem with my browser? or is it something related to hardware?

Thank you if you can help me with this. I can provide the code if you want.

Is it so diffcult for you to catch the debug output?

Maybe the issue is that the device losses connection to the server by any reason and hangs trying to connect again, and that’s why gets “ffreeze”.

when it is freeze, can you se it online? in the device’s dashboard?

Hi, ega, the debug output is here.

What I mean by freeze is, the line [THINGER]: Writing Bytes … these few lines stop sending, and my whole line from

< led1 led2 motor > to < Temperature → 28.10 C >

also stopped sending (they are data collected from another arduino UNO that acts as slave and are suppoed to be sent continuously to MEGA that acts as master which is connected to thinger). They are just simple communication that should not have problems. So from what I see, the program freezes. Feels like it could be stuck when trying to send some new lines of Thinger code. (I am not sure, cuz there is not way to test it). It happens once in a while and a reset fixes this problem (somewhat a short term solution).

Ya, as you can see there, when the program freezes, the whole dashboard displays the mega as offline.

Hi,

As the debug shows, the microcontroller keeps working after the thinger lines are sent, I see that the device hangs after the “temperature” message, and according the previuos messages it cannot reach the “led1, led2, motor” state message, I doubt that the issue is related with the thinger process.

Hope this helps.

Hi, I am here again to test the MEGA + ESP setup.

I have get some coding to try to debug whether it is my local connection problem or thinger side problem. I have left the local communication to run for like 2 nights, there is no drop of connection or anything. So I proceeded to test the Thinger side buy putting serial print line after the thing.handle() code. I could not recreate the problem consistently, so I try to get any available data when it occured.

So here is scenario 1, which is a rare case (almost every time it did not continue after stopped printing to serial monitor) in which the esp suddenly responded after being dead at the line thinger.handle() between 18:48:15.863 and 18:48:19.653, it returned [FAIL] for a few times, and then eventually stopped giving line to serial monitor after 18:48:20.999. I notice this happens a lot if i try to access the devices through thinger.io app.

18:48:15.863 -> [THINGER] Available bytes: 39
18:48:15.863 -> [THINGER] Writing bytes: 7 [FAIL]
18:48:19.653 -> [THINGER] Expected:7
18:48:19.653 -> [THINGER] Wrote:0
18:48:19.688 -> Thing handle already run. 
18:48:19.723 -> [THINGER] Available bytes: 61
18:48:19.757 -> [THINGER] Writing bytes: 8 [FAIL]
18:48:20.724 -> [THINGER] Expected:8
18:48:20.724 -> [THINGER] Wrote:0
18:48:20.759 -> Thing handle already run. 
18:48:20.793 -> [THINGER] Available bytes: 21
18:48:20.828 -> Thing handle already run. 
18:48:20.863 -> [THINGER] Available bytes: 20
18:48:20.897 -> Thing handle already run. 
18:48:20.930 -> [THINGER] Available bytes: 19
18:48:20.964 -> Thing handle already run. 
18:48:20.964 -> [THINGER] Available bytes: 18
18:48:20.999 -> Thing handle already run. 

Here is another instance. If u take note on the time u can see it stopped for about a minute before proceeding to the next code. I think this is related to thinger.handle(), but i dont know what I can do.

19:46:09.068 -> Thinger start
19:47:02.679 -> [THINGER] Available bytes: 100
19:47:02.714 -> [THINGER] Writing bytes: 8 [FAIL]
19:47:03.710 -> [THINGER] Expected:8
19:47:03.710 -> [THINGER] Wrote:0
19:47:03.743 -> [THINGER] Writing bytes: 2 [FAIL]
19:47:04.729 -> [THINGER] Expected:2
19:47:04.729 -> [THINGER] Wrote:0
19:47:04.763 -> After thinger handle
19:47:04.798 -> working after sending

So, do you guys have met something like this before?

I would let a ping monitor run for a day or two.
ping-monitor
Some internet providers are really getting worse from year to year.

If the device does not reach to write into the cloud server, there could be an issue with the internet access.

What I’ve done to improve the connection was to make a routine to reset the connection each 5 minutes, I need to upload data each 5 minutes so I made a routine that a minute before the uC will write, it calls the thing.stop() and after is disconnected calls the thing.handle(), I’m working with an ESP32 and using both cores, so one is dedicated to communication and it does not affect the process measurement (if keeps stuck or something).

Hope this helps.

Thank you for the suggestions @ega and @rin67630 . I think I will give it a try and let you guys know my progress.

@rin67630 Can I know which website do I ping to? console.thinger.io?

Can I know also where does thinger have their servers? Will it affect me in any way?

Pinging console.thinger.io should be ok.

ping  console.thinger.io
Pinging console.thinger.io [65.9.66.14] with 32 bytes of data:
Reply from 65.9.66.14: bytes=32 time=15ms TTL=246
Reply from 65.9.66.14: bytes=32 time=13ms TTL=246
Reply from 65.9.66.14: bytes=32 time=14ms TTL=246
Reply from 65.9.66.14: bytes=32 time=14ms TTL=246
Ping statistics for 65.9.66.14:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 13ms, Maximum = 15ms, Average = 14

It does not matter where the servers are. You are not tweaking performance.
The main issue you might have is that sometimes you don’t reach out at all, or the DNS fails.