Pages: [1]   Go Down
Author Topic: Read serial from serialsoftware  (Read 246 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

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

Code:
#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
Logged

Texas
Offline Offline
Edison Member
*
Karma: 25
Posts: 1298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


If you want to test software serial from one arduino to another look here:

http://www.instructables.com/id/Test-arduino-to-arduino-serial-using-softwareSeri/#intro
Logged

Good luck, Jack

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 653
Posts: 50888
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
tx to rx
rx to tx
A picture that shows the actual connection would convey far more information. To me, this statement looks like you connected pins 0 and 1 on each board to the opposite pins on the other board. But, those are NOT the pins you are reading from/writing to, in the SoftwareSerial instances.

If you meant that you connected the pins that the software serial instances use to each other, you should have used actual pin numbers.
Logged

Pages: [1]   Go Up
Jump to: