How to store serial data to an array to be send to server?
Posted: Fri Sep 04, 2020 10:47 pm
Hi all!
I have the following issue with the code below,
I’m trying to store serial data to an array, then convert all the array to a string and then send it to the server. But I keep getting an error “non class type”
The divine I’m queuing responds one byte at a time. Any suggestions is appreciated!
I have the following issue with the code below,
I’m trying to store serial data to an array, then convert all the array to a string and then send it to the server. But I keep getting an error “non class type”
The divine I’m queuing responds one byte at a time. Any suggestions is appreciated!
Code: Select all
#include <ESP8266WebServer.h>
int incomingByte[13] ; //array of data
String page1;
#define mdDeRe 14 // GPIO14 = D5 // sends signal to device.
ESP8266WebServer server(80);
void getdata1 (){
digitalWrite(mdDeRe, HIGH); /// enable receiver to receive data
Serial.write(17); ///// <<<---- maybe this can be written better
Serial.write(3);
Serial.write(0);
Serial.write(84);
Serial.write(0);
Serial.write(4);
Serial.write(7);
Serial.write(73);
Serial.flush();
digitalWrite(mdDeRe,LOW); //// enables device to send data
//// store received bytes into an array /////
if (Serial.available()) {
for (int i=0; i<13; i ++){
incomingByte[i] = Serial.read();
}
}
/// Here I would like to send the whole array to server
page1 = incomingByte.toString();
server.send(200, "text/plane",page1); //sends data to server
}