Building A Simple Python API for Internet of Things Gadgets

It’s no secret that I rather enjoy connecting things to the Internet for fun and profit. One of the tricks I’ve learned along the way is to spin up simple APIs that can be used when prototyping a project. It’s easy to do, and simple to understand so I’m happy to share what has worked for me, using Web2Py as the example (with guest appearances from ESP8266 and NodeMCU).

Barring the times I’m just being silly, there are two reasons I might do this. Most commonly I’ll need to collect data from a device, typically to be stored for later analysis but occasionally to trigger some action on a server in the cloud. Less commonly, I’ll need a device to change its behavior based on instructions received via the Internet.

Etherscan is an example of an API that saves me a lot of work, letting me pull data from Ethereum using a variety of devices.

In the former case, my first option has always been to use IoT frameworks like Thingsboard or Ubidots to receive and display data. They have the advantage of being easy to use, and have rich features. They can even react to data and send instruction back to devices. In the latter case, I usually find myself using an application programming interface (API) – some service open on the Internet that my device can easily request data from, for example the weather, blockchain transactions, or new email notifications.

Occasionally, I end up with a type of data that requires processing or is not well structured for storage on these services, or else I need a device to request data that is private or that no one is presently offering. Most commonly, I need to change some parameter in a few connected devices without the trouble of finding them, opening all the cases, and reprogramming them all.

At these times it’s useful to be able to build simple, short-lived services that fill in these gaps during prototyping. Far from being a secure or consumer-ready product, we just need something we can try out to see if an idea is worth developing further. There are many valid ways to do this, but my first choice is Web2Py, a relatively easy to use open-source framework for developing web applications in Python. It supports both Python 2.7 and 3.0, although we’ll be using Python 3 today.

Continue reading “Building A Simple Python API for Internet of Things Gadgets”

Automate Your Comfort Food Prep with an IoT Grilled Cheese Robot

What exactly qualifies as comfort food is very much in the palate of the comfortee. Grilled cheese may not work for everyone under every circumstance, but we’ll risk a bet that the gooey delicacy is pretty close to universal, especially when you’re under the weather.

But if you’re too sick to grill up your own and don’t have anyone to do it for you, this grilled cheese sandwich-making robot might be the perfect kitchen accessory. Dubbed “The Cheeseborg” and built as a semester project by [Taylor Tabb], [Mitchell Riek], and [Evan Hill] at Carnegie-Mellon University, the bot takes a few shortcuts that might rankle the grilled cheese purist. Chief among these is the use of a sandwich press rather than a plain griddle. We understand that this greatly simplifies the flipping problem, but to us the flipping, especially the final high arcing double backflip onto the sandwich plate, is all part of the experience. Yes, a fair number of sandwiches end up going to the dog that way, but that’s beside the point.

As realized, Cheeseborg feeds bread and cheese from stacks using a vacuum arm, sprays the grill with butter, and uses a motorized arm to push the uncooked sandwich into the press. At the peak of grilled perfection, the press opens and ejects the sandwich to a waiting plate. As an added bonus, the whole thing is Google Assistant enabled so you can beseech Cheeseborg to fix you a sandwich from your sick bed. See it in action below.

This is far from the first culinary robot to grace our pages. There was the recent CNC sausage bot, we’ve seen plenty of pancake bots, and even [Ben Krasnow] once automated cookie making.

Continue reading “Automate Your Comfort Food Prep with an IoT Grilled Cheese Robot”

Howto: Docker, Databases, and Dashboards to Deal with Your Data

So you just got something like an Arduino or Raspberry Pi kit with a few sensors. Setting up temperature or motion sensors is easy enough. But what are you going to do with all that data? It’s going to need storage, analysis, and summarization before it’s actually useful to anyone. You need a dashboard!

But even before displaying the data, you’re going to need to store it somewhere, and that means a database. You could just send all of your data off into the cloud and hope that the company that provides you the service has a good business model behind it, but frankly the track records of even the companies with the deepest pockets and best intentions don’t look so good. And you won’t learn anything useful by taking the easiest way out anyway.

Instead, let’s take the second-easiest way out. Here’s a short tutorial to get you up and running with a database backend on a Raspberry Pi and a slick dashboard on your laptop or cellphone. We’ll be using scripts and Docker to automate as many things as possible. Even so, along the way you’ll learn a little bit about Python and Docker, but more importantly you’ll have a system of your own for expansion, customization, or simply experimenting with at home. After all, if the “cloud” won’t let you play around with their database, how much fun can it be, really?

Continue reading “Howto: Docker, Databases, and Dashboards to Deal with Your Data”

State Machine Controls Garage Door Over The Internet

