http get

Hi,

I am connecting to a webserver and getting an answer with the right data. I want to use some of the returning characters as input for a pwm led driver. For that to work, I have to extract the relevant data from the input and turn them into an integer. It is the valuebetween < and> in the monitor. How can I do that? Where can I best look for an answer?
What might help is if I would not get the content type etc. text back every time. I guess that has to do with the syntax of the GET message. Does anyone have a suggestion for me for that?
I attached a screenshot of the monitor output.
Thanks, Jan.

/*written for nano33 IoT
  First Serial is started, then WIFI.
  A connectio0n is made to server "tuin",
  and every 5 seconds a http request is sent.
  The lux level is answered.
  This is stored as a CHAR CHAR and printed on the serial monitor
 */

#include <SPI.h>
#include <WiFiNINA.h>

char ssid[] = "PBL";          //  your network SSID (name)
char pass[] = "xxxxxxxxxx";   //  your network password

int status = WL_IDLE_STATUS;
IPAddress tuin(192,168,2,121);  // remote server we will connect to
WiFiClient client;

void setup() 
{
  Serial.begin(9600);
  while (!Serial) 
  {
  ; 
  }
  Serial.print("Attempting to connect to WPA network ");
  Serial.print("SSID: ");
  Serial.println(ssid);

  status = WiFi.begin(ssid, pass);  
  if ( status != WL_CONNECTED) 
  {
  delay(10000);
  while(true);
  }
  Serial.println("Connected to wifi");
  Serial.println("Starting connection to server");   
}    
void loop()
{
  client.connect(tuin, 80); 
  client.print("GET /control/rcontrol?action=gettext&message=<$(SEN.LXL)>\n");
  delay(5000);
  
  while (client.available()) 
  {
  char c = client.read();
  Serial.print(c);
  }
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.