May 22, 2016 Replies: 1 Some boards like Arduino Mega and Arduino Due have several hardware serial ports. These ports are very useful if you need to interact with multiple modules. The alternative for multiple hardware ports is software serial ports: https://www.b4x.com/android/forum/t...s-with-rsoftwareserial-library.65779/#content Software serial ports are more limited, especially if more than one is needed. The names of the serial ports are Serial1, Serial2 and Serial3 (on Mega and Due). Each one is tied to two specific pins. Accessing the additional ports requires a short inline C code. 1. Add a global variable named SerialNative1. Code: Private SerialNative1 As Stream 2. Add this inline C code: Code: #if C void SerialNative1(B4R::Object* unused) { ::Serial1.begin(9600); //<--You can change the baud rate b4r_main::_serialnative1->wrappedStream = &::Serial1; } #end if 3. Call the C code in AppStart: Code: RunNative("SerialNative1", Null) Now you can pass SerialNative1 to AsyncStream and work with it exactly like you work with any other stream. Last edited: Jan 15, 2018 Click to expand...
Some boards like Arduino Mega and Arduino Due have several hardware serial ports. These ports are very useful if you need to interact with multiple modules. The alternative for multiple hardware ports is software serial ports: https://www.b4x.com/android/forum/t...s-with-rsoftwareserial-library.65779/#content Software serial ports are more limited, especially if more than one is needed. The names of the serial ports are Serial1, Serial2 and Serial3 (on Mega and Due). Each one is tied to two specific pins. Accessing the additional ports requires a short inline C code. 1. Add a global variable named SerialNative1. Code: Private SerialNative1 As Stream 2. Add this inline C code: Code: #if C void SerialNative1(B4R::Object* unused) { ::Serial1.begin(9600); //<--You can change the baud rate b4r_main::_serialnative1->wrappedStream = &::Serial1; } #end if 3. Call the C code in AppStart: Code: RunNative("SerialNative1", Null) Now you can pass SerialNative1 to AsyncStream and work with it exactly like you work with any other stream.
Erel B4X founder Staff member Licensed User Longtime User Sep 18, 2018 #2 Additional hardware serial port on ESP32: https://www.b4x.com/android/forum/threads/hardware-serial-on-esp32.97318/#post-613593
Additional hardware serial port on ESP32: https://www.b4x.com/android/forum/threads/hardware-serial-on-esp32.97318/#post-613593