I'm using SparkFun's OpenLog, a microSD card data-logger to which you communicate through serial. The only connection needed is Arduino TX to OpenLog RX, because the OpenLog handles the rest.
I have run out of pins in the project I'm using, and have exactly one digital I/O pin left to use for the OpenLog. I'm using SoftwareSerial. However, when I declare an instance of SoftwareSerial, I need to give it 2 pins: RX and TX. I only need TX, and every other pin on my Arduino (Nano) is currently being used for output.
Will something go wrong if I declare SoftwareSerial with an RX pin that's actually being used elsewhere for output? Can I, instead, declare SoftwareSerial with a pin that doesn't exist - say, 100? Any other options?
I wouldn't use pin 100 or anything like that, because it tries to use that pin, eg. here:
void SoftwareSerial::setRX(uint8_t rx)
{
pinMode(rx, INPUT);
if (!_inverse_logic)
digitalWrite(rx, HIGH); // pullup for normal logic!
_receivePin = rx;
_receiveBitMask = digitalPinToBitMask(rx);
uint8_t port = digitalPinToPort(rx);
_receivePortRegister = portInputRegister(port);
}
They don't seem to have allowed for no Rx at all, so you might be better off taking the class, and making a "send-only" version by removing the references to the reading part. I'll take a stab at it, shouldn't take long.
#include <ReceiveOnlySoftwareSerial.h>
ReceiveOnlySoftwareSerial mySerial(10); // RX
void setup()
{
Serial.begin(115200);
while (!Serial) { } // wait for Serial to become available
// set the data rate for the ReceiveOnlySoftwareSerial port
mySerial.begin(9600);
}
void loop() // run over and over
{
// echo from software serial to hardware serial
if (mySerial.available())
Serial.write(mySerial.read());
}
This could be handy for situations (like reading from a GPS) where you don't need to write, and thus you can save a few hundred bytes of program code.
I want to ask question,
I'm using Arduino UNO, and i want to reduce I/O pin..
Is it possible to combine your library and SoftwareSerial library?
because when i tried your library alone thats perfect !
right now i try to combine your library to SoftwareSerial in order to retrieve data serial from my ID-12 (RFID) and send it to other device using Serial too..
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Uno"
ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o: In function `__vector_3':
--------------\Arduino\libraries\ReceiveOnlySoftwareSerial/ReceiveOnlySoftwareSerial.cpp:300: multiple definition of `__vector_3'
SoftwareSerial\SoftwareSerial.cpp.o:--------.cpp:305: first defined here
ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o: In function `__vector_4':
---------------\Arduino\libraries\ReceiveOnlySoftwareSerial/ReceiveOnlySoftwareSerial.cpp:307: multiple definition of `__vector_4'
SoftwareSerial\SoftwareSerial.cpp.o:-------\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:312: first defined here
ReceiveOnlySoftwareSerial\ReceiveOnlySoftwareSerial.cpp.o: In function `__vector_5':
---------------\Arduino\libraries\ReceiveOnlySoftwareSerial/ReceiveOnlySoftwareSerial.cpp:314: multiple definition of `__vector_5'
SoftwareSerial\SoftwareSerial.cpp.o:-------------\Arduino\libraries\SoftwareSerial/SoftwareSerial.cpp:319: first defined here
Ya you were right, SoftwareSerial can allow us to have Serial Port programming more than 1..I've tried it with two Serial port. And it works.. But I haven't tried it for more than two yet.
Ah.. ok.. I understand.. I just tried to minimize my I/O pin so I try to combine it with your library.
Hi Nick
Is it possible to use Receive only software serial for multiple pins (To read data from multiple devices).
I am using seven RFID readers in my project. What is the best way to read from all these devices
Ah, I suppose you could make 7 instances, but I warn you that because it turns interrupts off while receiving it would only successfully read from one at a time.
Hi Nick,
Your library works perfectly in Arduino IDE. In fact when I imported my project in Atmel Studio 7 it compiled with no errors.
However, once I uploaded the code onto ATmega328p using Atmel ICE programmer, as soon as a message is printed out, the terminal breaks!!!
In my case I am using CoolTerm on Windows 8.1. CoolTerm breaks with error message "104: Framing Error". I don't experience the same problem using SoftwareSerial library though.
What's my mistake?
Here is my code:
/*Begining of Auto generated code by Atmel studio */
#include <Arduino.h>
/*End of auto generated code by Atmel studio */
#include <SendOnlySoftwareSerial.h>
//Beginning of Auto generated function prototypes by Atmel Studio
//End of Auto generated function prototypes by Atmel Studio
// Connect Arduino pin 10 to RX of usb-serial device
uint8_t myTX = 10;
SendOnlySoftwareSerial ss(myTX);
void setup() {
Serial.begin(57600);
ss.begin(57600);
ss.println("Start");
}
void loop() {
}