Hi,
I am sending a data packet over my arduino serial pin and receiving it on my esp8266 nodemcu RX pin.
Arduino part i coded and works fine, I declared and array and used "Serial.write(array)" command.
But on receiving the same, for my esp8266 chip, there is a compilation error.
It is an assignment error "incompatible types in assignment".
How can i read this?
Thanks in advance
Below is my code:
// Import required libraries
#include "ESP8266WiFi.h"
String msg[1000];
// WiFi parameters
const char* ssid = "lenovo";
const char* password = "password";
void setup(void)
{
// Start Serial
Serial.begin(9600);
// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Print the IP address
Serial.println(WiFi.localIP());
}
void loop() {
Serial.println("I am in loop, now the data part");
msg = Serial.readString();
Serial.println(msg);
}
system
2
An array of String with 1000 elements takes 6000 bytes of RAM, even if all the elements are empty.
Do you have 6000 bytes of RAM to spare?
system
3
msg = Serial.readString();
msg is an array of String objects. Which element in the array are you trying to write to?
1 Like
True,
Thank you,
actually i have this packet incoming
"sprintf(msg,"SMKBXX,SMCXXX,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",....."
some 28 integers that i need to receive...
I do not understand how do i read this array "msg"
both Serial.read and Serial.readString throw me a compilation error.
system
5
How about:
#include "ESP8266WiFi.h"
String msg;
// WiFi parameters
const char* ssid = "lenovo";
const char* password = "password";
void setup(void)
{
// Start Serial
Serial.begin(9600);
// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Print the IP address
Serial.println(WiFi.localIP());
}
void loop() {
Serial.println("I am in loop, now the data part");
msg = Serial.readString();
Serial.println(msg);
}
(uncompiled, untested - sorry, I never use Strings, unless I can't avoid them)
Yep, that takes care of the compilation part.
Thanks..!!!
Hope this string will store 28 integers for me.
system
7
Hope this string will store 28 integers for me.
sp."Hope this String will store 28 integers for me."