Hi, I got this error when I try to upload into database.. Im using ESP8266 ..
Here's my code
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
SoftwareSerial DataSerial(12, 13);
const char *ssid = "xxxxxxxx";
const char *password = "xxxxxxxx";
const char *host = "xxxxxxxx";
unsigned long previousMillis = 0;
const long interval = 3000;
const byte ButtonPin = D1;
byte buttonState;
String arrData[4];
boolean parsing = false;
String sendval1, sendval2, sendval3, sendval4, postData;
void setup() {
Serial.begin(9600);
DataSerial.begin(9600);
pinMode(ButtonPin, INPUT_PULLUP);
buttonState = digitalRead(ButtonPin);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
int value = 0;
void loop() {
HTTPClient http;
String data = "";
if (Serial.available() > 0) {
char inChar = (char)Serial.read();
data += inChar;
if (inChar == '\n') {
parsing = true;
}
}
if (parsing) {
parsingData();
parsing = false;
data = "";
}
byte but = digitalRead(ButtonPin);
if (buttonState != but) {
buttonState = but;
if (LOW == but) {
DataSerial.println("Ya");
parsingData();
++value;
Serial.print("connecting to ");
Serial.println(host);
WiFiClient client;
sendval1 = String(arrData[0]);
sendval2 = String(arrData[1]);
sendval3 = String(arrData[2]);
sendval4 = String(arrData[3]);
postData = "sendval1=" + sendval1 + "&sendval2=" + sendval2 + "&sendval3=" + sendval3 + "&sendval4=" + sendval4;
http.begin(client, "xxxxxxx/writedata.php");
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
int httpCode = http.POST(postData);
Serial.println("Soil Moisture= "+ sendval1 + "Temperature= "+ sendval2 + "Humidity= "+ sendval3 + "pH= "+ sendval4);
if(httpCode == 200){
Serial.println("Upload Success");
Serial.println(httpCode);
String webpage = http.getString();
Serial.println(webpage + "\n");
}else{
Serial.println(httpCode);
Serial.println("Upload Failed. \n");
http.end();
return;
}
}
}
}
void parsingData() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
String data = "";
while (DataSerial.available() > 0) {
data += char(DataSerial.read());
}
data.trim();
int j = 0;
arrData[j] = "";
for (int i = 0; i < data.length(); i++) {
char delimeter = '#';
if (data[i] == delimeter) {
j++;
arrData[j] = "";
} else {
arrData[j] = arrData[j] + data[i];
}
}
}
}
Can anyone help me please?
and here is my Error...
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Exception (9):
epc1=0x40100262 epc2=0x00000000 epc3=0x00000000 excvaddr=0x6010e109 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffaf0 end: 3fffffc0 offset: 0190
3ffffc80: 00000005 00000000 3fffc228 401060e9
3ffffc90: 00000000 00000000 00000005 401025b8
3ffffca0: 40100f5b 00000030 0000001b ffffffff
3ffffcb0: 0000000c 00000001 00000000 40100824
3ffffcc0: e0036035 00000020 00000003 3fff05d8
3ffffcd0: 00000091 3fffc6fc 00000001 00000020
3ffffce0: 00000020 00000000 3ffee818 00000022
3ffffcf0: 3fffc200 40100760 3fffc258 4000050c
3ffffd00: 4020cdd2 00000030 0000001b ffffffff
3ffffd10: 40205220 00000004 4023ffcc 0000000e
3ffffd20: 38505345 3fff05d0 00000001 00000000
3ffffd30: 3fff05b4 3ffffeb7 00000000 3fff05b4
3ffffd40: 3fff05b4 4023ffcc 00000012 00000030
3ffffd50: 4000050c 4023ffcc 3fffc228 401060e9
3ffffd60: 40204fc8 00000030 0000001b ffffffff
3ffffd70: 402016ef 00000000 00000001 00000020
3ffffd80: 00000001 ffffffff 00000020 3ffee818
3ffffd90: 00000000 00000020 00000020 40100f58
3ffffda0: 3ffee698 3ffe892a 3ffffeac 40100f90
3ffffdb0: 00000000 3ffe892a 3ffee818 00000030
3ffffdc0: 3ffef794 00000001 3ffffe20 4020543d
3ffffdd0: 00000284 00000284 3ffe85e8 3ffee818
3ffffde0: 4023ffcc 00000020 3ffffeac 402050ad
3ffffdf0: 00000000 00000020 00000005 401025b8
3ffffe00: 4023ffdc 4010584f 3ffecab0 3ffee818
3ffffe10: 4023ffcc 00000011 3ffffeac 3ffee818
3ffffe20: 4023ffcc 00000011 3ffffeac 40205220
3ffffe30: 3fffdad0 4023ffcc 3ffffeac 402053b8
3ffffe40: 40206cb4 00000000 3ffffe70 402053e1
3ffffe50: 3ffe892a 00000000 00000000 40203438
3ffffe60: 00000000 00000000 3ffee804 4020131f
3ffffe70: 00000000 00000000 3fffc228 00000000
3ffffe80: 40010000 3f001388 00000000 00000000
3ffffe90: 00000000 00000000 0000001b 00000000
3ffffea0: 00000000 00000001 00000000 3fff05b4
3ffffeb0: 0011001f 80000000 00000000 00000000
3ffffec0: 00000000 00000000 00000000 00000000
3ffffed0: ffffffff 3fffda00 00000000 0000000a
3ffffee0: 00000000 00000000 00000000 00000000
3ffffef0: 00000000 00000000 00000001 3ffe85e4
3fffff00: 00000000 3fffdad0 3ffee818 00000030
3fffff10: 007a1200 1d7a2b75 00000000 3ffe85d0
3fffff20: 40204528 3ffe8928 3ffee788 40204534
3fffff30: 40204528 3ffe8928 3ffee788 40204794
3fffff40: 3ffe892a 0000000d 3ffee788 40204878
3fffff50: 0b17a8c0 00ffffff e317a8c0 402048f8
3fffff60: 007a1200 6a5c45d0 00000000 40201120
3fffff70: 00000000 00000000 feefeffe feefeffe
3fffff80: 00000000 00000000 00000001 40100584
3fffff90: 3fffdad0 00000000 3ffee804 3ffee818
3fffffa0: 3fffdad0 00000000 3ffee804 40205f74
3fffffb0: feefeffe feefeffe 3ffe85e4 401012b5
<<<stack<<<
--------------- CUT HERE FOR EXCEPTION DECODER ---------------