# Xbee MicroPython problem with xbee.receive() in serial communication (API 1)

**URL:** <https://forums.digi.com/t/xbee-micropython-problem-with-xbee-receive-in-serial-communication-api-1/28406>\
**Category:** XBee Micropython & IDE plugin\
**Tags:** micropython, serial-communication, xbee\
**Created:** [November 14, 2023, 3:32pm UTC](https://forums.digi.com/t/xbee-micropython-problem-with-xbee-receive-in-serial-communication-api-1/28406 "2023-11-14T15:32:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Armiks](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Armiks](https://forums.digi.com/u/Armiks)\
**Post date:** [November 14, 2023, 3:32pm UTC](https://forums.digi.com/t/xbee-micropython-problem-with-xbee-receive-in-serial-communication-api-1/28406/1 "2023-11-14T15:32:14Z")

</div>

Hi everyone, I have a request for help.  
The following code executes correctly in API mode “MicroPython REPL [4]”. Since I want to ensure that the module communicates with the microcontroller I change the API to Mode Without Escapes [1].  
The MicroPython program executes correctly but bypasses operations related to receiving data from the xbee and processing it (in the example I omitted).  
All other functions execute correctly and MicroPython sends data to relay.SERIAL. From the serial console I can send frames to MicroPython.

```auto
import utime
import xbee
from xbee import relay

def print_all(message):
    print(message)
    relay_ble_transmit(message)
    relay_serial_transmit(message)

def relay_ble_transmit(message):
    try:
        relay.send(relay.BLUETOOTH, message)
    except OSError as e:
        print("ERR_001_ble_connection_error_{}".format(e))

def relay_serial_transmit(message):
    try:
        relay.send(relay.SERIAL, message)
    except OSError as e:
        print("ERR_002_serial_connection_error_{}".format(e))

while True:
    received_msg = xbee.receive()
    if received_msg: print_all(received_msg['payload'.decode()])

    utime.sleep_ms(10)

```

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [November 15, 2023, 1:50pm UTC](https://forums.digi.com/t/xbee-micropython-problem-with-xbee-receive-in-serial-communication-api-1/28406/2 "2023-11-15T13:50:59Z")

</div>

The radio is not set up to use both API mode and Micro Python mode at the same time. You can use one or the other.

---

<div class="post-metadata">

**Author:** ![Armiks](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Armiks](https://forums.digi.com/u/Armiks)\
**Post date:** [November 16, 2023, 7:43am UTC](https://forums.digi.com/t/xbee-micropython-problem-with-xbee-receive-in-serial-communication-api-1/28406/3 "2023-11-16T07:43:14Z")

</div>

Thank you for your reply.
