Small Gadgets Making a Big Difference

February 9th of this year was a pretty cold night.  Not a record-breaker, but it was the kind of night cold enough that you needed to take care that your water pipes didn’t freeze, potentially causing thousands of dollars of damage.

That night, my phone and tablet started getting loud alerts every few seconds:

 

A temperature sensor at the Pajama Factory had dipped below the 35º Fahrenheit threshold we’d set, getting too close to freezing for comfort.  I started making calls to let the staff there know. Pretty soon, the sensors

At the Pajama Factory, there’s probably miles of hundred-year-old pipes, including a sprinkler system that needs to be kept ready-to-use, year-round.  In the Winter, there’s always the chance that pipes passing through an unoccupied or unheated part of the 300,000 ft² factory.

DJ, one of the members of FactoryMaker.space, is a 9-year-old Maker and inventor.  He’s also an avid gamer. DJ wanted to come up a way to make a bit of extra money to get himself a video game he had been eyeing. Together, we decided to come up with something that he could put together and sell, that would give his customers something truly useful.

The ESP8266 is a fairly new chip that’s immensely popular with makers and electronics hobbyists—it’s a complete ‘System on a Chip,” with WiFi.  You write a bit of code, burn it to the chip and then it’s ready to run, without the need for an attached computer.  It seemed the perfect candidate to base a “gizmo” around that DJ could sell cheaply enough and still perform a useful function.

Temperature sensors are something that almost everyone needs, so we paired the ESP8266 with the DS18B20, an inexpensive, yet highly-accurate and waterproof temperature module and some custom code and came up with the “Tempo,” our first “Internet of Things” device.

The Tempo boots up and connects to WiFi.  When it’s connected, it sends its data every few seconds to our server, which collects the data and feeds it to our monitoring and alerting programs.

You can watch DJ’s sensors in real time here.

It’s a simple device, easy to build and inexpensive, at around $15 each.  It does just one thing, but does it reliably.  (Leave a comment below if you’re interested in having us put some together for you.)

We think that’s pretty cool.

 

 

Control Sonoff Switches with Google Home (Part 1)

Getting into home automation doesn’t have to cost a fortune, if you’re willing to do a little bit of work!

Building your own IoT ecosystem will keep you immune from planned obsolescence, disappearing back-end services,  all while minimize vulnerabilities.  In this series, we’re going to show you how to build some devices that will let you say “Hey Google, turn off the lights!”  (Yes, just like Captain Picard from Star Trek, saying “Tea. Earl Grey. Hot.” and having your automated home make it for you, is not an impossibility. )

There are a few components needed to make this work.  The relays and the voice device, mainly, (Google Home, Siri, Alexa, Etc.) I’m starting with Google Home, since that fills an immediate need I have.

You’ll need an Internet-connected server of some sort, with a port open to the world.  A Raspberry Pi is powerful enough for this task.  It can be a remote server, if you like, even an obscure corner of an existing web site—we’ll just need to install a few PHP scripts to serve as webhooks for IFTTT.  If you’re using a Raspberry Pi, you can also host your own MQTT server.  If not, you can use a public one to get started. More on that later. First, let me introduce you to a remarkable bit of kit, the Sonoff!

The Sonoff is an Internet of Things component that you really need to be aware of:

Sold as a “WiFi Smart Switch,” its a nicely-packaged Internet-controlled relay.

Here’s a look inside:


The green terminal blocks at each end are such that you could chop a lamp cord, strip off 1/8″ of insulation, screw them in to the terminal blocks and have an Internet-controlled lamp. The yellow thing is a transformer, which, along with the capacitors and the varistor, form a 3.3v power supply that powers the device. (No USB cables and adapters needed!)

The relay is the black block with a white label, just below “worth” on the Way Cool Beans coaster.  (Way Cool Beans is the coffee shop where we dream up all of this stuff.  It’s a great place to get coffee, they do all their own roasting, by hand, on site and run their web server from a Raspberry Pi inside a glass head. They also host all of our classes. How cool is that?)

Here’s the back of the board:


There’s a couple of things that stand out here.  See those heavy solder traces?  That’s where the housecurrent (mains) power crosses the board.  The upper trace is the neutral and the lower one is the live current.  The two are nicely separated, even to the extent that there is a gap cut into the board, to keep it from shorting out.


It’s important to keep in mind that this board is designed to handle AC voltages that can kill you—never power it it up when it’s outside of its protective housing! (We’ll be programming it later, which requires you to feed it DC 3v with the case off, but that’s safe enough.) Use common sense and have a responsible adult handy, if you don’t happen to be one yet.

In the bottom left, you can see the “squiggle” of the onboard wifi antenna.

So why is this thing so special?  It’s got a built-in ESP8266! That means we can easily reprogram this thing to do all sorts of cool stuff, using open-source code that we can easily inspect and modify!  Here’s a package (Programmed with the Arduino IDE) that I absolutely adore for turning the Sonoff into a really great, easily-configured relay that we can control via MQTT!

There are a bunch of different ways to put your code onto an ESP8266, but by far, the easiest is to use the Arduino’s IDE, or “Integrated Development Environment.” Here’s a tutorial that explains how to install and configure your Arduino Environment. (Scroll down to “Installing and Configuring.”)

You’ll need to get yourself a USB to TTL Serial Adapter if you don’t have one already.  Be sure it’s set to 3.3v when programming ESP8266 devices!

Jonathan at SuperHouseTV on YouTube has an episode where he shows how to flash your own firmware onto the Sonoff.  (Jump to 17:35 to get right to that section, or watch the whole thing, if you have time.) Keep in mind that we’ll be flashing a different package onto the Sonoff.

OK – That’s going to do it for the first part of this tutorial.