Control Arduino with Python using Firmata / PyFirmata

Поделиться
HTML-код
  • Опубликовано: 7 ноя 2024

Комментарии • 74

  • @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.

  • @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.

  • @techuntech
    @techuntech 3 года назад +8

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

  • @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!

  • @thebravo299
    @thebravo299 3 года назад +2

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

  • @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.

  • @dreamwork69
    @dreamwork69 2 года назад

    We need a whole series for this 🙏🙏🙏

  • @AdamKaszok
    @AdamKaszok 8 месяцев назад +1

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

    • @kevinmcaleer28
      @kevinmcaleer28  8 месяцев назад

      Yeah, should do! Have you tried it?

  • @NicholasWong-vv1nn
    @NicholasWong-vv1nn 2 месяца назад

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

  • @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

  • @Lord-Black__
    @Lord-Black__ 2 года назад +1

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

  • @عبدالرحمنالمرنخ
    @عبدالرحمنالمرنخ Год назад +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  Год назад

      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

  • @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

  • @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)

  • @GraveyardghouI
    @GraveyardghouI 2 года назад +1

    Thank you for this great video.

  • @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.

  • @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.

  • @GRSG_tech
    @GRSG_tech Год назад

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

  • @XPowerfullXPlayerX
    @XPowerfullXPlayerX 2 года назад +1

    Hey this is very useful content , good work

  • @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

  • @hinasahamedmohamedsaleem500
    @hinasahamedmohamedsaleem500 2 года назад

    How to get input from dht11 sensor to python using pyfirmata

  • @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?

  • @JesusGonzalez-rd6qn
    @JesusGonzalez-rd6qn 2 года назад

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

  • @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.

  • @jackthorat4933
    @jackthorat4933 2 года назад

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

  • @xianguihuang5477
    @xianguihuang5477 2 года назад +1

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

  • @mohamedjbaili701
    @mohamedjbaili701 Год назад

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

  • @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

  • @taranagnew436
    @taranagnew436 2 года назад +1

    Can you get pyfirmata on visual studio code?

  • @amirphilip2234
    @amirphilip2234 8 месяцев назад

    I'm using Python but facing problem with firmata version

  • @ramazancalk1218
    @ramazancalk1218 2 года назад

    how do i control arduino stepper motor using python

  • @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 😊

  • @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

  • @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

  • @mortezazamani3570
    @mortezazamani3570 2 года назад

    that was helpful

  • @antalervin19-
    @antalervin19- 2 года назад

    Can you help me I have some errors

  • @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: ruclips.net/video/YBu6GKnN4lk/видео.html

  • @have_fun1107
    @have_fun1107 7 месяцев назад

    best

  • @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.

  • @alphonsenyandwi9075
    @alphonsenyandwi9075 Год назад

    good,

  • @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  6 месяцев назад

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

  • @YtAtif
    @YtAtif Год назад

    Hi

  • @whiskynguyen6059
    @whiskynguyen6059 2 месяца назад

    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