Home automation has been a hot-button topic time and again since the dawn of the personal computer age. These days, thanks to modern communications technology, it’s possible to do some pretty cool stuff. [Brad Harbert] decided to automate his garage door, controlling it over the Internet.

The build relies on a Particle Photon to do the heavy lifting of connecting the door to the Internet. Particle offer a cloud service that makes setting up such a project easy for the first timer, and [Brad] was able to get things working quickly. A relay is used to activate the garage door remote button, as it was desired to leave the main control board of the garage door opener untouched. Reed switches are used to sense the position of the door, and [Brad] coded a state machine to ensure the door’s current state is always known.

It’s a simple project, but [Brad]’s use of state machine techniques and position sensing mean it’s less likely he’ll get home to find his garage open and his possessions missing. If you’re new to programming simple physical devices, you could take a page out of his logbook. Of course we’ve seen similar builds before, like this one from parts from the scrapbin.

The Umbrella That Tells You The Weather

Most people can tell you the various uses of the umbrella — it keeps the rain off, pokes sleeping train passengers awake, and can be used as an improvised defensive weapon when tension in the hot dog line reaches boiling point. A true Englishman would never deign to employ their brolly so imprudently, of course, but they might just give it an upgrade by packing in a full weather station.

Please do not message us to complain about the redundancy of a rain sensor on an umbrella.

The build uses the Particle Photon as the brains of the operation, interfacing it with several sensors. There’s a DHT11 to handle temperature and humidity measurement, an Adafruit barometric pressure sensor, along with a custom-built anemometer using a brushed motor with 3D printed wind cups. Finally, a breadboard is turned into a rain detector, based on the same principles as those used in automotive applications.

 

The Particle Photon uses WiFi to tether to a smartphone, deliver the collected data to the cloud via Adafruit IO. This enables the data to be collated and processed further on a PC. Yes, it’s 2018, and they have the internet on umbrellas now.

As we reach further into the depths of winter, it’s one project that could very much come in handy, and [The Gentlemen Maker] has been kind enough to share the code on Particle.io. If that’s not good enough, perhaps you could use your umbrella as a WiFi antenna. Video after the break.

Continue reading “The Umbrella That Tells You The Weather”

An IoT Christmas Tree You’re Invited to Control

We love IoT gadgets, but are occasionally concerned that they might allow access to the wrong kind of hacker. In this case, [Kevin] has created an IoT tree that allows anyone to control the pattern of lights, and he’s invited you to do so!

We played with the tree a bit, and the web interface is fairly powerful. For each LED, you can select either a random color or a keyframe-defined pattern. For the keyframe LEDs, you can create a number of “keyframes”, each of which is defined by a color and a transition, which can be either linear, quarter sine wave, or instantaneous (“wall”). Additional keyframes can be added for each LED, and if don’t specify a pattern for all the LEDs, the system repeats those you have defined to fill the entire string. There are also a few preset patterns you can choose if you prefer. If you, too, want to play with the tree, don’t delay: it’s only available through the first week of 2019!

Behind the scenes, an aging Raspberry Pi provides the local brains driving the LED controller and streaming the video, while a cloud server running a Redis instance allows communication with the web. The interface to the string of WS2811 LEDs uses [Kevin]’s Kinetis LK26 breakout board, which he managed to get working despite the state of tools and documentation for the Kinetis ARM family. You can read a good discussion of the system on his blog; there are a surprisingly large number of pieces that need to work together. As usual, he provides all the source code for this project on GitHub.

We’ve seen [Kevin]’s work before, including his 73-LED wristwatch, and adventures developing on an STM32 from scratch.

But, if it’s IoT Christmas trees that have got you thinking, you can check out this one from last year.

DIY Mini Helical Antennas From Salvaged Co-ax Cable

[Mare] has a visual guide and simple instructions for making DIY mini helical 868 MHz antennas for LoRa applications. 868 MHz is a license-free band in Europe, and this method yields a perfectly serviceable antenna that’s useful where space is constrained.

A metric 5 mm drill bit makes a convenient core.

The process is simple and well-documented, but as usual with antenna design it requires attention to detail. Wire for the antenna is silver-plated copper, salvaged from the core of RG214U coaxial cable. After straightening, the wire is wound tightly around a 5 mm core. 7 turns are each carefully spaced 2 mm apart. After that, it’s just a matter of measuring and bending the end for soldering to the wireless device in question. [Mare] has used this method for wireless LoRa sensors in space-constrained designs, and it also has the benefit of lowering part costs since it can be made and tested in-house.

Antennas have of course been made from far stranger things than salvaged wire; one of our favorites is this Yagi antenna made from segments of measuring tape.