2

I'm sending sensor data using Arduino and ESP8266. But while compiling the sketch in Arduino I'm getting an error saying - deprecated conversion from string constant to 'char*' [-Wwrite-strings].

#include "SoftwareSerial.h"
SoftwareSerial esp(10, 11);// RX, TX
void setup() {
  esp.begin(9600);
  Serial.begin(9600);
  delay(100);
  Serial.println("Started...");
  reset();
  connectWifi();
}

//reset the esp8266 module
void reset() {
  esp.println("AT+RST");
  delay(1000);
  if (esp.find("OK")) Serial.println("Module Reset"); //error
}
dda
  • 6,030
  • 2
  • 25
  • 34
STACK2
  • 165
  • 1
  • 5
  • 16

1 Answers1

2

As Aeldred said you have just to cast you String to char*.

so your sketch will looks like :

#include "SoftwareSerial.h"
SoftwareSerial esp(10, 11);// RX, TX
void setup() {
  esp.begin(9600);
  Serial.begin(9600);
  delay(100);
  Serial.println("Started...");
  reset();
  connectWifi();
}

//reset the esp8266 module
void reset() {
  esp.println("AT+RST");
  delay(1000);
  if (esp.find((char*)"OK")) Serial.println("Module Reset"); //error
}
Serhan
  • 605
  • 9
  • 19