Arduino Serial Board seems to have some problem.

As i was running my code with the serial board, i noticed that the prints on my board suddenly goes weird with the letters and numbers and soon stop working like it should. After picture 1, it showed some weird arrangement of letters but the code continued to loop. But at picture 2, once the "response: 14am 13" came, my whole serial board stop moving and my code just stop working(I know it stopped working as my code sends data up to a database, so i can check if like the temperature etc is increasing or decreasing). Please help! Is it that my Arduino lack memory space? Or is my arduino faulty?

*Note there is not Break or any sort of code that will stop my program indefinitely.

the serial board?

What is that?

Sorry, i meant serial monitor!

Does it work again after reset?
What's all connected?
How about posting your code?

After reset, the problem will still occur after 5-10 loops. My Code purpose is to get NTP time from the server using GET method with Ciao library to get the time and if the time if right, it will do all the sensor readings and Send a Get method to the PHP application. The reason why i am using GET method to the php Application is because i will only need to change the URL of the hosted application and it will loop through the URL and get the data i need.

When i am testing out the NTP Codes alone, it works fine everytime. When i am testing out the code which gets data and send it to the php Application, it works out fine too. But when i integrate it together, the first few requests that i send to the php Application will always give me "Write Error" Which means unable to send up the URL, and after few more tries, it is able to send. But once it is able to send, the following problem above shows up and my code stops working.

Code is as follow below.
Note: The word server is my ip Address of the application.

#include <MemoryFree.h>
#include <Wire.h>
#include <UnoWiFiDevEd.h>


//Temperature Sensor
const int pinTemp = A0;      // pin of temperature sensor
float temperature;
int B=3975;                  // B value of the thermistor
float resistance;

void setup() {
	Serial.begin(9600);
	Ciao.begin();
	pinMode(2, INPUT);
	delay(5000);
}

void loop() {
  //NTP
  String time = doRequestForNTP("rest", server,"server/ntp.php", "GET");
  if(time == time){ //Check if the returned time from NTP is same as what we want
    
    String resource = "server/from_micro.php?unit=1&TmpSensor=";
    int val = analogRead(pinTemp);                               // get analog value
    resistance=(float)(1023-val)*10000/val;                      // get resistance
    temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;     // calc temperature

    resource += temperature;
    resource += "&PhSensor=50";
    
     Serial.println(resource);

 
  doRequest("rest", server, resource, "GET");
  Serial.println("End of DataUpload"); 
  Serial.print("freeMemory()=");
  Serial.println(freeMemory());
  }
  delay(10000);
}

void doRequest(const char* conn, const char* server, String command, const char* method){
  
  CiaoData data = Ciao.write(conn, server, command, method);
  if (!data.isEmpty()){
    Serial.println("D");
  }
  else{
    Serial.println ("Write Error");
  }
}

String doRequestForNTP(const char* conn, const char* server, String command, const char* method){ //if unable to get time, Delete String/Const Char* at command and replace with the other
  CiaoData data = Ciao.write(conn, server, command, method);
  if (!data.isEmpty()){
    Serial.println( "Response: " + String (data.get(2)) );
    return String (data.get(2));
  }
  else{
  Serial.println("Write Error in NTP");
  }
}

I could not view your pictures earlier on. The result of freemem in your 1.png clearly shows what goes wrong; you're running out of memory.

The usual culprit is the use of the String (capital S) class; and the usual suggestion is to get rid of it.

Before trying to fix that however, you have a bug in doRequestForNTP that might also be the cause of your problem: it does not return a defined String if there is no reply. You can change the else part to (and it's the first thing that needs to be fixed)

  else
  {
    Serial.println("Write Error in NTP");
    return String("");
  }

I avoid the String class as much as possible, so I'm not sure if the syntax is 100% correct.

I downloaded the Ciao library from https://github.com/arduino-org/arduino-library-ciao/releases and glanced over it.

It might not be that easy to get rid of the String class completely as the library seems to make heavy use of it as well.

Lastly
if (time == time) is totally useless as it will always be true.

I hope that the suggested change solves the issue.

PS
When posting code, please use code tags
Please edit your reply #4
type
** **[code]** **
before your code
type
** **[/code]** **
after your code

For the time, i am just using it to check for now, i will change it to something like 7pm etc. I see.. Means String are taking up alot of space in the memory. Is there any way to change like a String to a const Char*?

I noticed something strange too, that i cannot have 2 doRequest function running in the same loop. If there is 2 of the same function trying to connect to the same server, it will not work properly (I will be able to get The NTP but will not be able to post the URL anymore).

OP is using an Uno WiFi with original firmware and the UnoWiFiDevEd library. It's not ciao, it's like ciao.
that library and firmware have limitations on number of network sockets.

Juraj:
OP is using an Uno WiFi with original firmware and the UnoWiFiDevEd library. It's not ciao, it's like ciao.
that library and firmware have limitations on number of network sockets.

The OP has wasted everybody's time with this question.

Sheesh.

Now I will know not bother with his questions.

I don't feel that op wasted my time.

sterretje:
I don't feel that op wasted my time.

I do, because the original post left it that very important information about what hardware he is using.

If you think that isn't important, that's your right.
To me, it was a giant waste of time.

@ieee488, Well, if you feel that i am wasting your time then why are you even commenting and posting? Just get the fuck out of here. Im sorry i am not an "Expert" like you, knowing what kind of exact details i need to post to satisfy you filthy "Expert". As you can see from my post, i am a very new user coming into this forum. Rather than notifying me of what kind of information i need to put into my post, you rather come and talk rubbish here. It clearly define what kind of person you are in the society. Take a look at the other people who at least have the right mindset of helping a newbie that knows nothing. Learn at least something from them to salvage yourself.

@Wecuyx, slow down a bit. ieee488 did not insult you so no need for your style of reply.

(deleted)