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 IoT

Arduino IoT Shield Functions Explainer

Arduino makers …. you can connect your Arduino to MQTT brokers(servers) and launch your IoT with Arduino IoT Shield! It’s the 1Sheeld IoT shield that will do the job for you. It’s one of the most important but recent Arduino shields in 1Sheeld. Simply, it turns your Arduino into MQTT client where you can publish and …

Arduino Temperature Humidity System

IoT Arduino Temperature and Humidity System

Monitor my home environmental parameters remotely is one of the most desirable things I have ever wanted to make. It’s not about purchasing such a system that can get the job done for me. But, passion to create it myself. So, today, I am going to connect the popular DHT sensor to an online MQTT …

Arduino Door Lock

IoT Arduino Door Lock using 1Sheeld and Smartphone

  “Oh God! … It seems like I have forgotten the door lock open, again” … the normal saying whenever I am in hurry to go out! Have you encountered this problem before? It always confuses me since I may even think that I have left the door lock opened, and once I go back, …

IoT Fan Control

Arduino IoT Fan Control using 1Sheeld and Smartphone

Here I am with another IoT-based home automation project; Arduino IoT Fan Control. Every day, I get back from work tired and feeling hot. No air conditioner here and the fan takes much time to start cooling the room, sadly! So, I was thinking why not controlling the fan from outside my home with my …

Arduino Light Control

IoT Arduino Light Control using 1Sheeld and Smartphone

Have you ever forgotten to turn your home lights off when you got outside? Sadly, it happens to me all the time. And this causes confusion once I get my bills! Furthermore, here is one secret about me; I am a lazy man. I always want to control my room lamp from my sweet bed. …

Arduino Plant Watering System

Arduino Plant Watering System (Arduino Home Hacks #3)

Welcome to our home automation hacks series #3, for so many times I had problems with watering my plants while traveling abroad and I have always needed a way to control it remotely, then I decided to do it with one of the fanciest ways you may ever hear off, cause I’m gonna water my …