Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Arduino With Python: How to Get Started (Summary)

Microcontroller platforms are on the rise, thanks to the growing popularity of the Maker Movement and the Internet of Things. Platforms like Arduino are receiving a lot of attention in particular, as they allow developers just like you to use their skills and dive into electronic projects.

You learned how to:

  • Develop applications with Arduino and Python
  • Use the Firmata protocol
  • Control analog and digital inputs and outputs
  • Integrate sensors with higher-level Python applications

You also saw how Firmata may be a very interesting alternative for projects that demand a PC and depend on sensor data. Plus, it’s an easy way to get started with Arduino if you already know Python!

Download

Course Slides (.pdf)

23.7 MB

Download

Sample Code (.zip)

3.7 KB

00:00 This lesson is the conclusion and course review. Let me say congratulations on completing the course. Throughout our time together, you learned how to develop applications with the Arduino and Python. You learned how to use the Firmata protocol, and along with it, a little bit about the library pyFirmata.

00:19 You learned how to control analog and digital inputs and outputs on the Arduino, and how to integrate sensors with higher-level Python applications. Let’s do a quick review through the table of contents of what you learned.

00:31 It started off with an introduction and course overview. Then you moved into the Arduino platform. You installed the Arduino IDE, and learned a little bit about resistors and using a breadboard.

00:46 Then you set up your first program using the Arduino, sort of a “Hello, World!” and connected your Arduino to your PC and set up its ports.

00:57 Next, you started to connect external components to your Arduino board.

01:05 Then you set up the Arduino and the Firmata protocol to be able to have it talk to Python, and redid that “Hello, World!” program.

01:17 Next up, you were reading digital inputs and using a switch.

01:27 After that, you were reading analog inputs and using the PWM outputs that would emulate the analog outputs.

01:40 Then you got to build something that was a bit more of a real-world application of using a sensor to trigger a notification or send an email.

01:53 And then there’s this conclusion and course review. I’d like to leave you with some additional areas for you to explore. I’ll include links with much more information below this lesson. Up first is to explore REST APIs.

02:08 These are widely used to integrate different applications. You could use REST with Arduino to build APIs that get information from sensors and send commands to actuators. To learn about REST APIs, check out the Python REST APIs With Flask, Connexion, and SQLAlchemy.

02:23 You could continue off what you touched on here with GUIs. There’s a tutorial where you use Tkinter to build a graphical application. However, there are other graphical libraries for desktop applications. Threading. The infinite while loop that you use throughout this tutorial is a very common feature of Arduino applications. However, using a thread to run a main loop will allow you to execute other tasks concurrently. Check out an intro to Threading in Python. Face detection.

02:53 It’s common for Internet of Things apps to integrate machine learning and computer vision algorithms. With these, you could build an alarm that triggers a notification when it detects faces on a camera, for example. To learn more about facial recognition systems, check out Traditional Face Detection With Python. And then there’s a few other ways that you could be using Python with microcontrollers besides Firmata and Arduino. One is pySerial.

03:18 Arduino Uno cannot run Python directly, as you’ve learned, but you could design your own Arduino sketch and use pySerial to establish a serial connection.

03:26 Then you can control Arduino in Python using your own protocol. If you’re interested in running Python directly on a microcontroller, check out the MicroPython project.

03:36 It provides an efficient implementation of Python to be executed on some microcontrollers, such as the ESP8266 and the ESP32. SBCs. Those are single board computers, such as the Raspberry Pi, that you can run Python on. SBCs are complete Arduino-sized computers that can run a Linux-based operating system, allowing you to use vanilla Python. As most SBCs provide general purpose inputs and output pins, you can use it to replace an Arduino in most applications.

04:08 I want to thank you again for watching, and make sure that you practice with what you’ve learned here.

Kevin Walsh on April 11, 2020

Thanks, i learned a lot. Will be ordering my supplies so that i can play around and continue to learn how to use Python in this manner. My son also has several applications on his small farm that he would like to automate if possible.

David Wright on April 17, 2020

Thank you for this very informative course. I enjoyed going through it and am excited about expanding on what I have learned.

avalidzy on April 19, 2020

Motivates me to acquire a couple of starter kits involving Arduino and RaspberryPi. Thanks Chis for your presentation! ;)

dmurph68 on May 15, 2020

totally awesome

stefanhofmann2 on June 1, 2020

Hi, nice Tutorial!

Question:

Can you explain how to configure an I2C device with pyfirmata or pyMata and develop a library for the ADS1015 ADC converter from Adafruit. How to deal with the datasheet. How to select the register pointers. That would be Mega! The goal should be to be able to independently develop a library for all I2C devices on the market using datasheets.

Chris Bailey RP Team on June 2, 2020

Hi @stefanhofmann2, Thanks! I’m glad you liked the tutorial. The short answer is unfortunately no. I had to actually google all of the things you were describing in your comment. I think you are referring to i2C, because I typed 12C first, and the Analog to Digital convertor I found on Adafruit. I think the Adafruit community and forums may be more likely to help you on your more advanced search. I think your goal is great, and there is a bunch of open source development going on in that space. The circuit python stuff is really great also, and worth checking out. You may also find some other members in the slack who are interested in deeper embedded electronics.

DW on June 9, 2020

Great introductory course! Many thanks.

byronnelson on July 26, 2020

First exposure to firmata interested in possibilities of having a Raspberry Pi controlling pins on the Arduino you have opened a new world of possibilities… Thanks!

Become a Member to join the conversation.