Control Arduino with Python using Firmata / PyFirmata

Поділитися
Вставка

КОМЕНТАРІ • 74

  • @nunirvana
    @nunirvana 3 роки тому +8

    Awesome stuff. Thank you. people like you help us get more closer in building things our own and pursuing our passion.

  • @iKostanCom
    @iKostanCom 3 роки тому +4

    That is very interesting. I did not hear about Firmata and it looks like an easy way to communicate between any Pi device to Arduino. Thanks.

  • @EcoHamletsUK
    @EcoHamletsUK 3 роки тому +4

    Brilliant. I think Firmata may be what I've been looking for to control model railway layouts, with a Pi to control everything, and several Arduinos connected by USB or Bluetooth to drive servos, stepper motors and motor drivers. It would save a lot of work writing individual sketches for each Arduino. Even better, it looks like I could use Node-RED instead of writing any Python code, at least to get it all working, then write a really flashy Python program later if I want to. Node-RED could work for robots too.

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому +2

      Yes! Exactly, you can plug the firmata sensor readings and motor control into Node-Red to provide a dashboard UI and controls! You've got me thinking...

    • @EcoHamletsUK
      @EcoHamletsUK 3 роки тому +2

      I was writing a touch screen controlled Python program to run on the Pi, that would probably have used I2C to communication with the Arduinos, each of which would have different devices attached. And that was my second or third attempt to build a system that worked! This seems a much simpler process that can be developed in stages, and got working very quickly:
      1) Firmata on each Arduino
      2) Plug devices into Arduinos
      3) Set up Node-RED on Pi connected to network, with simple flows and a dashboard
      4) Run dashboard on a phone or PC
      5) Build the railway layout, install the servos, steppers and motor drivers, then connect everything with USB cables
      Then maybe one day, possibly, or maybe not:
      6) Spend hours/days doing clever stuff with Python to create an all singing and dancing control system, or build a good olde fashioned control panel with lots of knobs and switches! Or both! And this could all be added to the existing Node-RED/Firmata system.
      Steps 1 to 4 should only take an hour or two, and I've spent many times more than that getting nowhere so far!

  • @dreamwork69
    @dreamwork69 2 роки тому

    We need a whole series for this 🙏🙏🙏

  • @thebravo299
    @thebravo299 3 роки тому +2

    Nice video. well structured, informative and not rushed. just got yourself a new sub!

  • @Lord-Black__
    @Lord-Black__ 2 роки тому +1

    Thanks a lot I have been looking for that explanation!!

  • @i-negm
    @i-negm 2 роки тому +12

    00:00 - Intro
    00:40 - Session Goals
    01:29 - Hardware Setup
    01:45 - What is Firmata
    03:19 - How it works
    04:58 - Python PyFirmata Library
    05:52 - Channel Announcements: Like, Comment and Subscribe
    06:41 - Channel Announcements: New Video Every Sunday
    06:49 - What we can do with Firmata?
    07:44 - Why do we use Firmata?
    08:45 - How to install Firmata on Arduino
    09:25 - Upload Firmata Standard on Arduino
    09:35 - Change to Bluetooth Serial Port (Remote Update)
    10:29 - Demo Time
    15:02 - Demo Time - Visual Studio Python Code (blink example)
    I will continue the rest of the chapters if I watched the remaining of the video.

  • @BUILDwithMAULIK
    @BUILDwithMAULIK 2 роки тому +2

    very informative turorial. Can we use pyfirmata to control the robot without it being plugged into the computer (from battery power)?
    since the code is working form the PC directly and not uploaded on the Arduino itself.

  • @NicholasWong-vv1nn
    @NicholasWong-vv1nn 3 місяці тому

    I'm wondering how to use adafruit I2C sensors like the TSL2591 with Firmata. Would I need to recreate the circuitpython library in firmata?

  • @GraveyardghouI
    @GraveyardghouI 2 роки тому +1

    Thank you for this great video.

  • @kuwornueyramdela2304
    @kuwornueyramdela2304 3 роки тому +2

    thanks so much kevin

  • @TheCeremoniesOfIsrael
    @TheCeremoniesOfIsrael Рік тому

    OMG u know a lot how I wished I had a raspberry pi and an Arduino mega

  • @omarsalah6777
    @omarsalah6777 2 роки тому +2

    awesome tutorial sir , couldn't be better.
    i was wondering if this was applicable to other types of arduinos (other than the mega and uno)

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому +1

      Yes, definitely - basically any board that be programmed via the Arduino IDE can take the Firmata code

  • @عبدالرحمنالمرنخ
    @عبدالرحمنالمرنخ 2 роки тому +2

    If you disconnect the Arduino from the device, the code does not work with another power source
    I have to plug it into the computer
    What is the solution to permanently store the code on the Arduino like the Arduino IDE?
    I thank you very much for this excellent explanation :)

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      The Python code cannot run on the Arduino as its only an 8bit processor. You therefore cannot permanently store or run the Python code on the Arduino

  • @AdamKaszok
    @AdamKaszok 9 місяців тому +1

    Thank you for this video. Will it work for Python 3.12?

  • @michaeljwosniak7241
    @michaeljwosniak7241 2 роки тому +2

    Hello Mr McAleer. I'm really interested in this topic. could you tell me, does the Arduino have to stay connected to the PC for the pyfirmata code to work? or can the system operate just fine without being continually connected? (of course, after the code is uploaded)

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому +1

      The Arduino acts as a middleman when using Pyfirmata - so if you disconnect it from the PC it will do nothing. It needs the PC to run the code and the Arduino listens for commands, gets or sets data from its inputs & outputs and returns that to the PC.

    • @michaeljwosniak7241
      @michaeljwosniak7241 2 роки тому

      @@kevinmcaleer28 thanks alot sir. my hope was that it could be controlled as unit once the pyfirmata code was uploaded.

  • @XPowerfullXPlayerX
    @XPowerfullXPlayerX 3 роки тому +1

    Hey this is very useful content , good work

  • @yefriencarnacion8717
    @yefriencarnacion8717 3 роки тому +1

    Thank you so much for the tutorial , i loved it! So... to work arduino with python the arduino need to be connected with a pc right?

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому +1

      Yes or a Mac or raspberry pi (something that can run full Python)

  • @xianguihuang5477
    @xianguihuang5477 2 роки тому +1

    Hi, Kevin, would you mind explaining how Visual Studio where you write python codes connects to Arduino?

  • @MartinoDesign99
    @MartinoDesign99 2 роки тому +1

    Great video, thank you! I am new to Arduinos / programming and I have a cheap "kickstarter" robot that has an Arduino with a custom shield to control the 4 axis'. Is there any extra coding that needs to be added for the Arduino to pass through the shield to control the motors or is it as simple as calling the PIN that they are connected to?

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      Thanks Marrino! Its as simple as calling the pin!

    • @MartinoDesign99
      @MartinoDesign99 2 роки тому

      @@kevinmcaleer28 Thank you for the fast response. I am having trouble making it my robot arm move. The shield appears to look just like the one you are using in the video, however I am connected to servo motors. Do you mind send me a quick code snippet to make the servo motor on pin 13 move. Thank you again.

  • @JesusGonzalez-rd6qn
    @JesusGonzalez-rd6qn 2 роки тому

    Quick question, how do you import an arduino library in out python sketch using PyFirmata?

  • @mohamedjbaili701
    @mohamedjbaili701 Рік тому

    I can't save the program in Arduino board like Arduino IDE . The project doesn't work without pc

  • @michaeljwosniak7241
    @michaeljwosniak7241 2 роки тому

    One more thing sir Kevin. I am trying to build a RFID-enabled automated retrieval/storage and inventory system using Arduino boards. For my prototype, do you believe pyfirmata will be able to retrieve rfid data serially, put it in a pandas dataframe and finally with the help of a wxpython GUI bind pyfirmata events(or the GUI can control pyfirmata)? I hope you understand what I'm trying to ask since I really would love your insight.

  • @Ordinary._.Original
    @Ordinary._.Original Рік тому

    hi, can you help me i have problem using pyfirmata and hdc1080 with arduino ... i tryed many code but no one works

  • @beyyhenn1233
    @beyyhenn1233 3 роки тому +2

    Sir , if i want to use bluetooth module (HC-05) , instead of USB cable what should do (in Windows) ? . I am new to arduino and i wanted to try something new by not using C++ for arduino .

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому +2

      You'll need to change the serial connection settings in the sketch and add a bluetooth module to pins 2 & 3 (RX & TX). Then connect to the bluetooth device from windows and it will show up as a com port. You can then connect to that com port from Python to control it

    • @beyyhenn1233
      @beyyhenn1233 3 роки тому

      @@kevinmcaleer28 is it possible to connect Bluetooth with arduino controller apps in arduino sir ?

    • @mariafernandagarciapineda8334
      @mariafernandagarciapineda8334 2 роки тому

      Hello, were you able to make the connection? If yes, can you help me?

  • @havtje50
    @havtje50 3 роки тому +1

    Good video, I do have a question. Lets say i want to build a program that shows the "Hello World" message on my pc screen when i click on a button on the arduino. Can i do this with just python and an arduino or do i still need another device?

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому +1

      Hi ChillaxingMuzic, Yes you can totally do this with just an Arduino and python on a PC. The PC Python script would have a loop to check the status of any messages from the Arduino, the Arduino would send a message to the PC over serial if the button was pressed

  • @jackthorat4933
    @jackthorat4933 2 роки тому

    How to use resetFunc() from Arduino IDE in python to reset the arduino without actually pressing the physical button

  • @GRSG_tech
    @GRSG_tech Рік тому

    I have a Question
    arduino vs rasberry pi
    which is better ???

  • @amirphilip2234
    @amirphilip2234 9 місяців тому

    I'm using Python but facing problem with firmata version

  • @adhithanp930
    @adhithanp930 2 роки тому +1

    Bro can u do a video on vl53l0x sensor using Arduino in python

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      I've done one of these already: ua-cam.com/video/YBu6GKnN4lk/v-deo.html

  • @kaboom1208
    @kaboom1208 2 роки тому

    Hi, I'm watching from Bangladesh.
    Please help me,
    how can I connect with Bluetooth and run the pyfirmata code ?
    Btw nice video 😊

  • @hinasahamedmohamedsaleem500
    @hinasahamedmohamedsaleem500 2 роки тому

    How to get input from dht11 sensor to python using pyfirmata

  • @richardgao456
    @richardgao456 3 роки тому

    Tried using firmata with a motor driver. For some reason can't find it to work, even though it works in the arduino programming language (digital writing to pins works in arduino but not in python. The flashing pin code works in python though). Any advice?

    • @markspence1494
      @markspence1494 2 роки тому +1

      Had the same issue. Make sure you are importing the correct board. I was using a Mega and asking for pins that were there. DUH!!! I homered it.

  • @taranagnew436
    @taranagnew436 2 роки тому +1

    Can you get pyfirmata on visual studio code?

  • @mortezazamani3570
    @mortezazamani3570 2 роки тому

    that was helpful

  • @ramazancalk1218
    @ramazancalk1218 2 роки тому

    how do i control arduino stepper motor using python

  • @have_fun1107
    @have_fun1107 7 місяців тому

    best

  • @superpayaseria
    @superpayaseria 7 місяців тому

    no matter how many times I push the run button in visual studio it say's firmata not installed while it accepts the command just fine in pycharm. Have 0 clue what the problem is. Also I need a coder to help me build the terminator anyone interested in a serious humanoid robot project?? Hit me up please.

    • @kevinmcaleer28
      @kevinmcaleer28  7 місяців тому

      Have you installed the pyfirmata library first with ‘pip install pyfirmata’ ?

  • @frames123
    @frames123 2 роки тому +1

    how can we use arduino libraries with it?

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      You can't use arduino libraries with firmata, the Arduino acts as a dumb terminal between its pins and the python computer its connected to. You can use python libraries to control it instead. Was there something specific you were thinking of?

    • @frames123
      @frames123 2 роки тому

      @@kevinmcaleer28 Yes, i am thinking of text to speech with arduino and as python is so limitless we can do anything and exactly as you mentioned it is like ading GPIO support for arduino, thank you for your help

  • @alphonsenyandwi9075
    @alphonsenyandwi9075 Рік тому

    good,

  • @royhopkins974
    @royhopkins974 2 роки тому +1

    Can it work with ESP32?

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      The esp32 can run micropython, but I’m sure the pyfirmata will work on esp32 via the arduino ide If you select the esp32 board in board manager

  • @antalervin19-
    @antalervin19- 2 роки тому

    Can you help me I have some errors

  • @YtAtif
    @YtAtif Рік тому

    Hi

  • @whiskynguyen6059
    @whiskynguyen6059 3 місяці тому

    4:40

  • @rverm1000
    @rverm1000 2 роки тому

    you can cut out the first 9 minutes. get to the point fast

  • @waleedaiad3411
    @waleedaiad3411 2 роки тому +1

    How can i use hc-12 with arduino using python language?

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      You can treat it as a UART or Serial device, and then send data to it as you would normally

    • @waleedaiad3411
      @waleedaiad3411 2 роки тому +1

      @@kevinmcaleer28 can i call you for more information please

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      @@waleedaiad3411 ​ The best way to get help is to join our discord group - action.smarsfan.com/join-discord