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 Joystick

Top 5 Arduino Joystick Shields

In addition to playing games, joysticks have several usages in hardware projects. This includes controlling actuators and output devices, such as motors and speakers, or controlling pixels on a screen. In this article, I will introduce you to the best 5 Arduino joystick shields. Arduino joystick shields usually have at least one analog joystick with …

Arduino GPS logger

Top 5 Arduino GPS logger shields

You know when you download Google Earth and, out of the thousands of streets you can go to from the comfort of your chair, you choose to check out your home. Now you could do that automatically, just connect your GPS shield to your Arduino and, point it to the sky. Your home coordinates will …

Arduino Accelerometer

Arduino Accelerometer Shield Functions Explainer

Today I’ll be explaining the functions of the Arduino Accelerometer shield in 1Sheeld and how to use it to control things with gesture control. The Arduino Accelerometer shield in 1Sheeld allows you to use your smartphone as an Accelerometer sensor so you can get the changes in gravity in 3 dimensions which are X, Y, …

Arduino GPS

Arduino GPS Shield Functions Explainer

Today I’ll be explaining the functions of the Arduino GPS shield in 1Sheeld and how to use it to get longitude and latitude locations. The Arduino GPS shield in 1Sheeld allows you to use your smartphone as a GPS receiver to be able to track your Arduino project wherever it is, using the GPS sensor …

Control home lights with your voice (Arduino Home Hacks #1)

It’s now the age were the word “Hack” is a relevant word we see and hear everywhere, and i don’t mean the software cyber hacks,I am talking about DIY hacks πŸ˜€ . We made this Home Automation Hacks series to help you add fun features to your home stuff by doing it yourself πŸ˜‰ . …

Control a fan with smartphone gesture (Arduino Home Hacks #2)

Welcome to our home automation hacks series #2, today I am going to show you how to hack your home outlets with Arduino and a phone gesture πŸ˜‰ .This time I used Accelerometer sensor shield from 1Sheeld application. And with a simple gesture it will open\close the outlet to trigger the fan on or off …