Things Node to Things Gateway to IFTTT to Google Sheet

I’m finally, at long last, in possession of a gateway from The Things Network, and so I’m ready to start laying the groundwork for an open sensor network in Charlottetown.

What does this mean?

Well, imagine you want to measure something: temperature, humidity, noise, pollution, daylight, water level, pedestrians.

You do you the measuring with sensors out in the field, and sensors that are (a) small and (b) don’t use a lot of power, are best because they’re easier to spread around (if you can run a sensor with batteries, then you don’t have to run power to it; if you can tuck a sensor in a corner rather than paying an electrician to mount it somewhere you’re more likely to install it).

Once you have your sensors out in the field you need a way of getting the data they collect to a central data-collecting place. In the olden days this often meant that the sensors had a way of storing readings and you’d get in a truck and visit them occasionally and transfer the data to a laptop.

More recently sensors have been able to send readings using cellular telephone data networks, but that makes the sensors more expensive, and requires that they have SIM cards and a mobile operator through which to pass the data.

Ideally there could be low-cost sensors, communicating using radio over unlicensed spectrum, to a low cost gateway, thus removing the need both for trucks and SIM cards altogether.

And that’s exactly what The Things Network, a Dutch project, has set out to do. Their elevator pitch:

The Things Network is building a network for the Internet of Things by creating abundant data connectivity, so applications and businesses can flourish.

The technology we use is called LoRaWAN and it allows for things to talk to the internet without 3G or WiFi. So no WiFi codes and no mobile subscriptions.

It features low battery usage, long range and low bandwidth. Perfect for the internet of things.

In hardware form, here’s what this looks like right now in my office.

First is The Things Gateway, about the size of an iPad, with an antenna sticking out the top. Depending on the terrain, and how much area you want your sensor network to cover, you need one or several of these in a city, each operating independently. All they need is an Internet connection and power:

The Things Gateway in my office

Next is a prototypical sensor box called The Things Node that can be used for testing and development. It’s about the size of an Altoids tin, contains temperature, light and motion sensors as well as a multi-coloured LED and a button, and operates on 3 AAA batteries. These, like other sensors that speak LoRaWAN, can be placed anywhere and everywhere, and can sense and forward all manner of things to a nearby Gateway:

The Things Node in my office.

There’s a relatively simple process of activating The Things Gateway that involves getting it set with network connectivity (wireless or hardwired via Ethernet) and getting it registered with The Things Network’s routers. I called my gateway charlottetown-1, and here’s what it looks like in the Things Network console:

Screen Shot of The Things Network console

With the gateway in place, I turned to setting up The Things Node. At heart this is a SparkFun AVR inside a waterproof case, and the setup process involves getting an Arduino environment set up on a computer, connecting the computer to the Node by USB cable, and grabbing its unique ID number, called the EUI. Not the simplest procedure, but it’s well-documented.

Once the EUI is obtained, The Things Network console allows you to create an “Application,” and then to attached one or more “Devices” to that Application.

I set up an Application called charlottetown-thingsnodes that looks like this in the console:

Things Network Application screen shot

Next I added a Device, for my Things Node, to this application, and called it charlottetown-thingsnode-1:

Things Node Device screen shot

Finally, I uploaded a sample Arduino sketch to the Things Node that set it up to transmit temperature, light, and battery level readings every minute, and button-press and motion events as they happened.

Once I’d done all this, data started to flow from The Things Node, via The Things Gateway, over the Internet to The Things Network, where I could see it on my console:

Things Network console screen shot

You can see that at 3:59 p.m. this afternoon the temperature in my office was 21.69ºC, the light level was 31, and the battery level was 4060.

The Things Network doesn’t actually do anything with the data at this point; for that, Integrations are required. These are third-party services that use The Things Network’s API to allow you to visualize, analyze or otherwise act on the sensor data you’re gathering.

One of these integrations is with IFTTT (née If This Then That), and while it’s a little cumbersome to set up (as the documentation is out of date), I eventually got it working, with this setup:

Things Network IFTTT integration

The keys to getting it working were understanding that on the IFTTT end the “this” you need to configure is now called “Webhooks” (it used to be called “Maker”), and that the “Key” value you need to plug into the Integration settings on The Things Network is the string that comes after “/use/” in the URL for the Webhook setup (the part I’ve redacted here):

IFTTT Webhook Settings

The IFTTT “Applet” I setup takes data from The Things Network Integration via Webhook, and adds the three values it receives to a Google Sheets spreadsheet:

Screen shot of IFTTT applet

And that’s exactly what started to happen; here’s a shot of the Google Sheet:

Screen shot of Google Sheet

Here’s a chart of those values for the last day:

Chart showing temperature in the Reinventorium

There’s relatively little variation in the temperature in the office, it seems: it ranges from a low of 21.13ºC to a high of 22.75ºC, a range of only 1.62ºC. I suspect this has something to do with the fact that the new office here, in the basement of the St. Paul’s Church Parish Hall, is heated by the district heating system, and that it’s tightly regulated.

