Skip to content
Advertisement

Is there a way to “compile” Python code onto an Arduino (Uno)?

I have a robotics type project with an Arduino Uno, and to make a long story short, I am experimenting with some AI algorithms. However, I need to implement some high level matrix algorithms that would be quite simple using NumPy/SciPy, but they are an utter nightmare in C or C++. Even with the libraries out there, this is just getting ridiculous.

Is there any way I can do this project in Python? I think I heard something about the Mega having this capability, but I have an Uno, and replacing it is not an option at this point (that would set the project back quite a bit.) Also, I heard somethings about using Python to communicate to the Arduino via USB, but I cannot have the USB cable in while the thing is running. I need to be able to upload the program and be done with it.

Are there any options out there, or have I just reached a dead end?

Advertisement

Answer

There was a talk about using Python with robotics at this years PyConAU called Ah! I see you have the machine that goes ‘BING’! by Dr. Graeme Cross.

The only option he recommended for using Python on a microcontroller board was PyMite which I think also goes by the name of Python-On-A-Chip.

It has been ported to a range of boards – specifically he mentions the Arduino Mega which you said is not an option for you, but it is possible it is supported on other Arduino boards.

However, because it is a “batteries not included” version of Python it is more than likely that you will have a real problem getting numpy/scipy etc up and running.

As other posters have suggested, implementing in C might be the path of least resistence.

Update: again, not specifically for Arduino, but pyMCU looks to provide python on a chip. The author states he may look at developing an Arduino version of pyMCU if there is enough interest.

Advertisement