Stability of an arduino UNO with ethernet shield and dht11 temperature sensor

Hello, some people in my office has started working on a temperature control project using an arduino uno and they asked for my help regarding the programming portion of the task.
You can find the code here: GitHub - vodkatad/termostatino: Codice per controllo temperatura con arduino
Basically arduino reads the temperature every ten seconds and does a POST to a server that sends a mail if the temperature rises above a certain cutoff or does not hear from arduino for some time. There is also a leftover piece of code in arduino that switches on/off a relay based on temperature values but right now that behaviour is not needed.

My problem is that this setup is unstable: after a while (that varies without any regularities that I was able to could work perfectly for 12 hours or only for 30 minutes) it stops sending POST requests, the attached LCD display is not refreshed with new temp values and also the serial becomes mute....but If I ping its IP I am able to reach it.
Up until today I only realized about the end of the POST requests so I believed it was only a problem with the Ethernet library (you can see old commits with different strategies about the HTTP connection) but when I saw that it was not reading temperatures and writing to the serial port anymore I started having doubts about what could be the issue. Is it obviously related to the sw or could it somehow depend on some hw problem? The circuit is still using a breadboard.

I'm sorry, maybe similar issues have already been discussed here but I had some trouble in thinking about an appropriate search combo for my problem. If the schematics are needed I will gladly post them.

Thank you very much for your help,

There are two 'computers' running in your project, the Arduino and the Ethernet Interface.

It sounds like the Arduino stops and the Ethernet continues.

You need to add code to find out where in the Arduino code the problem is.

You can add some Serial.Print statement to show where in the code you are. You will see the last print that worked.

You can also connect some LEDs to show where the code is running.

Thanks, I'll look in this direction I did not know that Ethernet Interface and Arduino were living two separated lives - I admit that having received the hardware already assembled I skipped some of the preliminary documentation process!

On top of everything with keepalive connection the small python server is having some troubles so I am having serious difficulties in dissecting the issue...sadly the code was born without many Serial.print as long as for the first two days it worked perfectly and I felt almost blessed :slight_smile:

Quick follow-up: it wasn't arduino's fault! The python library used to manage http requests was sometimes failing (in a strange way, if someone is interested: and arduino remained stuck while trying to do the POST. Adding a timeout AND a threaded server seems to have solved the issue.

On a side note I was wondering if leaving the "debug" prints on the serial could be an issue for arduino: as long as it restarts when one plugs in the usb cable they are not useful at all but I am sufficiently lazy to be thinking to leave them there :slight_smile:

Thank you very much for your help,

You could add a check to only print if the serial is available.