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

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 …

Display traffic status on an IKEA clock with Arduino and 1Sheeld

Whenever it’s time to get off the office, I always check the traffic status to choose the best time to go home. But I couldn’t find a way to do that autonomously. So then …. I was up to make a system that shows me the current traffic status with the help of a simple tool that is used …

Log noise level on cloud using Arduino & 1Sheeld

Nowadays people started integrating stuff with the internet for their daily uses, and fortunately, it’s not hard to do so..! as there are a lot of hardware/software tools that ease the development of such applications. One of these tools is the 1Sheeld’s Internet shield, which allows your arduino board to connect to a mobile application …

NFC Module for Arduino

Top 3 NFC modules for Arduino

We can see how much RFID applications are being used in our daily life like in the elevators, many facilities entrances or even in some supermarkets but have you ever thought of how it works? RFID stands for “Radio Frequency ID” so it’s uniquely identifying items through radio frequency and it composed out of three main …

Top 5 Data logger Modules for Arduino

Top 5 Data Logger Modules for Arduino

Want to store your Arduino project’s data, measurement’s or sensor readings for future analysis?  Then you are in the right place, cause today I’m gonna list here the best 5 Arduino Data logger Modules. Data logger gives you the ability to track your system statistically and check how it worked over certain intervals . You can also …