xbee.transmit() examples
xbee.transmit() using constants
In this example, the MicroPython code transmits a broadcast message using the xbee.ADDRESS_BROADCAST constant.
- Access the MicroPython environment.
- Copy the sample code shown below:
import xbee
test_data = 'Hello World!'
xbee.transmit(xbee.ADDR_BROADCAST,test_data)
- At the MicroPython >>> prompt type Ctrl+E to enter paste mode. The terminal displays paste mode; Ctrl-C to cancel, Ctrl-D to finish.
- At the MicroPython >>> prompt, right-click and select the Paste option.
- Once pasted, the code should execute immediately. If the transmission attempt is successful, the MicroPython prompt is returned or else the appropriate error message is displayed.
xbee.transmit() using byte string
In this example, the MicroPython code transmits a broadcast message using the xbee.ADDRESS_BROADCAST constant.
- Access the MicroPython environment.
- Copy the sample code shown below:
import xbee
test_data = 'Hello World!'
xbee.transmit(b'\x00\x13\xa2\xff\xad\x95\x5a\xa8', test_data)
- At the MicroPython >>> prompt type Ctrl+E to enter paste mode. The terminal displays paste mode; Ctrl-C to cancel, Ctrl-D to finish.
- At the MicroPython >>> prompt, right-click and select the Paste option.
- Once pasted, the code should execute immediately. If the transmission attempt is successful, the MicroPython prompt is returned or else the appropriate error message is displayed.