Hi,
here my problem, I got a little home automation box that send data trough serial. I want to read these data to eventually use it with the arduino, for now, all i want is to read these output, since i only got a uno and nano, both only have one serial rx/tx. So i use one to plug in the box and the other on my laptop to read the data with the software serial library. the only data that it show on the screen when i press a button on my box is some garbage like some yyyyyy. here's my code:
/*
Software serial multple serial test
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
The circuit:
* RX is digital pin 2 (connect to TX of other device)
* TX is digital pin 3 (connect to RX of other device)
created back in the mists of time
modified 9 Apr 2012
by Tom Igoe
based on Mikal Hart's example
This example code is in the public domain.
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("Start reading");
// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
}
And the other
And the other
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 4); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
}
void loop()
{
if (Serial.available())
mySerial.write(Serial.read());
}
tx to rx
rx to tx
gnd to gnd
vin to vin
Thanks in advance