Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By javadhabibi
#82755 Hi every one
I have a sensor that should send 1KB data every 40ms. I want to send this through ESP8266 (Nodemcu) to my laptop. This is my code:

Code: Select all#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

/* Put your SSID & Password */
const char* ssid = "NodeMCU";  // Enter SSID here
const char* password = "12345678";  //Enter Password here

char  Data_mem[10][1024];
uint8_t Data_mem2[10][1024];

int a=0;

/* Put IP Address details */
IPAddress local_ip(192,168,1,1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);

//ESP8266WebServer server(80);
WiFiServer server(80);                   

void setup() {
  Serial.begin(115200);
  WiFi.softAP(ssid, password);
  WiFi.softAPConfig(local_ip, gateway, subnet);
  delay(100);
 
  server.begin();
  server.setNoDelay(true);// Don't Permit TCP Buffering
  Serial.println("HTTP server started");

  //Data Init
     for(int j=0;j<10;j++){
        for(int i=0;i<1024;i++) {
            Data_mem[j][i]='G';
        }
      }

     for(int j=0;j<10;j++){
        for(int i=0;i<1024;i++) {
            Data_mem2[j][i]=10;
        }
      }
}

void loop () {
  WiFiClient client = server.available();
  if (client) {
    if (client.connected()){
      if(a==0){
        a=1;
        for(int j=0;j<10;j++)
          client.println(Data_mem2[j]);   
    }
      else{
        client.stop();  // terminates the connection with the client
      }
    }
  }
}


In this Code, i have 2 problem:
1- How to send an array of array of uint8_t through WiFi? (Each 1KB data(=Data_mem[j]) should send in one seprate packet)
In this code i get this error:
call of overloaded 'println(uint8_t [1024])' is ambiguous

2- If i want to send char instead of uint8_t, data sent. But what received is not 10 * 1024 =10240 bits. They are 56320 bits!(I have copied received data of packet sender in Word and get the number of characters ('G'))
Note that it is true for sending client.println(Data_mem[0]) and is 1024 bit.

I need both array of array of uint8_t and char.

Thanks