I am trying to establish a wired one way communication between two Arduinos.
I decided to use SoftwareSerial because that lets me choose the pins for the communications.
I also use SoftEasyTransfer to send struct.
Transmitter code:
#include <SoftEasyTransfer.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
//create object
SoftEasyTransfer ET;
struct SEND_DATA_STRUCTURE {
float temp = 22.22;
float hum=88.88;
} myData;
//give a name to the group of data
SEND_DATA_STRUCTURE mydata;
void setup() {
mySerial.begin(9600);
Serial.flush();
//start the library, pass in the data details and the name of the serial port.
ET.begin(details(mydata), &mySerial);
}
void loop() {
//send the data
ET.sendData();
delay(100);
}
Receiver code:
#include <SoftEasyTransfer.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
//create object
SoftEasyTransfer ET;
struct RECEIVE_DATA_STRUCTURE {
float temp;
float hum;
} myData;
//give a name to the group of data
RECEIVE_DATA_STRUCTURE mydata;
void setup() {
Serial.begin(115200);
Serial.flush();
mySerial.begin(9600);
mySerial.flush();
//start the library, pass in the data details and the name of the serial port.
ET.begin(details(mydata), &mySerial);
}
void loop() {
//check and see if a data packet has come in.
if (ET.receiveData()) {
Serial.print("Temperature: ");
Serial.println(myData.temp);
Serial.print("Humidity: ");
Serial.println(mydata.hum);
}
delay(100);
}
So I connect Pin10 on both Arduinos and Pin11.
After the data was received the receiver should print the data. But nothing is being printed which for me indicates there is no incoming data.
I tried to swap the pins, connecting Pin10 on one arduino to Pin11 on the other and vice versa. In this case "Temperature" and "Humidity" is printed but for values 0.00 printed.
Why the code does not work?
Libraries can be downloaded from this link.
Update:
With the swapped connection I receive half of the data.
Temperature is still showing 0.00 while humidity is 88.88.