You are reading a single comment by @user106712 and its replies. Click here to read the full conversation.
  • 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().

About

Avatar for user106712 @user106712 started