Greetings....
I'm currently working on a project which is running out of pins in Arduino NANO.
I have a question,
Whether a single declared software serial ports be used to communicate between two different devices.
The first device is SIM800L GSM in which Arduino is going to only transmit commands.
The second device is NEO6M GPS module in which the Arduino is going to only receive data.
Can softwareSerial serial1(9, 10); be used ?
9 for NEO6M and 10 for SIM800L ?
"running out of pins in Arduino NANO"
You are using the Ax pins as digital IO also? A0 to A5 = D14 to D19.
A6, A7 are analog input only.
I don't see any reason why Tx and Rx couldn't go to two different devices electrically. Be sure to connect GNDs.
If you are using two different libraries for those, that might complicate things.
I think there is also a Timer associated with those pins, that also should be considered.
Baud rate - Software serial can only transmit, or only receive. If different baud rates are needed, I would leave it set for the receive side, then change to the Tx frequency, and then switch it back to the Rx frequency.
Yes that should work (with previous remarks) as long as you don’t rely on a library for the sim800 (and you’ll be blind to how the sim800 is answering your commands). TinyGPS++ only depends on you feeding it, so should be fine.
Just be careful that you can’t send and receive at the same time with software serial - so your gps will probably behave erratically when you are sending stuff out and you’ll miss some sentences.
Thanks for replying.
This is the first time I've using the Arduino forum for discussions.
I've really used all of the digital pins form 0 to 13 and analog pins form A0 to A7 in Arduino NANO.
For example I said I'm using (9, 10) for Rx and Tx.
But you can suggest me a solution
So that I'll swap my connected modules to another pins according.
Right now only two digital pins are left
Within that two I'm forced to use one as Tx to send commands with SIM800L and one as Rx to receive data form NEO6M.
it seems (to me) that you didnt pay the necessary attention to #2 and #3 above. Your problem is not on the pins but on the fact that with the softwareserial , some received messages will be lost if at the same time you are Txing.
So, in this case i suggest you put your tx at the end of the reception period. For example, if you receive every 1 sec, you start a timer (see "millis without delay") and arrange to Tx after about 900ms past start of reception. The remaining 100 ms are enough for tx a SIM800 command. Evaluate Rx/Tx ms ratio according to your period, number of characters rx/tx and baud rate.
Did you connect a non serial device on pin 0 and 1?
If so - i would suggest you swap whatever is there for the 2 pins you wanted to share as Tx/Rx and use hardware Serial. This way you’ll have something more robust.