+ 11

Can i use python in arduino, instead of c+?

python is a high level programming language with its various applications in different sections including scientific calculations and artificial intelligence. I want to use it in my arduino board instead of c++, as I found it more simple with better impact. is it possible. ? then how?

23rd Jun 2017, 8:14 PM
Subhayan De
Subhayan De - avatar
49 Réponses
+ 18
you can't program your arduino in python because as @Martin Taylor wrote an atmega 328 lacks resources for a python interpreter. a possible workaround is to upload firmata firmware on your arduino and have a python program interact with it through serial communication. You can send serial commands (via usb or bt or wifi or IR or...) from your python script that will control the Arduino board: set pins, read inputs, drive outputs etc... In that way you won't touch the arduino and c++, as all the instructions will be defined in your python script.
24th Jun 2017, 10:56 PM
seamiki
seamiki - avatar
+ 12
@You are 100% right to assume my way of interpretation about the Python. However I personally never used Python in combo with any Arduino board but merely C++, but like I stated before I am glad that we could focus our minds together to solve yet another question...😆😆😆
28th Jun 2017, 10:18 AM
🇺🇸 Anatoli🇧🇪🇪🇺 ,
🇺🇸 Anatoli🇧🇪🇪🇺 , - avatar
+ 11
@Subhayan: You should never forget, that the Arduino is merely a processor board equipped with Analog and Digital in/out ports to control certain on off switches or make readouts of some sensors. It has never been nor will it ever be a full function computer that could run a whole complex programm to do whatever monitoring you like. To solve your problem and not use a PC or Laptop, you have only one option. That option is to use a Raspberry PI 3 board to substitute a computer. This version is capable of running Python programs larger than you could on your Arduino. The combo ARDUINO + RASPBERRY PI is the perfect solution and it even requires low power. It has everything you would ever need on board like, Bluetooth, Wifi, etc... Have fun in experimenting with those two in equilibrium you will find a wonderful world of possibilities my friend. I however pointed this combination out several times in Q/A postings here at SoloLearn and I will always repeat it. Arduino and Raspberry PI are a match made in electronic heaven 😆😆😆😆😆😆😆
28th Jun 2017, 10:45 AM
🇺🇸 Anatoli🇧🇪🇪🇺 ,
🇺🇸 Anatoli🇧🇪🇪🇺 , - avatar
30th Jun 2017, 9:38 PM
Ranjan Bagri
Ranjan Bagri - avatar
+ 7
@Maks : This is a learning platform and not a social media application. However you can communicate on asking questions on your problems by going to the Q/A section and post a question. Someone will try to answer it or several will be doing it as you see here. There is however a littele chat thread thats quite busy, just look at the Q/Asection you will find it. Welcome and good luck with your studies here at SoloLearn 😆😆😆
2nd Jul 2017, 8:13 AM
🇺🇸 Anatoli🇧🇪🇪🇺 ,
🇺🇸 Anatoli🇧🇪🇪🇺 , - avatar
+ 6
@Martin with the Arduino Mega you should have enough memory available and remember the sketches for Arduino do not keep lots of storage of data but only send commands to execute certain ports. It is more activating a robot and keep it busy. So it is actually more a processor level coding to have other equipment switched On or Off or let them do things, not for big data bases etc. to store data. So Python can certainly be used to program Arduino and also the RASPBERRY PI computer.
25th Jun 2017, 12:18 AM
🇺🇸 Anatoli🇧🇪🇪🇺 ,
🇺🇸 Anatoli🇧🇪🇪🇺 , - avatar
+ 5
@Seamiki: I actually didn't know that, you see we all get smartter when we share info. Thanks for elaborate the question a bit more in depth. 😆😆😆
28th Jun 2017, 10:05 AM
🇺🇸 Anatoli🇧🇪🇪🇺 ,
🇺🇸 Anatoli🇧🇪🇪🇺 , - avatar
+ 5
thanks for your precious suggestion @anatoli. actualy experimenting new things is the best source of gaining knowledge.😉
28th Jun 2017, 10:52 AM
Subhayan De
Subhayan De - avatar
+ 5
C++ is more preferable
2nd Jul 2017, 6:19 AM
Krafty Coder
Krafty Coder - avatar
+ 4
@Martin, its not that you run Python on the Arduino. Python is merely a programming language to create a sketch to be run in an Arduino board. So the Sketch is actually Assembler code, not Python because the Python code is translated and reworked into a piece of ASSEMBLER that the processor can handle. If your Sketch doesn't run on the Megaboard from Arduino, your code is way to big and should be rewritten into a smaller size. That's what's happening. Your statement that Python connot be run on Arduino, has no basis.
25th Jun 2017, 10:11 AM
🇺🇸 Anatoli🇧🇪🇪🇺 ,
🇺🇸 Anatoli🇧🇪🇪🇺 , - avatar
+ 4
thanks for so many answers to my question. It has helped me a lot..
27th Jun 2017, 3:02 PM
Subhayan De
Subhayan De - avatar
+ 4
@Martin Taylor i'm aware of that: I think you saw my answer where I suggested using firmata. The other option (Python Arduino Prototyping Api) although similar to the firmata approach, is closer to the Arduino syntax and for a python-only approach, would make the transition to Arduimo c/c++ a bit more gradual. Maybe I went to far when I read Anatoli's "Python is merely a programming language to create a sketch"...
28th Jun 2017, 9:34 AM
seamiki
seamiki - avatar
+ 3
atlast a little bit of success. .but don't know if it could run more complex programming... I have used pyserial with great success in controlling the pins on the arduino. Your workstation (laptop, etc) runs a python script that then communicates in real time to the arduino. It's not quite the same as running the script directly on the arduino but I was doing quite a bit more than I thought the arduino could handle (some music analysis, hitting a REST api, etc).
28th Jun 2017, 10:32 AM
Subhayan De
Subhayan De - avatar
+ 3
@Goran totally right: see this thread sorted by date: another pythonist who "surrended" to the simplicity of the arduino abstraction layer. https://www.sololearn.com/discuss/145565/?ref=app
28th Jun 2017, 6:53 PM
seamiki
seamiki - avatar
3rd Jul 2017, 1:28 PM
Akash
Akash - avatar
+ 3
ultimate collection of pdf check it once https://www.sololearn.com/Discuss/510275/?ref=app
4th Jul 2017, 9:56 AM
Akash
Akash - avatar
+ 2
Hello fellow citizen. I'm happy to hear you too like our beloved Python. Sure you can code to Arduino using Python (In most cases) feel free to read about it here: http://playground.arduino.cc/interfacing/python&ei=qEPiD-f6&lc=pt-BR&s=1&m=224&host=www.google.com.br&ts=1498258157&sig=ALNZjWn33Es4QrAC7NfKZGYGKrXXKEFAhg thank you and have a nice day good sir.
23rd Jun 2017, 10:53 PM
Nicolas Cendron Fernandes
Nicolas Cendron Fernandes - avatar
+ 2
@Martin Taylor I think @Anatoli is referring to something like this: https://github.com/vascop/JUMP_LINK__&&__Python__&&__JUMP_LINK-Arduino-Proto-API-v2/blob/master/README.md At the current state of the project i'd stay with the Arduino IDE. Lack of libraries is also an issue. in conclusion is an interesting approach but from a practical point of view, it lags behind and could be a useless pain especially for beginners.
26th Jun 2017, 5:03 AM
seamiki
seamiki - avatar
+ 2
pyxie 0.1.24 https://pypi.python.org/pypi/pyxie For whoever got interested in the argument, I found this python module aimed at translating simple python code in to c++ instructions targeted for a limited set of Atmel MCU (Atmega 8A, Atmega 328). I did not try it (yet) but according to the doc page there are limitations on both python and c++ side. I guess those limitations increase when trying to use libraries but again I did not try it yet. For beginners those limitations could potentially lead to criptic errors that would make the experience a royal pain and I'd feel more like reccomending my previous suggestions (firmata) that has a proven solid implementation although thre are cases when it may not be what you're looking for in an embedded project. Hope that my messing around sparked more interest than fear. If anyone got scared for any reason: research and knowledge kill some fear and creat new ones to repeat the process...
28th Jun 2017, 10:10 AM
seamiki
seamiki - avatar
+ 2
https://code.sololearn.com/cECTmIQW4HEC/?ref=app check this and report bugs if you got
2nd Jul 2017, 2:11 AM
Akash
Akash - avatar