About This Tutorial
This is a tutorial for Python beginners who want to learn to program devices to interact with the physical world and with the so called "Cloud". You are going to learn how to program with MicroPython, a version of the Python language designed to run on microcontrollers. The applications that you are going to learn how to write are going to read data from sensors, display information on small screens, react to the push a button, and upload or download data from the Internet. Lots of cool stuff!
This tutorial is focused on the software side more than on the hardware side. I'm going to use a high-level "Lego" approach for building circuits, so instead of having to solder components into circuit boards, you'll be building your experiments on breadboards, and interconnecting components with jumper wires. You will be able to assemble and disassemble your circuits with ease, and more importantly, reuse components as you move through the tutorial and later when you build your own projects.
To be able to follow this tutorial you just need to have basic coding experience with Python. You do not need to have any previous knowledge of microcontrollers, electronics, or even MicroPython.
You will also need a Windows, Mac or Linux computer with a free USB port, as you will connect a microcontroller to your computer to program it. If your computer is one of the newer ones that only come with USB-C ports, then you are going to need an adapter so that you can connect a regular USB cable.
The Shopping List
In this section I will give you a short list with the components that you are going to need to build all the examples featured in this tutorial. As a reference, I'm providing links to Amazon US and UK for all of them (disclaimer: my Amazon affiliate link is embedded in these links), but you do not need to buy the exact products I'm linking. There are many manufacturers for these components, so use the links I provide as a reference and then if you prefer, buy your components from your favorite retailer. If you want a recommendation other than Amazon, Ebay is also a great place to shop for electronic components, and you'll probably find better prices.
MicroPython runs on a few different types of microcontrollers, but for this tutorial I'm going to work with just one model: the ESP8266. Note that there are a few different boards that you can buy with the same chip. The model that you want to get is the one informally referred to as "development board", and more formally known with the ESP-12 model name. These boards come with the microcontroller mounted on it, a small printed Wi-Fi antenna, a micro-USB input for power and programming, and 30 pins that insert straight into a breadboard.
The cost of these devices is so low that you are going to find that most sellers offer them in pairs or in four-packs. I recommend that you do order at least two.
Temperarure and Humidity Sensor
To demonstrate how to work with sensors, I'm going to use a DHT22 temperature and humidity sensor. This little device reads and reports the temperature and humidity levels in the environment. Depending on where you buy it, you may find models that come with three or four pins. Both are fine for this tutorial.
Some of the examples will display information on a small 128x64 pixel OLED screen. Once again, these are so cheap that you may want to get a few.
Some of the examples will be triggered by a button push. You are not going to need more than one button at a time for this tutorial, but as with the above you may want to also get a pack, since buttons are always handy to have.
Breadboard and Jumper Wires
To be able to easily build and take apart your circuits without soldering, you are going to need a breadboard and some jumper wires. I recommend that you get more than one breadboard as well.
USB to MicroUSB Cable
You will need a USB cable to connect your microcontroller to your computer. This is going to provide power, and also a serial connection through which you'll upload code into the microcontroller memory. This is the same cable that charge most Android phones, so you may already have one you can use.
Power Bank (Optional)
A power bank is not required for this tutorial, but if you have one, you will be able to use it to power your microcontroller independently of the computer after you have uploaded your code.
Let's Build Some Stuff!
I hope you find this a fun and interesting tutorial. Once you have the materials listed above you are ready to move on to the next chapter and start building stuff!