But when I upload the code string “hello” is sent by the arduino but not received by wio terminal?
Sending code:
char mystr[5] = "Hello"; //String data
void setup() {
// Begin the Serial at 9600 Baud
Serial.begin(9600);
}
void loop() {
Serial.write(mystr,5); //Write the serial data
delay(1000);
}
Receiving Code:
char mystr[10]; //Initialized variable to store recieved data
void setup() {
// Begin the Serial at 9600 Baud
Serial.begin(9600);
}
void loop() {
Serial.readBytes(mystr,5); //Read the serial data and store in var
Serial.println(mystr); //Print data on Serial Monitor
delay(1000);
}
It may works fine because you use this string not as string but as array of bytes with predefined length.
But when you initialize your variable with a string "Hello" - the compiler created array "Hello\0" with 6 elements and then copy it to your array mystr. But mystr array is only 5 chars long - so the sixth char will be placed to memory beyond the array. This can lead to overwriting the memory area with a completely different variable and unpredictable behavior.
raunaksinghinventor -
First the Wio Terminal is not a display. It is a computer (using an ATSAMD51chip) so just sending it "Hello" will not cause it to do anything. It must be running some program to detect input on the TX/RX pins of the input port and display on it's LCD. You can write the program in the IDE, load it to the Wio Terminal using the process provided by Seeed on their Get Started page. Once you have Wio Terminal programmed then communication is easy via serial port, Bluetooth or even via Wifi.