ESP32-Based Soil Monitoring System Occasionally Loses Sensor Readings After Several Days

MariaWilliams

Jun 8, 2026
3
Joined
Jun 8, 2026
Messages
3
Hi everyone,

I'm working on a remote soil monitoring project using an ESP32 that measures soil moisture, temperature, and ambient humidity. The system uploads data periodically over Wi-Fi and is powered by a small solar-charged battery pack.

The project works well initially, but after running continuously for several days, I occasionally notice that one or more sensors stop reporting valid values. The ESP32 remains online and continues transmitting data, but some readings become stuck or return invalid values until the system is rebooted.

Current setup:

  • ESP32 development board
  • Capacitive soil moisture sensor
  • DHT22 temperature/humidity sensor
  • Solar-powered battery system
  • Custom PCB
Things I've already checked:

  • Sensor wiring connections
  • Power supply voltage stability
  • Wi-Fi connectivity
  • Basic error handling in the firmware
A few questions:

  1. Have you experienced sensor communication failures during long-term ESP32 deployments?
  2. Could memory fragmentation or resource leaks cause sensors to stop responding after several days?
  3. Are there recommended watchdog or sensor recovery techniques for unattended monitoring systems?
  4. Would adding additional filtering, protection, or connector improvements help improve long-term reliability?
I'm also preparing a new PCB revision and would appreciate any recommendations regarding sensor interfacing, power management, or PCB layout before sending it for manufacturing.

Thanks!
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
14,272
Joined
Nov 17, 2011
Messages
14,272
As the ESP32 continues to operate, this is most likely a software issue.
Here are some items to consider:
  • Check all counters, timers etc. for possible overflow(s) and handle these properly.
  • Check your memory management. Is all allocated memory freed after use?
  • Avoid copying data when possible, use by reference instead. This minimizes memory usage.
  • Are you using interrupts? If so, do the interrupt routines clean up and return from interrupt properly?
  • Are you using gobal variables? If so, check that these are handled consistently and are not changed by an unauthorized piece of code.
some readings become stuck or return invalid values until the system is rebooted.
Have you tried to reset only the affected sensors and the associated drivers in software instead of completely rebooting?
 

bidrohini

Feb 1, 2023
214
Joined
Feb 1, 2023
Messages
214
I've seen similar issues in long-running ESP32 deployments, and in my experience it's often related to software rather than the sensors themselves. Memory leaks, heap fragmentation, or a sensor library getting stuck can all cause readings to freeze while the ESP32 continues running normally. Check this discussion: https://forum.arduino.cc/t/esp32-board-freezes-randomly-when-rapid-serial-printing/1199915/

One thing worth trying is adding logic that detects invalid or repeated readings and automatically reinitializes the affected sensor. A watchdog can also help recover from situations where a task becomes unresponsive.

For the next PCB revision, I'd also pay attention to connector quality and power filtering, especially in solar-powered systems where supply conditions can vary significantly throughout the day. Check this similar solar powered pcb: https://www.pcbway.com/project/gifts_detail/Solar_Powered_WiFi_Weather_Station_V3_0.html

Out of curiosity, are the failed readings always from the same sensor, or does the problem affect different sensors at different times?
 

MariaWilliams

Jun 8, 2026
3
Joined
Jun 8, 2026
Messages
3
I hadn't considered counter or timer overflows, so I'll definitely review those along with the memory usage over time. The project does use interrupts for sensor sampling and communication, so I'll also double-check that those handlers are behaving correctly.

At the moment, I've only been recovering by rebooting the entire ESP32. I haven't implemented logic to reset individual sensors or reinitialize their drivers when invalid readings are detected. That sounds like a worthwhile experiment and could help narrow down whether the problem is in the sensor interface or elsewhere in the application.

Appreciate the detailed troubleshooting ideas
 
Top