XBee3 micropython uart communication


I am using XBee3 to communicate with a meter through RS485. Refer to https://www.digi.com/resources/documentation/Digidocs/90002219/#reference/r_uart_constants.htm?TocPath=Access%2520the%2520primary%2520UART%257C_____1, I access the uart via stdout.buffer.write() and stdin.buffer.read(). The meter able to receive modbus request that sent from XBee but the modbus response is not what I expected. I transmit the response to coordinator XBee to console out the reading as XBee3 modules only have one uart available. So I suspect by using stdin.buffer.read() method to read from uart is not safe as stdin stream will also contain other information that redirect to that stream. Am I correct?

No, these functions should work properly.

Refer to this post’s accepted answer https://forums.digi.com/74098/xbee3-access-serial-with-micropython-for-simplified-serial?show=76976#a76976 , it stated that stdout is unsafe. So the stdin response probably mess up due to this?

That would depend on which XBee 3 product you are working with. If you are using the XBee 3 Cellular, and you use the Micro Python UART, then no it is not an issue.