I'd like to be able to use Python from a sketch. According to the Arduino playground, one can use PySerial from a computer to talk with an Arduino via Python.

It looks like from that page you can also use various API's to use Python with an Arduino from a computer. However, I'd like to know if you can execute Python directly from a sketch. It would be nice because then you could execute Python directly from a sketch, and not all of it would have to be written in Python.

If this is not possible, is there an easy way to execute Python on an Arduino? Looking at the various API's it was hard to determine exactly what they did, and if you could execute a .py script from a computer or from anything on the Arduino.

  • It's not an Arduino board, but you might be interested in Micro Python. It got kickstarted a few months back.
    – Matt
    Feb 23, 2014 at 18:46

1 Answer 1


It looks like from that page you can also use various API's to execute Python directly on the Arduino.

I don't see that, at all. All those links show you how to communicate with the Arduino over serial using Python on the host side.

You'd need a python interpreter to be able to run python on the Arduino. There is the Python On A Chip project and it seems like they have support for the Mega.

2010/09/01 (1bdb8d31f27b) New platform: Arduino Mega.

Some more info from the PyMite page:

any device in the AtMega family which meets these requirements: 20KiB Flash and 4K RAM, will run today

I doubt you'll find anything that'll let you mix Arduino and Python code in the same sketch.

  • According to the python-on-a-chip website, you need at least 8 kB of ram to run a normal program
    – TheDoctor
    Feb 23, 2014 at 15:36
  • Hmm, so basically your options are to either execute Python from a computer, somehow use the Python On A Chip project with an Arduino, or just execute native C\C++ code? Interesting...
    – hichris123
    Feb 23, 2014 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.