Ultimately, of course, it doesn’t make sense to use all this gear just to measure the temperature in my office. But once I get the gateway centrally mounted somewhere high in Charlottetown, thousands of sensors over a large swath of the city, will be able to send data through it. That’s next!

Parenting by Echo Drop-in

One of the amazing/creepy features of the Amazon Echo is that you can opt-in to allowing other Echo users to “drop in” on your Echo, and this establishes an instant audio connection between the two of you, with no need to answer or acknowledge. It’s like leaving your front door open, and dispensing with the niceties of the need to knock.

Today is a snow day, and Oliver is home from school. I need to work. Catherine needs to work. And Oliver is averse to coming to the office or studio with either of us.

Given my new office’s proximity to the house–directly across the street, and 15 seconds away if I’m running–we decided to try an experiment today, where we leave the “drop in” connection between the Echo in my office and the Echo in our living room open. So, in a sense, Oliver and I are “in the same room,” albeit separated by a city street.

Oliver’s 17 years old, and he doesn’t need constant supervision: he’s pretty independent and self-contained as regards most aspects of life. But because someone could knock on the door, or Ethan could start barking at a squirrel, or the toilet could overflow, he needs access to supervision, and that’s what I’m here for, across the street.

We’ll see how it goes.

Edge Case

I spend a good portion of my working life, as all coders do, dealing with edge cases, those remote, seldom-seen corners of systems that confound original expectations. Discussion about edge cases often starts with “I never imagined that…”

I suspect that my new work-home proximity is going to drive Google Maps’ timeline feature bonkers: it’s an edge case, where the proximity falls well within the margin of geolocation-determining error.

I called. They were there.

For all the corporate merging and rebranding and offshoring that’s happened to what we now know as Bell Aliant, there are vestiges of Island Tel that show up from time to time, offering the kind of warm, neighbourly service we used to take for granted. Today was one of those days, as Installer Steve was on site here at the St. Paul’s Anglican Parish Hall (Reinventorium 2.0) to move the fiber connection from The Guild (I learned, by eavesdropping, that these are called the “F” and “T” ends, respectively, presumably for “From” and “To”).

Steve was every inch an Island Tel employee, literally and figuratively, and he got me up and running with flexibility, good humour, and technical acumen.

By early afternoon I was in business, with 142 Mbps down and 155 Mbps up when connected by 5 GHz wifi:

Screen Shot of Bell Speed Test on new fibre connection (wifi)

And a dizzying 307 Mbps down and 153 Mbps up when wired directly into the Actiontec router:

Screen Shot of Bell Speed Test on new fibre connection (Ethernet)

Twenty-four years ago I created my first website wired to the Internet via a 14.4 kbps bare copper connection to PEINet with a modem on either end; if my calculations are correct, that means my Internet speed is now about 21,000 times faster than it was then.

The move isn’t quite complete yet: there’s still the type drawer to come, and a table, and some shelves. And the bits and bobs I took off the printing press. But I’ve got until the end of the month to do that, so I’m going to take a break from moving-stress, get some work done, and enjoy tomorrow’s snow storm.

Digital Moved

I managed to get the digital side of the Reinventorium moved today, with the generous help of my friend Ray, who popped over with his station wagon at exactly the right time.

No bandwidth yet—the Bell Aliant installer is booked for tomorrow. But my gear is in place, ready and waiting for it.

But before that, the printing press gets moved: I’m meeting the team from McQuaid’s at 8:00 a.m. at The Guild.

From Pretty to Gritty

Peter Santenello writes about moving to Kyiv in 2016:

That November in 2016 was a step into another dimension for my mind, and new scenery for my eyes. Kyiv didn’t quite have that same charm as it did in the summer… grey skies fused into grey buildings, like one wide and long brushstroke of paint on canvas.

But I didn’t want everything to be great; I didn’t want the weather to be perfect. I wanted texture, depth, and grit… and Ukraine checks all of these boxes like a seasoned professional.

Every place evokes a feeling in the first twenty-four hours. Ireland, drinking. Bali, relaxation. Las Vegas, excess. New York, busyness. Ukraine… authenticity.

The country has an uncanny ability to keep things authentic. There are a whole set of factors that lead to this outcome, but where much of the modern world is trying to put on a show, Ukraine is one of those places that doesn’t. In a way, it’s very simple here; people only smile if they mean it. There are no “being nice” gestures, only gestures that come from authentic intentions whether for good or bad.

My thoughts returned to this when I read last week that Downtown Charlottetown Inc. has a program called Gritty to Pretty, which seeks to fund “projects [that] will contribute to DCI’s strategic beautification goals.”

While I support the general notion of supporting creative workers in using the city as a canvas, the “Gritty to Pretty” wording of this program infantilizes artists, reducing their creative work to “gussying up the place.”

I don’t want my community to be pretty, like Santenello I want it to have “texture, depth, and grit,” and if the business community is going to subsidize art, it should remove the shackles of “pretty” from its program, embrace the grit, and fund authentic art that changes the world.

Charlottetown Perspectives Entry, 2012

(My entry to the Charlottetown Perspectives program in 2012)


Subscribe to Peter Rukavina's Weblog