Bonezegei_SoftSerial is an Arduino library that allows you to create a software serial port on any digital pin. It supports the most common baud rate 9600. This library can be used to interact with devices like sensors, modules, and other microcontrollers that need a serial interface. Bonezegei_SoftSerial handles both reading and writing data and is compatible with the default Arduino Serial library.
Disclaimer
The code and libraries provided by Bonezegei is intended for informational and educational purposes only. Bonezegei does not own or manufacture the hardware associated with the code. The code is provided "as is" without any warranty, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall Bonezegei be liable for any claim, damages, or other liability arising from the use of the code or the hardware. Users are solely responsible for ensuring that their use of the code complies with all applicable laws and regulations.
1. Receive Only
/* Bonezegei Software Serial Recieve Only Author: Bonezegei (Jofel Batutay) Date: August 2023 Frame format: 8 bit word 1 Stop bit NOTE : the Receive function is not interrupt based use separate device for Uart receiver or transmitter */ #include <Bonezegei_SoftSerial.h> /* param1 = RX Receive pin declaration DO NOT use the write functions like write, print and println since the pin for write is not properly initialized */ Bonezegei_SoftSerial SoftSerial(16); void setup() { Serial.begin(9600); SoftSerial.begin(9600); } void loop() { if (SoftSerial.available()) { int ch = SoftSerial.read(); Serial.write(ch); } }
2. Send Only
/* Bonezegei Software Serial Send Only Author: Bonezegei (Jofel Batutay) Date: September 2023 Frame format: 8 bit word 1 Stop bit Do not use receive function when using send only mode */ #include <Bonezegei_SoftSerial.h> /* A Huge Thanks to JCWren on github for pointing this out Send Only Mode param1 = RX pin (set to negative value to enable TX only mode) param2 = TX pin */ Bonezegei_SoftSerial SoftSerial(-1 , 16); void setup() { Serial.begin(9600); SoftSerial.begin(9600); SoftSerial.print("Hello World\n"); } void loop() { }
3. Send and Receive
/* Bonezegei Software Serial Author: Bonezegei (Jofel Batutay) Date: August 2023 Frame format: 8 bit word 1 Stop bit Simple Send and Receive NOTE : the Receive function is not interrupt based use separate device for Uart receiver or transmitter */ #include <Bonezegei_SoftSerial.h> /* param1 = RX param2 = TX */ Bonezegei_SoftSerial SoftSerial(16, 15); void setup() { Serial.begin(9600); SoftSerial.begin(9600); SoftSerial.println("UART Test"); } void loop() { if (SoftSerial.available()) { int ch = SoftSerial.read(); Serial.write(ch); } if (Serial.available()) { int ch = Serial.read(); SoftSerial.write(ch); } }
References
- Batutay, Jofel. (2023). Arduino Library Installation. Bonezegei. https://bonezegei.com/?c=resources/tutorial&&d=resources/tutorial/libraries/install&&nav=1
Cite this
- Batutay, Jofel. (2023). Bonezegei SoftSerial. ResearchGate. https://doi.org/10.13140/RG.2.2.28003.12325.