2

I receive the following:

09:27:10.618 -> 0 0 
09:27:12.589 -> 0 0 
09:27:14.616 -> 0 0 
09:27:16.622 -> 0 0 
09:27:18.576 -> 0 0 
09:27:20.577 -> 0 0 
09:27:22.583 -> 0 0 
09:27:24.606 -> 0 0 
09:27:26.571 -> 0 0 
09:27:28.612 -> 0 0 
09:27:30.585 -> 0 0 
09:27:32.582 -> 0 0 
09:27:34.564 -> 0 0 
09:27:36.563 -> 0 0 
09:27:38.587 -> 0 0 

When I use the following codes: For sending:

#include <SPI.h>
#include <SoftwareSerial.h>
SoftwareSerial Serial1(0, 1);
char mystr[6] = "Hello"; //String data

void setup() {
  // Begin the Serial at 9600 Baud
  Serial1.begin(9600);
}

void loop() {
  Serial1.write(mystr,6); //Write the serial data
  delay(1000);
}

For receiving:

    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,6); //Read the serial data and store in var
  Serial.println(mystr); //Print data on Serial Monitor
  delay(1000);
}

Why don't I get my hello string? NOTE: When I changed to Serial1 for the receiver code I now receive nothing. Not sure why it doesn't work.

4
  • 1
    pins 0 and 1 are hardwareserial. don't use them with SoftwareSerial. you have to terminate the buffer with 0 to use it with print – Juraj 2 days ago
  • I want to use it between my rx/tx from a custom made circuit based on nano board to my adafruit feather m0. The feather supports serial1, the other board does not; yet I want to send the message on a hardware level, how would I do this without softwareSerial? As Serial1 won't work on its own as its "not declared in scope". When you say terminate the buffer with 0, should i do "Hello0"? – Robin Svensson 2 days ago
  • why not use Serial if you don't use it for USB? not '0', but 0. int l = Serial.readBytes(buff, len); buff[l] = 0; – Juraj 2 days ago
  • 2
    The Receiver log looks like some SerialMonitor output, which receives via USB. The text to report there should come from feather's Serial1 ? I'd guess on the feather you should do if (Serial1.available()) Serial.write(Serial1.read()); – DataFiddler 2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.