Arduino’s SoftwareSerial vs AltSoftSerial: Which library to use with 1Sheeld+ ?

The newer version of 1Sheeld (1Sheeld+) built to support both iOS and Android devices,but not just that …! There’s another secret feature supported to solve the problem of using extra shield/board over 1Sheeld+, and this shield/board have the same way of communication used by 1Sheeld+ (The hardware UART serial pins pin0&pin1) with your Arduino.

Exactly as you read, 1Sheeld+ has on board male headers that will help you choose another Arduino pins as a way of serial communication between the Arduino and 1Sheeld+,rather than the fixed hardware uart serial pins(pin0&pin1).

Special thanks to Arduino implementing SoftwareSerial, and Paul Stoffregen for implementing the AltSoftSerial library, giving us the advantage to do such feature with 1Sheeld+.But each library has its pros & cons, and in the next lines, I will reveal which one is most convenient to use with Arduino & the 1Sheeld+ stacked over.
Lets go for the details:

SoftwareSerial

PROS

– Allows any two pins (except pin13) to be a serial uart port.
– Gives the advantage to create multiple instances and assign several soft serial ports,but only 1 can be activated to send/receive at a time.
– Runs over high baudrates up to 115200 bps for a 16Mhz processor.
– Supports signal inversion which allows serial devices that uses inverted signals to communicate easily with your new softwareSerial ports(to know more about signal inversion please check this link).

CONS

– An interrupt driven based library that depends on pin state changes,which lock out interrupts for a long time when start sending, affecting reception of data.
– More sensitive to other libraries that uses interrupts in it’s implementation.That’s why it’s not recommended in systems that send and receive at the same time.

AltSoftSerial

PROS

– Uses 16 bit hardware timers to generate output & calculate the received input waveforms.
– Has minimal interference with simultaneous use of HardwareSerial and other libraries
– Send and receive at the same time with minor data loss.

CONS

– Limited to certain pins (supported by 16-bit timers) as pins 8,9 & 10 in arduino UNO.
– Affects libraries uses the same 16-bit timers which will off course disable some PWM pins.while if the board has several 16-bit timers you can configure which timer AltSoftSerial uses by editing “config/known_boards.h” within the library. which will allow AltSoftSerial to be used together with other libraries which require the timer which AltSoftSerial uses by default.
– Can be sensitive to interrupt usage by other libraries,but not as sensitive as SoftwareSerial due to the short time interrupt latency.
– Still doesn’t support signal inversion like the SoftwareSerial library.

Conclusion

It seems that SoftwareSerial library has a lot of powerful features than the AltSoftSerial library, but that didn’t make it for the judge (1Sheeld+), as it was just knocked out because of its lack of sending and receiving data simultaneously.That’s why we gonna be experimenting AltSoftSerial with Arduino&1Sheeld to see how it goes.

Experiencing AltSoftSerial with Arduino&1Sheeld

Before testing the AltSoftSerial library, I will explain how does the extra over board male headers connected to 1Sheeld+ serial lines (Rx,Tx) and to Arduino gpio pins:

As the above figure explains,the pins come in 9X2 (9 columns & 2 rows), the first row has several common male pins connected to the Tx pin of 1Sheeld (yellow circles to the yellow pin), and the second row has several common male pins connected to the Rx pin of 1Sheeld (red circles to the red pin).The other pins each are connected directly to individual Arduino pin(green squares to the green header), giving you the ease of assigning any gpio Arduino pins to the Rx or Tx pins of 1Sheeld.

I have connected Arduino pin8 (to 1Sheeld Rx) and pin9 (to 1Sheeld Tx) using regular  jumpers.Let’s start testing the baud rate for each, the hardware serial and the AltSoftSerial.

Making both AltSoftSerial and Hardware serial work will produce some problems, since both lock interrupts to send/receive data, but the hardware serial is more faster handling interrupts,so make sure that AltSofSerial baud rate is lower than the hardware serial.

Unfortunately the feature defining different baudrates to the board is not supported by the 1Sheeld apps(IOS/Android) yet, but you can still download our SDK (.apk) sample from here, it has a feature to set the baudrate.

1- Scan for your 1Sheeld+ board.
2- Select your 1Sheeld+ board and press Connect.
3- Select your 1Sheeld+ board from the connected devices list.
4- Roll down till you see the “SET BAUD RATE” option and click the baud rate window to choose another baud rates.
5- Choose your baud rate and hit set baud rate.

EXAMPLE CODE

This is a modified internet example code using AltSoftSerial on baud rate 57600, upload the code after setting the baud rate and hit Arduino’s Reset button.But now you don’t have to switch the UART switch to the communication mode anymore (as you already using another serial port for communication) just leave it at the SWS which stands for Software Serial and watch your application working 😉

Hope the feature help you out guys, if you have any questions please feel free to leave it in the comments 🙂




Related Blogs

Arduino Robotics

Arduino Robotics Series, from a car to a robot arm

Arduino keeps standing out from the crowd of all-around development boards due too its ease of use and budget price. As a result, this has enabled almost anyone to get his own idea into life no matter how crazy or even useless to the whole world it was, except for its maker! Also, it has …

Arduino Robot Arm

How to build an Arduino Robot Arm placed on RC Car

Arduino robots are always funny and definitely more enjoyable when combined with robotic arm! And today, I will walk you through the making of a simple Arduino Robot Arm that’s made of cardboard and how you can attach it over your Arduino Bluetooth RC Car / Robot that you have made so far through this series. …

Arduino Line Following Robot

How to build an Arduino Line Following Robot using Cardboard

Arduino Line Following Robot is one of the easiest and most well-known projects that anyone can make to learn the basics of programming, electronics, and mechanics all in one project. It’s known that this project is common for most of the makers and tech students and today I am going to give it a revisit …

Arduino Obstacle Avoiding Robot

How to build an Arduino Obstacle Avoiding Robot using Cardboard

Back again with another Arduino Bluetooth RC Car tutorial but with an advanced feature that makes your car autonomous by adding ultrasonic sensors to the RC Car you have made before!. Yeah, I know that you may have seen other tutorials using ultrasonic to make the car/robot avoid obstacles ahead, but I am going to …

Arduino Bluetooth RC car

How to make an Arduino Bluetooth RC Car using Cardboard

  Cardboard crafts are one of the most popular and easy to make DIY stuff. Mixing this with the unmatchable enjoyment of RC Cars and the ease of using Arduino, I am going to show you how to make a Cardboard Arduino Bluetooth RC car that you can control via Bluetooth from your smartphone.  …

Arduino Security Camera

Arduino Security Camera System (Arduino Home Hacks #4)

Arduino Security Camera Have you ever wanted to check your home in real time? Afraid that maybe someone has stormed in, don’t remember if you shut the door or not or maybe wanna check if your Hyper-energetic dog has broken any of your dishes AGAIN!! 🙂 Then this is the perfect place for you cause today …