I am using two soft serials, taking input from one UART and passing it to the USB UART.
var hubSerial = new Serial();
hubSerial.setup(2400, { // problematic when baud rate=9600
rx: NodeMCU.D5,
tx: NodeMCU.D6
});
var usbSerial = new Serial();
usbSerial.setup(9600, {
rx: NodeMCU.D9,
tx: NodeMCU.D10
});
usbSerial.on('data', function (data) {
try {
hubSerial.print(data);
} catch (e) {
d0("failed to send on hub's data");
}
});
hubSerial.on('data', function (data) {
try {
usbSerial.print(data);
} catch (e) {
d0("failed to send on usb's data");
}
});
d0() is essentially console.log over port 23.
The PIN assignment cannot be changed hence the use of soft serial. I think the issue is that .on('data',..) is coming back 1 or 2 bytes at a time. I will experiment using .available().
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I am using two soft serials, taking input from one UART and passing it to the USB UART.
d0() is essentially console.log over port 23.
The PIN assignment cannot be changed hence the use of soft serial. I think the issue is that .on('data',..) is coming back 1 or 2 bytes at a time. I will experiment using .available().