Extracting IP address from a character array returned by ESP8266 module

You seem to have moved the 'tag' and 'value' globals into a function, which is a good start. But you could go a bit further: you have

char value[25];
char tag[10];
.......
strcpy(tag,"STAIP");
scantext(tag,value);

but the strcpy() bit is really a part of scantext() so could be done as

char value[25];
scantext("STAIP",value);

[the ..... marks here are not 'c', of course, they're just marking bits of code which aren't relevant for this discussion and don't change).

You could get rid of 'incoming[]' as a global by bringing it into connecttowifi() and extending scantext():

bool connecttowifi()
{
  char incoming[100]; 
  char value[25];
.....
.....
   scantext(incoming, "STAIP",value);

You could also save some repeated code : you have two copies of

 wifireceive();
  if (strstr(incoming,"OK")) {

so why not include the test in wifireceive():

bool wifireceive(char* inStr) {
.......
return strstr(inStr,"OK");
}

and then:

if (wifireceive(incoming)) {
....
}else
{
....
}

I haven't tested all these bits so I may have some syntax errors to catch you out :slight_smile: