0

I have a php file in my website which returns sensor reading. I had been fetching this reading and displaying in my Serial monitor using the below code

http.begin("http://<MYWEBSITE>/fetch_sensor.php");  
  int httpCode = http.GET();                                                                 
  if (httpCode > 0) {
    String payload = http.getString();   
    SensorReading = payload.toInt();
    Serial.print("Sensor Reading=");
    Serial.print(SensorReading); 
    Serial.println();
  }

Now I have updated my php file to return readings of multiple sensors. The readings are returned seperated by commas like 23,66,82,100

I am looking to update my code so that the readings returned by the php file is assigned as SensorReading1, SensorReading2, SensorReading3 etc.

Seeking help from experts.. Thanks!!

MC Emperor
  • 22,334
  • 15
  • 80
  • 130
Intelli
  • 1
  • 5

1 Answers1

1

You need to split your incoming string into separate strings, and then display each one. There are a few ways of splitting a string: https://arduino.stackexchange.com/questions/1013/how-do-i-split-an-incoming-string

Kamil B
  • 33
  • 9