Fried Desk Lamp Reborn: How To Use ESP8266 To Build Connected Devices

Some hacks are born of genius or necessity, and others from our sheer ham-fisted incompetence. This is not a story about the first kind. But it did give me an excuse to show how easy it is to design WiFi-connected devices that work the way you want them to, rather than the way the manufacturer had in mind.

It started out as a sensible idea – consumer electronics in Vietnam have many different electric plug types for mains AC power: A, C, G, F, and I are fairly present, with A and C being most common. For a quick review of what all those look like, this website sums it up nicely. There are universal power adapters available of course, but they tend to fit my most common type (C) poorly, resulting in intermittent power loss whenever you sneeze. So I figured I should replace all the plugs on my devices to be A-type (common to those of you in North America), as it holds well in all the power bar types I have, mainly leftover server PDUs.

This was very straightforward until I got to my desk lamp. Being a fancy Xiaomi smart lamp, they had opted to hide a transformer in the plug with such small dimensions that I failed to notice it. So instead of receiving a balmy 12 volts DC, it received 220 volts AC. With a bright flash and bang, it illuminated my desk one final time.

Continue reading “Fried Desk Lamp Reborn: How To Use ESP8266 To Build Connected Devices”

Following Pigs: Building An Injectable Livestock Tracking System

I’m often asked to design customer and employee tracking systems. There are quite a few ways to do it, and it’s an interesting intersection of engineering and ethics – what information is reasonable to collect in different contexts, anonymizing and securely storing it, and at a fundamental level whether the entire system should exist at all.

On one end of the spectrum, a system that simply counts the number of people that are in your restaurant at different times of day is pretty innocuous and allows you to offer better service. On the other end, when you don’t pay for a mobile app, generally that means your private data is the product being bought and sold. Personally, I find that the whole ‘move fast and break things’ attitude, along with a general disregard for the privacy of user data, has created a pretty toxic tech scene. So until a short while ago, I refused to build invasive tracking systems – then I got a request that I simply couldn’t put aside…

Continue reading “Following Pigs: Building An Injectable Livestock Tracking System”

Etching Large Brass Sheets Is Harder Than You Think

One of my favorite ways to think of engineering is that a glass is not half empty or half full, only twice as large as it needs to be. As useful as that idea is, it also means that I rarely put any effort into the aesthetics of my projects – I learn or accomplish what I need, desolder and recycle the components, then move on. Few of my projects are permanent, and custom cases tend to be non-reusable, so I skip the effort and expense.

Once in a while though, I need to make a gift. In that case form and function both become priorities. Thankfully, all that glitters is not gold – and over the last year I’ve been learning to etch the copper alloys commonly classified as ‘brass’. We’ve covered some truly excellent etched brass pieces previously, and I was inspired to try and etch larger pieces of metal (A4 and larger) without sacrificing resolution. I thought this would be just like etching circuits. In fact, I went through several months of failed attempts before I produced anything halfway decent!

Although I’m still working on perfecting my techniques, I’ve learned enough in the meantime to give a report. Read on if you’re feeling the need for more fancy brass signs in your life.

Continue reading “Etching Large Brass Sheets Is Harder Than You Think”

Fablab Saigon Celebrates A Belated Arduino Day

Okay, we’ve just left May and stepped into June, why are we talking about Arduino Day — traditionally a March 16th event where makers congregate and share projects? I live in Ho Chi Minh City, and the event tends to take place in mid-May, but the enthusiasm and collaborative spirit are just as strong. Organized by the awesome local maker group Fablab Saigon with the venue provided by Intek Institute, there were some neat projects on display along with some talks from local companies.

The first thing that struck me about the event was how young the maker movement is here – most attendees were still in high school or early university. By contrast, I was 23 when I first learned to use AVR microcontrollers with assembly language (by the time Arduino started to get traction the boat effectively missed me). I couldn’t help but feel like a bit of a relic, at least until we all started talking excitedly about robots (I had brought a couple). It seems that geeking out about electronics is the great equalizer which knows no age limits.

Continue reading “Fablab Saigon Celebrates A Belated Arduino Day”

Schrödinger Quantum Percolator Makes Half Decent Coffee

I couldn’t decide between normal and decaffeinated coffee. So to eliminate delays in my morning routine, and decision fatigue,  I’ve designed the Schrödinger Quantum Percolator — making the state of my coffee formally undecidable until I drink it.

At its core, the Quantum Percolator contains a novel quantum event detector that uses electron tunneling to determine whether to use caffeinated or decaffeinated coffee. The mechanical components are enclosed in an opaque box, so I can’t tell which type of coffee is being used.

The result is coffee that simultaneously contains and does not contain caffeine – at least until you collapse the caffeination probability waveform by drinking it. As the expression goes, you can’t have your quantum superposition of states and drink it too!

Continue reading “Schrödinger Quantum Percolator Makes Half Decent Coffee”

Yes, You Can Put IoT On The Blockchain Using Python And The ESP8266

Last year, we saw quite a bit of media attention paid to blockchain startups. They raised money from the public, then most of them vanished without a trace (or product). Ethics and legality of their fundraising model aside, a few of the ideas they presented might be worth revisiting one day.

One idea in particular that I’ve struggled with is the synthesis of IoT and blockchain technology. Usually when presented with a product or technology, I can comprehend how and/or why someone would use it – in this case I understand neither, and it’s been nagging at me from some quiet but irrepressible corner of my mind.

The typical IoT networks I’ve seen collect data using cheap and low-power devices, and transmit it to a central service without more effort spent on security than needed (and sometimes much less). On the other hand, blockchains tend to be an expensive way to store data, require a fair amount of local storage and processing power to fully interact with them, and generally involve the careful use of public-private key encryption.

I can see some edge cases where it would be useful, for example securely setting the state of some large network of state machines – sort of like a more complex version of this system that controls a single LED via Ethereum smart contract.

What I believe isn’t important though, perhaps I just lack imagination – so lets build it anyway.

Continue reading “Yes, You Can Put IoT On The Blockchain Using Python And The ESP8266”

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”