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

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 …

Top 5 Arduino Voice Control Modules

Ever wanted to talk to your Arduino project? Recently I watched this video of a Harry Potter magic wand that you can command to turn on lights and order food! Disclaimer: I’m not a Harry Potter fan, not a fan of Star Trek or Star Wars either! Total Game of Thrones nerd though, check out …

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 …

GPS shield

1Sheeld GPS Shield Vs. SparkFun GPS Shield

Making a tracking system is something that most of us wanted to have in our projects, and with all that modern technology offering us, it can be made very simply with our beloved board ‚ÄúArduino‚ÄĚ and a GPS shield. Today I will make a detailed comparison between our 1Sheeld GPS shield and the SparkFun GPS …

Joystick Shield

1Sheeld Gamepad Shield Vs. SparkFun Joystick Shield

Most of us used to play video games using joystick either on PlayStation or PC. When I started tinkering with Arduino, when I built a robot or a vehicle, I also wanted to control it with a similar joystick, so I got the Sparkfun joystick shield. Today I will make a detailed comparison between our …

1Sheeld voice recognition shield vs Easy VR3 Shield

1Sheeld Voice Recognition Shield Vs. EasyVR3 Voice Recognition Shield

Ever wanted to control¬†things only with voice commands, like controlling your room lights or a robot kit? Then you are in the right place! ¬†I’m going to make a detailed comparison between our Voice Recognition Shield and the famous EasyVR3 Voice Recognition Shield. I will cover the getting started points for each one till you …