How to Connect and Control an Arduino From Python!

  Рет қаралды 57,648

LeMaster Tech

LeMaster Tech

Күн бұрын

Пікірлер: 111
@seanmcelwee5034
@seanmcelwee5034 Жыл бұрын
Thanks for making this tutorial. This is a great generic parser to implement for most projects to easily add microcontroller sensors to l your python program
@lemastertech
@lemastertech Жыл бұрын
Thanks for watching! That was my hope in making it for sure!
@johnnynolan7844
@johnnynolan7844 26 күн бұрын
Hey bro. You just saved me a year trying to master c++ I should have checked for python interface first.
@lemastertech
@lemastertech 25 күн бұрын
Haha well I’m glad to hear it! You will have to master a little bit of C++ of course just to make the serial commands work, but also their new boards can run micro python!!
@oladunk9986
@oladunk9986 5 ай бұрын
Thank you very much for sharing this video.Very useful and just what I needed for some future projects using Raspberry Pi , Arduino, ESP32.Never done serial port programming in Python before.
@lemastertech
@lemastertech 5 ай бұрын
You’re very welcome thank you for watching!
@thedarthcader7055
@thedarthcader7055 5 ай бұрын
Thanks for making this tutorial! It was super helpful and well explained!
@lemastertech
@lemastertech 5 ай бұрын
You’re welcome thank you so much for watching!!
@whitenoise3120
@whitenoise3120 8 ай бұрын
Thank you for your time and dedication to making this video. For me it was excellent, fast and direct. Your video helps me with a project that I want to do in which I use a muscle sensor in which if the muscle sensor is activated it turns on a green LED. and when it stops receiving signal it turns off. Hopefully you can make an example of what I intend to do. Thanks for help and time.
@lemastertech
@lemastertech 8 ай бұрын
Hi that’s an interesting application! Do you have a specific muscle sensor already specified and picked out yet? If it outputs a digital on/off signal it should be pretty easy to do but it will depend on the sensor!
@TheMadManPlace
@TheMadManPlace 8 ай бұрын
Hi Bit late to the party but I only just found your channel. NEVER used Python but I hear that it is rather powerful so I will be going "hermit" to test it out and learn it. Have a few questions about both Python (and Arduino running GRBL but that is for later) 1) Can Python run on "old" 32 bit Windows systems? - eg. WinXP, Win7 32bit. 2) Can Python use the USB port to connect to the Arduino? 3) Would it be possible to retrieve a file from a storage device? eg. A G-Code command list file from a HDD or memory stick. 4) I assume that parsing strings is an easy standard function so parsing the input should be easy (in PHP it was VERY EASY) 5) Then can I forward the commands to the Arduino so that GRBL can do its thing? 6) Would Python be able to receive and handle returns from the GRBL on the Arduino and branch accordingly? I am assuming that the answer to all these things is probably a resounding YES. Now why am I asking? I need to control a CNC Router and the only PC I have is AT BEST an OLD HP Notepad that is happy with XP but can handle Win7-32bit with a LOT of coaxing. My aim is to write my own 32bit friendly version of GCodeSender that runs well on really old 32bit Windows machines because the only available versions that will INSTALL EASILY are all 64bit. To run 32bit it needs libraries that Microsoft no longer gives you and when you go to alternative source web sites my Anti-Virus has heart attacks. (I listen to my Anti-Virus software) And just by the way, there are A LOT of people out there with the same problem that I have - ESPECIALLY us pensioners. So, its off to install Python for me and I hope you had a good Easter weekend.
@lemastertech
@lemastertech 8 ай бұрын
Hi this is a really cool project idea and the answer is definitely yes to all the questions but honestly 1-4 seem easy, but it’s 5 and 6 I’m not certain on as I haven’t done that specifically myself but doesn’t seem crazy!
@superpayaseria
@superpayaseria 8 ай бұрын
Yeah but can u program an entire humanoid robot just using the arduino? With 10's of thousands of selections and options off of just one loop alone?? Like robocop?? And also anyone that wants to build robocop with me hit this up if you can code or want to be part of the team. Thx!
@lemastertech
@lemastertech 8 ай бұрын
lol this is easily one of the best comments I’ve ever gotten on a KZbin video and I can honestly say I don’t have the time or knowledge to help you build robocop but I sincerely wish you all the best 😂
@anicetolandeiro6652
@anicetolandeiro6652 5 ай бұрын
"DomusOperandi - Automação Residencial com Arduino", on KZbin. No robocop but something like.
@ansar1mm
@ansar1mm 2 ай бұрын
I am interested
@johnrobiedemotor8470
@johnrobiedemotor8470 2 ай бұрын
Did you succeed?
@mixme8655
@mixme8655 2 ай бұрын
thank you sir for sharing this video Im trying this now as beginner
@lemastertech
@lemastertech 2 ай бұрын
Awesome thank you for watching!
@queenidog1
@queenidog1 23 күн бұрын
great tutorial but I don't see how adding 26 lines of Python to 5 or 6 lines in Arduino is some kind of advantage. You can do the same with C++ as you did with Python with a few more commands to write to the monitor. And why run an interpreter when you can compile in Arduino? Python is great for Pi but I don't see a use in Arduino.
@lemastertech
@lemastertech 23 күн бұрын
Hi, a lot of people prefer doing somewhat complicated programming in Python and then just sending over a simple command to the Arduino. Like you could scrape the web, do some sort of data analysis on it and convert that down into what you want the Arduino to do with a very simple serial command and just have the Arduino set up to take the serial command and react to that to control outputs or monitor inputs
@MaxPersia-p1t
@MaxPersia-p1t 11 ай бұрын
bro your so cool i will tell about you to all my programmer friends
@lemastertech
@lemastertech 11 ай бұрын
Hey thank you so much haha!
@maciejbalawejder
@maciejbalawejder 10 ай бұрын
Really helpful. Thanks a lot! :)
@lemastertech
@lemastertech 10 ай бұрын
You're super welcome, thanks for watching!!
@PipeEnglish-g2x
@PipeEnglish-g2x 3 ай бұрын
I am newer. Either Could to learn my first mycropyton or c ++?.
@lemastertech
@lemastertech 3 ай бұрын
When you first start programming with Arduino you’ll probably want to be referencing examples for almost every project you have so I bet you’ll find way more examples for c++ sketches since it’s been around much longer but Python is definitely much easier for beginners, so I suggest both! It doesn’t have to be learn one or the other, just stick with it and enjoy the ride and don’t be afraid to google stuff!!
@its_P.S.A
@its_P.S.A 3 ай бұрын
Thank you very much for your video! it helped me a lot!
@lemastertech
@lemastertech 3 ай бұрын
Thank you for watching!! Glad it helped
@SeussmanCT
@SeussmanCT 7 ай бұрын
Weird situation, it appears when I run from arduino, both LED's immediately just turn on from start. This occurs from coding it myself and using your github Pyduino code... only difference is that I made the Python portion first before the Arduino...
@lemastertech
@lemastertech 7 ай бұрын
Hi, this could be resolved probably by just writing LOW to both LED pins in the setup code? Is it when the arduino first powers on or when the python program first connects to the board?
@flioink
@flioink Жыл бұрын
As far as I know both C++ & Python are used for Arduino. My guess would be that C++ gets the speed advantage but for prototypes it probably doesn't matter.
@lemastertech
@lemastertech Жыл бұрын
I don’t believe the arduino IDE natively supports Python programming unless I’m not aware of that setting!! I thought generally you had to do base level setup on your arduino in their C++ format?
@flioink
@flioink Жыл бұрын
@@lemastertech Yea, I think you're right. There's like a translation layer from what I understood. Because of many Python Arduino projects here I thought the connection is "official". Nowadays everything except my fridge can run Python ;)
@byteforcebuilds8213
@byteforcebuilds8213 8 ай бұрын
Getting an "access is denied error". Any idea what could be causing that?
@lemastertech
@lemastertech 8 ай бұрын
Almost certainly this is because you still have the arduino ide open! Can’t connect to two sources at once :)
@rezahassani2335
@rezahassani2335 6 ай бұрын
hi great tutorial.I want to make a project that is controlled with python and arduino.basically the arduino talks to python to do something and then after finishing the job the python programs talks to arduino via serial to do something and after arduino job is done the arduino sends a word via serial to python and the loop continues.this requires 2way communication between python and arduino.would you give me some tips how to do this.thank you
@lemastertech
@lemastertech 6 ай бұрын
I think a read and write tutorial would be very useful between Python and arduino I can for sure try making one soon thanks for the suggestion!
@Burgerhs
@Burgerhs 5 ай бұрын
So should I buy a arduino uno dev board and a light; can I use it with roboflow objects detection im new sorry?
@lemastertech
@lemastertech 5 ай бұрын
That’s a good idea for a cool Project! You can use any Python packages you want and just send data back and forth from the arduino when you need to control the light or read sensors in!
@Burgerhs
@Burgerhs 5 ай бұрын
@lemastertech 🤣 chief i have no clue how to do that im only good at mechanic . I'm searching yt for a code like that tho
@sherinkishore9469
@sherinkishore9469 2 ай бұрын
If we only use Serial.print in Arduino is it possible to access the serial.print Hello world through Python??
@lemastertech
@lemastertech 2 ай бұрын
You can print the data sent over serial into the console windows yes!
@naivedyasharma4512
@naivedyasharma4512 10 ай бұрын
hey loved the video! but i am getting this error can you help me out? this error has come due to .open() function self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: 'COM14201' During handling of the above exception, another exception occurred:
@lemastertech
@lemastertech 10 ай бұрын
Hi sorry I have not seen this before - are you using a Mac? I did mine on a PC maybe there’s an OS difference is hitting com ports??
@naivedyasharma4512
@naivedyasharma4512 10 ай бұрын
thanks! yeah i am using a Mac@@lemastertech any suggestions how to fix it? raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg)) serial.serialutil.SerialException: [Errno 2] could not open port COM14201: [Errno 2] No such file or directory: 'COM14201' why is it treating COM14201 as a file? maybe thats the problem? btw the best video on this topic thanks man appreciation it!!You have gotten a new sub
@oladojasirajudeen.1215
@oladojasirajudeen.1215 3 ай бұрын
Thank you very much for enlighten me with use of Arduino and Python, a misconception has been broken, my coursemate( who is a scholar to be precise) told me it is not possible to control arduino with python. I have a question. Is it possible to upload a python code on arduino memory such that it will be acting based on the python code. I have project which I will be working with both arduino and python, can please help me out.
@lemastertech
@lemastertech 3 ай бұрын
Hi - the newest arduino boards can run a very lightweight version of Python, up until this point because arduino’s run on C++ based code it hasn’t been very possible to program an arduino with Python
@oladojasirajudeen.1215
@oladojasirajudeen.1215 3 ай бұрын
@@lemastertech So there is low probability that Python Program will work on Arduino. I also have another question, like the Arduinos that support lightweight python codes, is it possible to for the Arduino to upload python codes in its memory.
@oladojasirajudeen.1215
@oladojasirajudeen.1215 3 ай бұрын
@@lemastertech I have a final year project I am working that involves both Arduino and Python. Please I want to know if you can please guide me on it.
@sleepless2554
@sleepless2554 15 күн бұрын
Hi I have a question if I want to build mobile application with python to send string to arduino to maybe turn on something and at the same time I want my app to be able to receive sensor value from arduino to display via bluetooth. what module to use for 1. build the app interface(Kivy? maybe?) 2. receive and send value from and to arduino thank you.
@lemastertech
@lemastertech Күн бұрын
If you’re trying to build a Python mobile app Kivy is the best package for that in my opinion yes! And Bluetooth send and receive should work with basically any available modules but you might want to get an Arduino with Bluetooth or WiFi built in for a few bucks more to make that part of your development easier!
@slslimee
@slslimee 8 ай бұрын
Hey, Can you turn this into a GUI. For example using Tkinter? And also can you make a tutorial out of it if possible? Thanks!
@lemastertech
@lemastertech 8 ай бұрын
Yes you can and I am working on a tutorial on that right now and will likely have it out this week on the channel! I’ll probably use PyGame but it would work the same using tkinter just a little difference syntax!
@slslimee
@slslimee 8 ай бұрын
@@lemastertech Ohh okay... but is it possible to send data input from arduino to python? for example, i want to send photoresistor value on python and use the value to do certain things in the app?
@dracodavidius3583
@dracodavidius3583 5 ай бұрын
How to command the Arduino to read a connected sensor and send the information back to the Python program???
@lemastertech
@lemastertech 5 ай бұрын
Hi that’s just reading serial data! You use serial.print() commands in your arduino IDE and then your python program just needs to listen for serial data!
@dracodavidius3583
@dracodavidius3583 5 ай бұрын
@@lemastertech How do I do that in Python? (Without causing the Arduino to reset every time I try to open a serial connection on the Python end?) NB I will probably be trying to do this on Ubuntu, or possibly RPiOS.....??? (Linux either way.)
@cristinakulczynski3860
@cristinakulczynski3860 8 сағат бұрын
Muito bom, eu não estava achando conteúdo em português!
@pzare1
@pzare1 6 ай бұрын
how the program upload to arduino board?
@lemastertech
@lemastertech 6 ай бұрын
Hi, how to program what to an arduino? Using relays you can just program an arduino like any other program!
@viniciusvieira9160
@viniciusvieira9160 5 ай бұрын
Thanks so much bro!
@lemastertech
@lemastertech 5 ай бұрын
You’re welcome thank you for watching!
@layepicfirebrand3251
@layepicfirebrand3251 4 ай бұрын
Is there a way to make this faster? When I enter "ON" it takes like half a second before it registers. Is there a way to make this significantly faster?
@lemastertech
@lemastertech 4 ай бұрын
Hi do you just mean it’s slow to start or even slow while running? It should be very responsive while running is there are chance you’re running this on an older computer?
@fineidontknowwhat8218
@fineidontknowwhat8218 11 ай бұрын
Awesome video but is there a way you send information from Arduino to python?
@lemastertech
@lemastertech 11 ай бұрын
Hi yes there is! The difference is just basically serial.read versus serial.write - the difference is using either transmit or receive from the arduino but it’s capable of doing both!
@unknown-vq8so
@unknown-vq8so 8 ай бұрын
How to create simple GUI with Arduino uno and python?
@straightforward8928
@straightforward8928 8 ай бұрын
Man I was going to ask the same
@lemastertech
@lemastertech 8 ай бұрын
This is a great question and I’d recommend using a simple PyGame or tkinter gui and then the same backing code as this video shows - I can make a video on it soon!
@straightforward8928
@straightforward8928 8 ай бұрын
@@lemastertech please brother, actually I tried doing it by myself for 2 quiz buzzers but it isn't detecting the COM and showing the result in GUI
@blueraventy
@blueraventy 8 ай бұрын
how to apply this on ANPR system?
@lemastertech
@lemastertech 8 ай бұрын
High are you talking about a plate recognition algorithm?? It depends on the output of data you get from that system, it might just be simple serial data but it might be more complicated than that!
@blueraventy
@blueraventy 7 ай бұрын
@@lemastertech Yes I was talking about plate recognition. Can you please explain more on that?
@connormckenzie9266
@connormckenzie9266 5 ай бұрын
Thanks man.
@lemastertech
@lemastertech 5 ай бұрын
You got it thanks for watching!
@manolo_21
@manolo_21 11 ай бұрын
Can you do something with raspberry pi or with a game engine?
@lemastertech
@lemastertech 11 ай бұрын
Hi! Sure I can do you have a project in mind or a preferred game engine?
@JoqsanCastellanos
@JoqsanCastellanos 8 ай бұрын
My Arduino resets instead of reading the serial port.
@lemastertech
@lemastertech 8 ай бұрын
You mean when you run the python program it never populates you with options for serial ports, or once you select your port it never reads data?
@JoqsanCastellanos
@JoqsanCastellanos 8 ай бұрын
@@lemastertech I mean when I send the data to the serial port with Python, my Arduino resets. It just doesn't work but I guess my device has some issue.
@skjcreation24
@skjcreation24 5 ай бұрын
Thank you so much
@lemastertech
@lemastertech 5 ай бұрын
You’re super welcome thanks for watching!
@mohamads9759
@mohamads9759 4 ай бұрын
Very Great.
@lemastertech
@lemastertech 3 ай бұрын
Thank you!!
@Hero-hx6on
@Hero-hx6on Ай бұрын
thamks
@lemastertech
@lemastertech Ай бұрын
Thanks for watching!!
@mohammedalyafeai7283
@mohammedalyafeai7283 5 ай бұрын
I am lost Idk where should I connect each cabel and resistor
@lemastertech
@lemastertech 5 ай бұрын
You make an arduino project like normal then use a serial cable to connect a regular computer to your arduino board. Don’t think you need to do anything special with a resistor
@mohammedalyafeai7283
@mohammedalyafeai7283 5 ай бұрын
@@lemastertech yes that's clear, my issue where should I plug each cable and light, ad I'm very beginner, if you can share a picture of how they should look like I would appreciate it, because the picture that was in the video is not clear for me
@Gamesnvlogs278
@Gamesnvlogs278 9 күн бұрын
This doesn't work for me the red light is just constantly on
@lemastertech
@lemastertech 5 күн бұрын
Hi sorry for the delayed response, this usually means it has connected to something via Bluetooth, potentially a phone or PC? It should be blinking when you first power up then solid once connected!
@carstenseifert2478
@carstenseifert2478 9 ай бұрын
Why do you not use micropython??
@lemastertech
@lemastertech 9 ай бұрын
It took 20 lines of code to do from scratch and is very useful to know how to control stuff via serial!
@sarvar_abd
@sarvar_abd 7 ай бұрын
I found this a bit hard tbh
@lemastertech
@lemastertech 7 ай бұрын
Was it because I didn’t explain it well or just a confusing concept in your opinion??
@sarvar_abd
@sarvar_abd 7 ай бұрын
I reckon it has to do with my understanding of the concept, need more time maybe, but still could u go even further and make oversimplified guide on this with more details on each element maybe 😅
@floflo3901
@floflo3901 5 ай бұрын
i want a community to join please
@lemastertech
@lemastertech 5 ай бұрын
Like a LeMaster tech discord or something specifically about Python and arduino connections?
@floflo3901
@floflo3901 4 ай бұрын
@@lemastertech yessssssssssssss
@SalisburyKing
@SalisburyKing 6 ай бұрын
I think I will stick with Arduino it's easier.
@lemastertech
@lemastertech 6 ай бұрын
I actually think arduino memory is the main reason you’d want to be able to write a python script though, you’ll find large projects or complicated functionality can’t run very well on the limited memory that comes with arduino so writing computer based scripts for more advanced functionality is very useful!
@pro_gamer4558
@pro_gamer4558 3 ай бұрын
Just get raspberry pi instead
@lemastertech
@lemastertech 3 ай бұрын
Why did you watch this video if you didn’t want to know how to do this with an arduino?
@pro_gamer4558
@pro_gamer4558 3 ай бұрын
I didn’t.
@pro_gamer4558
@pro_gamer4558 3 ай бұрын
@@lemastertech I didn’t
@syedfarazhaiderrizvi6267
@syedfarazhaiderrizvi6267 5 ай бұрын
Any one got this error ile "c:\Users\hp\Desktop\HASNAIN\ard.py", line 21, in serialInst.open() File "C:\Users\hp\AppData\Local\Programs\Python\Python312\Lib\site-packages\serial\serialwin32.py", line 64, in open raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError())) serial.serialutil.SerialException: could not open port 'COM6': PermissionError(13, 'Access is denied.', None, 5)
@Kuan4150
@Kuan4150 5 ай бұрын
Same here
@lemastertech
@lemastertech 5 ай бұрын
This usually means you still are using the arduino in the arduino IDE! Two programs can’t access the same serial port at once!
@lemastertech
@lemastertech 5 ай бұрын
This usually means you still are using the arduino in the arduino IDE! Two programs can’t access the same serial port at once!
Unlock Arduino's Power with Python | Step-by-Step Guide
9:41
Enjoy Mechatronics
Рет қаралды 19 М.
Arduino MASTERCLASS | Full Programming Workshop in 90 Minutes!
1:25:31
Programming Electronics Academy
Рет қаралды 2,7 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 16 МЛН
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 8 МЛН
How to Make GUIs in Python for Arduino Projects
9:27
LeMaster Tech
Рет қаралды 1,7 М.
Every Developer Needs a Raspberry Pi
27:27
Sam Meech-Ward
Рет қаралды 977 М.
Modern Graphical User Interfaces in Python
11:12
NeuralNine
Рет қаралды 1,6 МЛН
PlatformIO: All you need to know in 10 Minutes!
10:56
J's e-shack
Рет қаралды 335 М.
What's the difference? Arduino vs Raspberry Pi
6:21
Tinkernut
Рет қаралды 1,8 МЛН
3 PYTHON AUTOMATION PROJECTS FOR BEGINNERS
17:00
Internet Made Coder
Рет қаралды 1,7 МЛН
How to process Arduino data in Python
7:33
Curio Res
Рет қаралды 29 М.
From Brains to Bot: Arduino's Next-Level Journey with AI.
7:26
DIY Builder
Рет қаралды 508 М.
How to do Object Detection using ESP32-CAM and Edge Impulse YOLO Model
16:50
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 16 МЛН