What could cause AdC Reading only to get stucked? I am doing a Solar water heating contrôler with arduino.
I have had a freeze of the AdC value read (ntc probe that read Solar panels) that remained at -1.75degc. this was confirmed by the serial data sent an recorded (using raspberry and Time series database) but also the direct Reading on the LCD (16x2). After rebooting Arduino everything get back normally.
Additionnel strange thing is that the water tank ds18b20 temperature sensor serial data value showed a huge spike 1e4... That lasts less than 1 second (which Can not happen as the sensor max value is 125 deg c from this numerical sensor.). After that spike, the adc recorded value remained Frozen. The other ds28b20 and LCD menu navigation and display were ok...
Could that be related to EMI?
To SRAM overflow? Even if the rest of the program seems to work?
What could enables me to discriminates between those issues?
It seems it happened arround 2 days after the Arduino was rebooted.
Description of set up:
I am using a standalone atmega 328 with polulu programmer. 8mhz internal crystal. Everything places on veroboard (main). Then a child veroboard holds the various resistors (Pullup, pulldown) for the input signals. Another child veroboard holds the outputs (pwm pump speed driver), optocoupler for pump Relay.
The supply is a meanwell din rail 5v ac-dc concerter.
I places decoupling caps arround atmega 328, diode+ pull up resistor + cap on reset Line as i had resets regularly (they are gone now).
The pump Relay is on a separate 24v supply. Grounds are separrated from Arduino with this 24v circuit (that incluses flyback diode). But grounds are common to main and 2 children veroboards. The ntc Solar panel probe wire is twisted rj45 cat6. It is shielded and shielding is connected to the atmega grounds.
My program is non blocking type with use of millis and state machines. During developpent I checked the Time operation of the program that was running fast (no delay).
The main structure is quite straightsforward. See bellow commented:
//Get Button state and debounce
buttonLeft.launchSM();
buttonRight.launchSM();
buttonDown.launchSM();
buttonUp.launchSM();

//Menu(uses menubackend library)
menuNavigationBehavior(); // ie detect action from button pressed.Should be executed very rapidely... (less than 10 ms).
EditingVarInMenu(); // changing variables in Menu requiring speed loop (set parameters for example)

//Getting Temperature from panel1, 5 for 5 averaged values 
//every 20 ms ie 20 * 5 we have a temperatuure every 100 ms.
TemperaturePanel1(5,20,Tpanel1);

//Getting Temperature from one wire. Time between fetch and return of 100 ms.
getOneWireTemp (); 

//CONTROLLER---------------------------------------------------------------
//System Control Logic updated at Time loop
// Controller logic state machine execution
switch (ControllerMainState)
    {
        case CONTROL_MANUAL:
          ManualStateActions();
          break;

        case CONTROL_AUTO:
          AutoStateActions();
          break;

        case CONTROL_ERROR:
          ErrorStateActions();
          break;
    }

    //MENU DISPLAY_____________________________

    if( millis() - timer_50_ms &gt; 200) // 
         {
              timer_50_ms = timer_50_ms+200;
              displayMenu(); // change the display. Can be done less often ie every 200 ms
          }
You appear to have a difficult problem.  One of the rules I use is never power the arduino with 5V power, always use the barrel connector and go with about 8 volts. The additional filtering etc the on board power supply does is amazing. The external 5V is ok for most of the other devices. Another option would go to the local electrical store and purchase a metal junction box and mount the electronics in that complete with a metal cover. Be sure it is grounded to earth. The reason for this is your prototype assembly has a lot of antennas that will pick up just about all of the electrical noise in the area. Remember all grounds must be connected. Arduinos are not hardened for industrial or commercial controller applications.