Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 999
Alex Eftimiades Avatar asked Nov 13 '11 21:11

Alex Eftimiades


People also ask

Can you compile Python to Arduino?

The Arduino IDE does not yet support Python. Instead, we can use OpenMV, a platform that supports programming Arduino boards with MicroPython. Through the OpenMV editor, we can install MicroPython, and upload scripts directly to the board. There's also a number of examples available directly in the editor.


1 Answers

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.

like image 52
Mark Streatfield Avatar answered Sep 19 '22 03:09

Mark Streatfield