Home/Support/Support Forum/Can Micropython file and Python file run together / call from eachother / import one another?

Can Micropython file and Python file run together / call from eachother / import one another?

0 votes
Can Micropython file and Python file run together / call from eachother / import one another?
asked Jul 27 in MicroPython by edunn106 New to the Community (14 points)

Please log in or register to answer this question.

2 Answers

0 votes
I think you're asking about running Python code on a host processor (e.g., a PC) and interfacing with MicroPython code running on the XBee module.

In that case, the answer is "yes", but you cannot make function calls from Python on the host to MicroPython on the XBee.

You would put the XBee into API mode and use Digi's xbee-python library (https://github.com/digidotcom/xbee-python) to handle the API frames.

Then you would make use of "User Data Relay" frames to send blocks of data between your Python program on the host and MicroPython on the XBee. There should be samples of that in the xbee-micropython project (https://github.com/digidotcom/xbee-micropython).

That data is in whatever format you decide on. You'll have to create your own protocol where you send a request to your MicroPython code and it generates a response.
answered Jul 28 by TomCollins Veteran of the Digi Community (1,870 points)
–1 vote
No, you can't import from the Lib or one for the other.
answered Jul 27 by mvut Veteran of the Digi Community (12,791 points)
well, I mean.. how might I make a tkinter gui button that when pressed it runs a micropython script that writes to an i2c slave device's particular register address on my i2c mcp23017 io expander, telling it to turn an LED on or off?

thanks btw
You would need to connect to two I2C interface together. Then you would have to in the Micro Python interface of the XBee3, perform an I2C address discovery. From that, you can send a command to that I2C interface telling a specific address what to do.
...