IoT 101: Hardware and Python

Yahia el sherbini
Elements blog
Published in
3 min readFeb 14, 2017

“Brush up on your high school physics, you are gonna need it,” Said Marcel, my colleague here at Elements, after answering my question about how I can supply a mini motor, a bulb and my LoPy board through one power source. His words speak true in a lot of situations I faced recently, but I will get to that in a little bit.

Today I am going to talk about something you have probably been hearing a lot recently: IoT (Internet of Things). Or my endeavor with it, at least. This is where I started: I first learned what LoRa is and how TTN (The Things Network) plays part in providing a network for people like me to use. There are nodes (the devices transmitting packets), gateways (picking up those packets) and a TTN backend (the backend that communicates to your application or broker).

LoRa

LoRa is simply one of the ways you can connect your devices to the internet. LoRa (or LoRaWAN) is a Low Power Wide Area Network that operates on radio frequencies. For a more detailed, and frankly better, explanation visit www.lora-alliance.org.

What is great about LoRa/TTN is that using it is for free. It is also low power so your devices can run on battery for a long time. The hurdles you may face with LoRa though are as follows: LoRa enabled devices are not always the cheapest. Gateways are expensive and not all cities have good coverage yet (Although the TTN community is doing a great job and it will improve with time).

Microcontrollers

I learned about LoRa, spent a lot of time setting everything up and got ready for the big moment! I sent my first “Hello world” packet, from a Sodaq Autonomo with an attached LoRaBEE, that got picked up and passed through, by a nearby gateway, to a router that sent it to TTN where my TTN application page appended a line saying my message arrived. I smiled and thought, now what else can I send?

Enter microcontrollers, the nodes in the LoRa flow, the things in Internet of Things, or toys for developers. This is when things started to get more interesting. You have probably heard of Arduino before, they have been used by electronics hobbyist for a few years now. I have used Arduino-like boards for a brief amount of time but then I got introduced to something else called LoPy. A board that runs and compiles Python code! As a Python developer I was ecstatic. That is not the only reason I preferred the LoPy, however.

The LoPy connects to WiFi so you can do everything over the air: soft reset, put your Python files, update firmware and debug. The downside of the LoPy is that it is new so there aren’t a lot of libraries yet and not all sensors work right out the box.

High school physics

The last part of the puzzle is working with sensors and modules and where I am spending time on now. To setup a set of sensors and modules that connect to your board, you will most likely have to set up circuits. This is when you will go back to your high school physics (or well, electronics). Breadboards, voltage dividers, resistors, transistors and many other things you will have to think about to make the modules effective.

It is a whole different world, but it’s fun and as deep as the ocean­!

The coming period I will be working on more IoT stuff, keep an eye on the Elements blog for updates!


Follow Elements on Facebook, Twitter and LinkedIn!

Originally published at www.elements.nl on February 14, 2017.

--

--