2020 in review

Bought a new house. Worked from it (and the old house) a lot. Oldest kid started kindergarten (remotely). Went on a couple trips. That’s the highlights.

New house

Most prominently, my family bought a new house. It’s only about 8 miles as the crow flies from the old house. The process was a struggle, partly because two kids and a global pandemic makes it difficult to visit as many options as easily as we’d have liked. Partly because the market was extremely hot — we were outbid on the first house we made an offer on, and we’d offered asking price (or maybe even more, I forget). We also had at least one showing canceled because the buyer accepted an offer between the time we scheduled it and when it was scheduled for, and we visited a house for a showing that had — unbeknownst to us and our realtor — already been sold shortly before.

Still, we eventually found a great one that backs onto common ground woods and a creek, with more woods behind it. We’ve seen deer and turkey, and a wide variety of birds, among other animals. Collected some neat rocks along the creek. We’re pretty happy with it.

Which leaves the old house, which has been a bit of a pain to deal with. I haven’t had much luck in finding people to do some fairly light work that needs done before putting it on the market, so I’ve been getting done what I can myself in bits and pieces. Things like resealing the basement walls, patching and painting, etc. Probably the biggest bits are replacing light fixtures, replacing carpet upstairs, and removing sticky vinyl tile from the bathroom floor to reveal — as our realtor suspected — the original 1940s tile floor in great condition underneath. Great condition other than needing to remove all the adhesive, clean and probably regrout the whole thing. I hope I will not be writing about the old house in the 2021 in review other than to say we sold it.

Trips

Went on a couple trips this year.

In January we drove to Minnesota for a funeral in my wife’s family.

At the beginning of March, I went to New Orleans for the 2020 NICAR convention. There had been some question leading up to it whether or not it would happen, but the organizers were pretty consistent in saying it would. And it did.

The conference itself was fine. I’d never been to New Orleans. I flew down, wandered around the city a bit as usual, before the conference. I led sessions on GitHub and file organization, as well as helping out in a sort of “office hours”-type session. Played Wingspan with some folks one night at the hotel bar. The party was at the aquarium on the waterfront, which was quite nice.

Power line towers receding across a lake

After the conference, I took Amtrak back to St. Louis, via Chicago. I visited with Pete in Chicago and ate, if I recall correctly, my last meal in a restaurant in 2020 — March 9 at Breakfast House. I also managed to find Anderson Pens’ Chicago location (new to me). It would close (“temporarily” — but it’s still closed) a little more than a week later.

When I arrived home, I asked my boss whether he thought it might be best if I worked from home for a week, just as a precaution. Later that evening I got an email announcement that a conference attendee had tested positive (another would follow several days later, but that was the last we heard of spread related to the conference). And shortly after that, everyone was working from home.

Other than that, I haven’t been much of anywhere. I took the kids for a drive through Lone Elk Park but we stayed in the car. I also traveled back to Danville for an estate sale at my grandparents’ house, but I went by myself.

Hobbies

(Other than surviving a global pandemic). My singing group, the Greenleaf Singers put on a concert on January 5. And then that was it. We haven’t been able to sing together since. Though the St. Louis Renaissance Faire still went on, we didn’t perform. The Christmas concerts we normally sing were cancelled. I’ve made the least music this year in at least a decade, and I miss it so much. Our group has gotten together on Zoom a few times, just to hang out, but the singing doesn’t work so well.

Rock with fossils

Photography has been on the upswing, especially since buying the new house. The variety of things to see, plants and animals in the woods and along the creek is great for taking pictures.

The kids and I have been down to walk around the creek a few times to go rockhounding. There are some fossils and other interesting rocks to be found, and the creek floods quite a bit so I think the rocks should turn over a fair amount.

A male cardinal landing on a feeder

A very new hobby (like within the past few days) is birding. After noticing the large variety of birds at the new house, I anticipated getting a feeder at some point. Then I saw a sale on 20 lb. bags of mixed feed for $5 just after Christmas, and jumped on it. I hung a tube feeder, which was successful, and then built a crude platform feeder for larger birds, which has also been ok so far. This is in turn allowing for some fantastic photos (I set the feeders up not far from a convenient spot) and even live-streaming.

Geekway to the West was canceled this year, so we didn’t get to go to that. Consequently (and between moving, et al.) we haven’t played a lot of games this year. We did buy Wingspan for Tabletop Simulator and play through that a couple times.

SIU Job

I taught data journalism at SIU for the second time. It went well, despite meeting virtually for the second half. For the upcoming spring semester I’ll be teaching that again as well as a visual communication course.

STLPR Job

It was, no surprise, largely focused on the pandemic. I built a dashboard and a bot for our Slack that helps broadcast the stats to our reporters daily. Also worked on the election, of course. Flew the drone a couple times, including at a drive-in open for business during the pandemic. Among many many other things.

I think I’ve been into the newsroom a total of three or four times since the end of February.

Media

Some media I enjoyed this year, in no particular order:

The St. Louis Symphony Orchestra played Beethoven’s 9th. Enough said.

Chris Thile and Andrew Bird played an incredibly joyful rendition of ‘Blue Skies’ on Live From Here. Also Live From Here got canceled, which is still disappointing to me.

I greatly enjoyed the streamed Sondheim 90th Birthday Concert.

Watched the filmed version of Hamilton on Disney+.

Speaking of streaming services, when we moved, we canceled DirecTV and got Hulu’s live TV service. So far, so good.

I watched the Cardinals play on opening day, which I’ve always enjoyed but was particularly significant this year amid the uncertainty.

I highly enjoyed AppleTV’s Central Park animated series, as well as Ted Lasso. My kids have also enjoyed Helpsters.

I didn’t read a whole lot. I borrowed the biography Weird Al: Seriously, and The Office: The Untold Story of the Greatest Sitcom of the 2000s: An Oral History from the library.

I watched a lot of YouTube:

  • Cracking the Cryptic’s sudoku, which I’ve been enjoying the challenge of attempting every so often. The Miracle Sudoku is what introduced me and many other people to the channel.
  • Late last year, we’d started watching the British comedy game show Taskmaster, and continued that as they posted new episodes.
  • Adam Savage, formerly of Mythbusters, has been doing a fantastic job during the pandemic on his channel Tested.

Siri and alarms

This is probably common enough knowledge if you use Siri often, but I don’t so here I am: If you ask Siri, at least on HomePod, “how long until my next alarm”, the answer will include alarms that are turned off.

This morning, my kid set an alarm for his next school meeting, but got the time wrong. I told Siri to “cancel the alarm”. Siri confirmed the alarm had been turned off. Then my kid correctly set an alarm.

A while later, my kid asked how long until his class. So we asked Siri “how long until my alarm”. Siri gave an incorrect time. Took me a minute to figure out the time was until the first, canceled alarm.

I asked Siri “what are my alarms”, and it listed both (but confirmed the incorrect one was turned off). I deleted the incorrect one.

Now asking “how long until my alarm” gives the right answer. It was confusing to me that asking “how long until my alarm” would include an alarm that’s turned off, but maybe there are situations where that would make sense.

A new feature for Tweetnest

I’ve been using Tweetnest to download and archive my tweets for some time now. I set it up some time ago, and generally, it just runs. I think I’ve had to go reboot the cronjob it uses to collect new tweets once or twice. I just added a feature to automate finding tweets “on this day” from prior years.

Background

Tweetnest, if you’re unfamiliar, is a self-hosted app to collect all your tweets and present them nicely in a way that’s separate from Twitter’s interface. It collects everything into a mySQL database, and is written in PHP. It’s nice to have a backup of Tweets kept separate from Twitter.

The main page just displays recent tweets, but it also lets you search, and has month and day pages. It’s a nice, calm interface for exploring or searching old Tweets of yours, which comes in more handy than you’d think.

I have been using Micro.blog more, through this site, which solves some of those problems. But even if I left Twitter today, having this backup and nice interface to it would be valuable, so I figured it was worth doing a little writeup on.

Ok, so what’s the new feature?

As I said I haven’t really touched the site since installing it, and mostly it works fine. But I recently went in a made a tweak, which is the impetus for this post.

One thing I’ve been doing recently is checking out my Tweets “on this day” to see what was going on last year, five years ago, even a decade ago. Twitter doesn’t have a function for this natively, and neither does Tweetnest.

I started out just by visiting the pages on Tweetnest sequentially. The daily page URLs are formatted year/month/day, so you can visit last year’s pretty easily, then just change the year in the URL, see the new ones, and so on. But this is tedious and occasionally there are no Tweets on a given day so it’s a waste of time.

I quickly tired of that, and wrote a little Keyboard Maestro macro to get the current date, format the URL properly, and open tabs in my browser, one for each year between one year ago and when my archive starts in 2008. This is pretty good, but it only works on desktop, not mobile, and it still suffers from the case when there are no tweets on a day (it just opens a tab that says “No tweets here!”).

Finally, I decided to create a proper solution. I built a page for the site that gets the current day and month, then queries the database for tweets that happened today, and presents them.

The code

This was pretty simple and required no innovation on my part. I just modified the code for a specific day to remove the year, and added logic to get the date from the current date, instead of the URL. It’s functional, but since I don’t know PHP it’s quite possible I’ve done something wrong. Here’s the query:

date_default_timezone_set('America/Chicago');
$day = date("d");
$month = date("m");

...

query("SELECT `".DTP."tweets`.*, `".DTP."tweetusers`.`screenname`, `".DTP."tweetusers`.`realname`, `".DTP."tweetusers`.`profileimage` FROM `".DTP."tweets` LEFT JOIN `".DTP."tweetusers` ON `".DTP."tweets`.`userid` = `".DTP."tweetusers`.`userid` WHERE MONTH(FROM_UNIXTIME(`time`" . DB_OFFSET . ")) = '" . s($month) . "' AND DAY(FROM_UNIXTIME(`time`" . DB_OFFSET . ")) = '" . s($day) . "' AND `".DTP."tweets`.`hidden` = 0 ORDER BY `".DTP."tweets`.`time` DESC");<br>

Next, I modified the .htaccess file to run the new php file at a particular URL (I called mine “/today”), and the inc/html.php file to include a link to “/today” in the sidebar. And that’s that. Now I can visit that link and see all the tweets posted through the years on a single page. You can see my modifications on my Github fork of the project.

Other enhancements

One other thing about Tweetnest is that it hasn’t been officially updated to include the new, longer Tweets. So some folks who use it have modified it to take advantage of those. You can see those changes in my previous commit, or in various issues in the main repository.

One shortcoming

A thing I noticed while working on this was that, because I hadn’t made the long-tweets upgrade until now, many prior tweets are truncated (Twitter increased the length at the end of 2017).

One suggestion in the Github issues was to remove all tweets since the lengthening and re-import them.

Tweetnest has two ways of importing tweets: The loadtweets.php file and the loadarchive.php file.

Loadtweets is the thing that runs on a cronjob, so usually it’s only grabbing a handful of tweets at a time. It uses Twitter’s API to get tweets, and so is limited to 3,200. This, unfortunately, isn’t quite far enough to get all my Tweets since the change (it also hits a memory error when trying to load that many).

Loadarchive was built to consume json files you can download from Twitter that contain your archive. Twitter limits public access to tweets to the last 3,200, but it will compile your data and let you download all of your tweets.

Unfortunately, the format of this archive has changed since this function was written for Tweetnest. I attempted this route, but ran into a couple roadblocks:

  1. The link to the tweet on Twitter is missing its username. Tweetnest generates the Tweet, but wherever it’s trying to grab the username from to generate the link is missing, and so the URL it links to is just missing a piece.
  2. Retweets are messed up. In prior archives (and in current API calls) you seem to get much more information about retweets than you do in the archive. And so when you load tweets from the archive, Retweets aren’t able to get the original tweet.

There are probably ways around both of these problems for someone more versed in PHP and/or Twitter’s API/data than I am, but since new tweets should come in at their full length and new retweets are ok, it’s not vital to fix these problems. (If you do tackle this, please let me know).

Conclusion

Tweetnest is pretty great, especially for some free software written nearly a decade ago. It’s nice to be able to hack on things and add features that make your life slightly easier.

2018 in review

The biggest change in the new year of course is the birth of my second child. I also applied for and was chosen to teach a data journalism class at SIU-Carbondale beginning in the Spring. Other than that, I don’t know. After reviewing the year, I mostly just feel exhausted.

Personally

The aforementioned child was born by the time February was here, so we spent most of the year adjusting to raising two kids instead of one.

Trips

Took mostly small trips, in town.

In April, we visited the St. Louis Science Center during an exhibit featuring the command module Columbia from the Apollo 11 mission. It was a surprisingly moving experience to be in the presence of it.

Also went to a Cardinals game with my Dad in April, to the Zoo in May, the Transportation Museum in June, a Cardinals game in June, Grant’s Farm and the Arch in August, the Arch again in September, and the Garden Glow at the Botanical Garden in December.

A couple larger trips my family took were to take the new baby to visit my family in May, another trip back there in Christmas and a trip to Carbondale, Ill. to fill out some paperwork for the job, when we also took in a football game and spent a day at Giant City State Park.

In June I also stopped by Chicago for a day on my way home from a work conference and got to hang out with a friend and his family.

Home Improvement

Didn’t do much to our house this year, unfortunately. Did clean out the back fence line again this fall, and dug out an old lava-rock-lined flower bed on the north side of the lot. Also bought a new battery-powered lawnmower and weed trimmer, which are working out well.

Hobbies

The singing with Greenleaf continues, beginning with a concert in January, as well as singing a bit at one of our member’s weddings. We also performed at the Renaissance Faire in Wentzville for three weekends, the concert at Eliot and our own concert in December. We finally sold tickets online for the first time for our own concert and that seemed to work well.

In February, I made a weather status indicator out of a Raspberry Pi and a Blinkt! module. Later in the month, I used a Scroll pHat HD and a Pi to animate a customizeable rainstorm. Inspired by the movie ‘Desk Set’ and its 1950s computer mainframe prop, I also coded up a version of that.

I think I played exactly one round of golf this year, at the Prairies in Cahokia.

In May, Pam and I went to “Geekway to the West”, a board game convention in St. Charles. They have a game library with all different kinds, vendors and publishers running demos, and lots of door prizes. Between Thursday and Sunday, I played 22 games. It was a lot of fun — we plan on going back again this year.

In August, I managed to finally use some scrap leather I bought at the Renaissance Faire the previous year to make a lcase for my AirPods. Turned out pretty good, and it was fun making it, although I haven’t done anything else with it.

In August, I also went bowling for the first time in a half-decade.

In September, I somehow got it in my head to go thrift store hunting. The first time out went pretty well, yielding a Gitman Bros. blue oxford shirt, a Land’s End pink OCBD, a Brooks Bros. broadcloth shirt and some Banana Republic Traveler Jeans. Around the same time I also nabbed a deal on a pair of new Levi’s for $13. Later in the year I got a couple new Jos. A. Bank corduroy jackets for $20 each, so I was feeling pretty well dressed by the end of the year.

In October, Pam and I went to a board game cafe, Pieces. It was a good time. We played Jaipur, Hive, Medieval Academy and Potion Explosion.

I keep on taking pictures. I bought a used Rokinon 85mm f1.4 lens, which I really enjoy using. Also got a 12mm f2 for Christmas this year, so I’ll be trying that out more too.

Arts

A NYT article in early January led me to ‘Force Majeure’ a weird, dark movie about relationships in a Swedish family on a ski trip. It was good, and one of those splinter-in-your-brain-type movies. It was a 2014 movie, so nothing new, but new to me.

While in Chicago for a work trip, I got to multitask and go to a Mac Power Users meetup and meet David Sparks, Katie Floyd, and Kourosh Dini, among many other fans of the show. It was a good time.

I watched ‘Jesus Christ Superstar Live’ on NBC on Easter Sunday. It was quite good.

Also in April, I was lucky enough to win the lottery to see Hamilton at the Fox. Pam and I went, and it exceeded expectations. Just incredible.

In August, I got to go see a couple friends performing in R-S Theatrics’ Light in the Piazza, which was delightful. I wasn’t familiar with the show or the soundtrack, and it was quite good.

In October, the “Rushmore of Nerdcore” tour came to the Firebird, with Schaffer the Darklord, Mega Ran, MC Lars and MC Frontalot. I heard MC Frontalot on his last trip through St. Louis, and I’m glad I went again.

I saw the Coen Bros’. Ballad of Buster Scruggs when it came out on Netflix. Not without its issues, but beautifully shot, and thought-provoking.

Finally, in December I happened to catch that TCM was playing White Christmas in a few theaters on a couple nights, so Pam and I went to see that. She really enjoys the movie, and it was nice to see it in a theater.

Food/Booze

My first restaurant meal in 2018, according to my Twitter, was a Courtesy Diner Slinger, so it was pretty much all downhill from there.

I also made it to Squatters Cafe several more times before it closed toward the end of the year. The chef is opening a new restaurant nearby, so I’m looking forward to that.

On the aforementioned Chicago work trip, I went to Portillo’s for the first time. I also went to Eataly, which was a couple blocks down from the hotel and Shake Shack a couple times, which was right across the street.

In September I got to take a VIP tour of the Schlafly Brewhouse downtown. It was interesting to see behind the scenes and in the basement, as well as taste some in-production stuff.

I made Krupnik again, and it turned out great. I took some to one of the Greenleaf cast parties and it seemed to be a hit.

I made some chili for our work chili cookoff in November. It did not win, but I thought it was pretty good. Got to make chili powder from scratch, too.

On Black Friday I managed to nab some bottles of 2018 Bourbon County Barrel Stout at Schnucks, so now I have bottles going back to 2015. Due to accidentally getting some extra 2017, I also cracked open a bottle of that, and it’s delicious, as expected.

Work

Got a new boss, got a new (side) job. Flew the drone a bunch, did a bunch of projects.

New Job

I saw an opening posted for a temporary part-time person to teach a data journalism class at Southern Illinois University Carbondale, where I earned my degree from. It sounded like a good fit, so I applied, and I got it. I’ve been preparing for it ever since, and the first class is in two weeks. I’ll be commuting down there one day a week. So we’ll see how that goes. I’m excited.

Projects

Worked on lots of projects this year: A 10-year look back at the Great Recession, a major project on the 25th anniversary of the Flood of 93, a neat little graphic tracing the path of a baseball at Busch Stadium, our election night graphics, a investigative piece on Northside Regeneration, and a year-end Best of 2018 project.

And those are mostly just the larger projects, let alone the analyses, maps and daily graphics, tools, etc.

Trips

In March, NICAR was in Chicago. It was good, and more of the same. I helped lead a session on “Learn From My Fail.”

In June, I also got a spot at SRCCON in Minneapolis. A bit higher-level/more conceptual than NICAR is (also smaller), it was great to be able to take a step back for a few days and focus a bit wider than usual.

Drone

We finally got the drone and all the approvals and everything we needed to fly this year, so I got to take it out several times. I flew mostly in St. Louis, taking pictures of the new NGA site, the former Pruitt-Igoe site and St. Louis’ water towers. I also flew at a house that was flooded in 1993, though you couldn’t see the river from the house using the drone. I got it out over the Mississippi River to take some photos and video of the Merchants Bridge. And I took it out after a snowfall in December and got some footage and photos of the Mississippi River from the Illinois side just south of Chain of Rocks Bridge.

I was also on our radio talkshow in May to talk about the drone and how we’d use it, and again in July, this time live, to talk about Temporary Flight Restrictions in place around the President’s visit.

Games I played at Geekway to the West:

Thursday
Atlantis rising
Rising sun

Friday
El Dorado
Azul
Hardback
Sagrada
Cottage Garden
Rising Sun
Whistle Stop

Saturday
Sentient
Photosynthesis
Indian Summer
The Networks
Palace of Mad King Ludwig
Topiary
The Thing: Infection at outpost 13
Jaipur
Bottom of the Ninth
Settlers of Catan: Dice

Sunday
New York Slice
Topiary
Blueprints

Raspberry Pi + Blinkt = Weather status

I made a thing!

I’ve a had a few Raspberry Pi Zeros lying around projectless for a while now — they’re just so inexpensive and I love the idea of a tiny cheap computer, so every time there’s a new revision I pick one up at Microcenter. I have an original 1.2, a 1.3 (with the added camera connector) and a Pi Zero W with integrated wireless and bluetooth.

Back when I first started fiddling with the Pis, I bought a few RGB LEDs, but couldn’t get them working right. I’m sure it was a combo of not having the appropriate resistors and user incompetence. I was in Microcenter the other day, and while they did not have a new Pi, they did have a Pimoroni Blinkt: Pre-soldered headers, and 8 individually addressable RGB LEDs with a Python library.

The Blinkt actually fits within the footprint of the Pi — it only looks like it’s overhanging on the sides here because it’s sitting up very high. I have a female header on the Pi and the Blinkt comes with a female header, so there’s a connector in between, making the whole thing about 3/4″ higher than the surface of the Pi.

After plugging it in 1, I installed the library to the Pi. It comes with a bunch of examples to get you started. It’s super-easy to light up a pixel: set_pixel(pixel,r_value,g_value,b_value) for whichever pixels you want to set or update, then show() to send the command 2.

Then I had to decide what to build. I’m not too interested in notification things, like new messages on Twitter or Facebook or new emails or whatever. Those are pretty much on or off, and additionally would require tying into multiple services.

Weather seemed interesting. I’d looked at the Dark Sky API before. There’s a lot of complexity there: Temperature, precipitation, wind, humidity, visibility, clouds, etc. plus looking at current conditions, future conditions, or even past conditions.

Design

Eight LEDs isn’t that many. I wanted to build a status-board type app — no user input (aside from location). But I also wanted to do more than just display current conditions.

I settled on having a number of “screens” the app would cycle through, each displaying a different type of information.  I only make use of a max of seven LEDs per screen, leaving one to indicate which screen you’re currently viewing.

(So far) the screens I have are:

  • Current conditions — displays current temp, low and high in the next 24 hours, and precipitation probability for the current day.
  • Seven-day low-temperature forecast
  • Seven-day high-temperature forecast
  • Seven-day precipitation probability forecast

The display cycles between each screen on a two-second delay. It updates its data from the Dark Sky API every five minutes (probably overkill, but the API gives you 1,000 calls per day for free).

For the temperature displays, I have a scale of < 0° (purple), 0-32° (blue), 32-50° (light blue), 50-65° (green), 65-80° (yellow), 80-95° (orange) and > 95° (red). I’ve also decided to use apparent temperature rather than actual in all cases. Example at left.

For the precipitation, I have < 25% chance (green), 25-75% chance (yellow) and > 75% chance (red). Example at right.

The indicator letting you know you’re looking at current conditions is white, seven-day low temp is blue, seven-day high temp is red, and seven-day precipitation is green. Given the need to clearly indicate which screen you’re on, I’m not sure how many more I’d be able to add without being confusing.

Demo

Unfortunately our weather here in St. Louis isn’t terribly variable at the moment, but here’s a walkthrough of the current displays nonetheless. These are all diffused through an index card as it’s difficult to take a photo of the LEDs directly. The display just cycles through the following four screens.

Current Conditions

The current conditions are: Current temp, 24-hour low and 24-hour high all between 0 and 32°F, and a 25-75% chance of precipitation today. You can see the status indicator light at the far right (it’s white, though it looks blueish in the image).

7-day low temperatures

Pretty simple to read this one: 0-32°F lows all week. Blue status indicator.

7-day high temperatures

Hey, something different! On Thursday, the high temp will be between 32 and 50°F, and on Friday it will be between 50 and 65°F. Red status indicator.

7-day precipitation

Here’s the 7-day precipitation forecast. 25-75% chance of precipitation today, Tuesday, Wednesday and Saturday. Less than 25% chance Monday, Thursday and Friday. Green indicator.

How it works

Here’s the whole program:

import json, time, os.path
import blinkt, requests

status_colors = {'current':[1,1,1],'high':[1,0,0],'low':[0,0,1],'precip':[0,1,0]}

blinkt.set_clear_on_exit()
blinkt.set_brightness(.1)

def getForecast(key,lat,lng):
url = 'https://api.darksky.net/forecast/' + key + '/' + str(lat) + ',' + str(lng)

stl = requests.get(url)

return stl.json()

def getTempColor(temp):
if temp &amp;lt;= 0:
color = [10,0,30]
elif temp &amp;lt;= 32:
color = [0,0,30]
elif temp &amp;lt;= 50:
color = [0,15,30]
elif temp &amp;lt;= 65:
color = [0,30,0]
elif temp &amp;lt;= 80:
color = [60,20,0]
elif temp &amp;lt;= 95:
color = [60,10,0]
else:
color = [30,0,0]
return color

def getStoplightColor(prob,low,high):
if prob &amp;lt; low:
color = [0,30,0]
elif prob &amp;lt; high:
color = [60,20,0]
else:
color = [30,0,0]
return color

def showSevenDayTemps(temps, which):
blinkt.clear()
# set status light
color = status_colors[which]
blinkt.set_pixel(7,color[0],color[1],color[2])
for i in range(7):
color = getTempColor(temps[i])
blinkt.set_pixel(i,color[0],color[1],color[2])
blinkt.show()

def showSevenDayPrecip(precip, which):
blinkt.clear()
# set status light
color = status_colors[which]
blinkt.set_pixel(7,color[0],color[1],color[2])
for i in range(7):
color = getStoplightColor(precip[i],.25,.75)
blinkt.set_pixel(i,color[0],color[1],color[2])
blinkt.show()

def showCurrent(data):
blinkt.clear()
# set status light
color = status_colors['current']
blinkt.set_pixel(7,color[0],color[1],color[2])
# get current temp (use color scale)
color = getTempColor(data['temp'])
blinkt.set_pixel(0,color[0],color[1],color[2])
# daily high and low (use color scale)
color = getTempColor(data['low'])
blinkt.set_pixel(1,color[0],color[1],color[2])
color = getTempColor(data['high'])
blinkt.set_pixel(2,color[0],color[1],color[2])
# precip (red, yellow, green)
color = getStoplightColor(data['precip'],.25,.75)
blinkt.set_pixel(3,color[0],color[1],color[2])

blinkt.show()

def prepData(forecast):

data = {'lows': [], 'highs': [], 'precip': [], 'current': {}}

for day in forecast['daily']['data']:
data['lows'].append(day['apparentTemperatureLow'])
data['highs'].append(day['apparentTemperatureHigh'])
data['precip'].append(day['precipProbability'])

curr_temp = forecast['currently']['apparentTemperature']
data['current']['temp'] = curr_temp
data['current']['low'] = curr_temp
data['current']['high'] = curr_temp

for hour in forecast['hourly']['data'][:24]:
if hour['apparentTemperature'] &amp;lt; data['current']['low']: data['current']['low'] = hour['apparentTemperature'] if hour['apparentTemperature'] &amp;gt; data['current']['high']:
data['current']['high'] = hour['apparentTemperature']

data['current']['precip'] = forecast['daily']['data'][0]['precipProbability']

return data

forecast = None
cur_time = time.time()
interval = 5*60
delay = 2

while True:
if forecast is not None and (cur_time + interval) &amp;gt; time.time():
pass
else:
forecast = getForecast( [api key] ,38.6270,-90.1994)
data = prepData(forecast)
cur_time = time.time()

showCurrent(data['current'])
time.sleep(delay)
showSevenDayTemps(data['lows'], 'low')
time.sleep(delay)
showSevenDayTemps(data['highs'], 'high')
time.sleep(delay)
showSevenDayPrecip(data['precip'], 'precip')
time.sleep(delay)

We’ll just go through it line by line:

import json, time, os.path
import blinkt, requests

status_colors = {'current':[1,1,1],'high':[1,0,0],'low':[0,0,1],'precip':[0,1,0]}

blinkt.set_clear_on_exit()
blinkt.set_brightness(.1)

First, we’re importing the necessary packages, including blinkt to control the LEDs and requests to access the API. The status_colors variable is a dict of the screens and their associated indicator colors. The next two functions tell the script to clear out all the lights when the program exits, and to set the default brightness of the LEDs to the minimum (you can control the brightness individually when you set the pixel, though anything more than the minimum is very bright.

Skipping down to the main program:

forecast = None
cur_time = time.time()
interval = 5*60
delay = 2

interval and delay are about timing, but different things. interval determines how long to wait before getting a new update from the API. As written, the program makes a new call every five minutes. The Pi Zero doesn’t have a real time clock, so if I need the actual time I have to sync it from the Internet somewhere. But I realized I don’t actually need to know real time, only elapsed time. So I get whatever time the Pi thinks it is when the program starts (cur_time = time.time()) and then just check how much time has elapsed to see if I need an update from the API.

delay determines how long to pause on each screen. Right now it’s set at two seconds, which is probably as quick as I’d want it to be. A touch slower might be better.

Next is a loop that runs continuously while the program is running.

while True:
if forecast is not None and (cur_time + interval) &amp;gt; time.time():
pass
else:
forecast = getForecast( [API key here] ,38.6270,-90.1994)
data = prepData(forecast)
cur_time = time.time()

First I have to determine whether or not to hit the API for a new forecast. I need to get a new forecast whenever I either don’t have one at all (e.g. the user has just started the program) or if it’s out of date. So the first condition (line 112) just says if both of those conditions are false, I don’t need a new one.

If I do need a new one, I go get it (getForecast()), passing in my API key, and the lat/lng of the location. One enhancement might be asking the user for a lat/lng on run, or even a city/state or ZIP and geolocating. Here’s the getForecast() function:

def getForecast(key,lat,lng):
url = 'https://api.darksky.net/forecast/' + key + '/' + str(lat) + ',' + str(lng)

stl = requests.get(url)

return stl.json()

Pretty straightforward. The API has a few optional parameters, but a basic call like this gets everything. The function returns the json response.

After I’ve got the data, I do a little prep to make it easier to work with. That’s prepData() on line 116. Here it is:

def prepData(forecast):

data = {'lows': [], 'highs': [], 'precip': [], 'current': {}}

for day in forecast['daily']['data']:
data['lows'].append(day['apparentTemperatureLow'])
data['highs'].append(day['apparentTemperatureHigh'])
data['precip'].append(day['precipProbability'])

curr_temp = forecast['currently']['apparentTemperature']
data['current']['temp'] = curr_temp
data['current']['low'] = curr_temp
data['current']['high'] = curr_temp

for hour in forecast['hourly']['data'][:24]:
if hour['apparentTemperature'] &amp;lt; data['current']['low']: data['current']['low'] = hour['apparentTemperature'] if hour['apparentTemperature'] &amp;gt; data['current']['high']:
data['current']['high'] = hour['apparentTemperature']

data['current']['precip'] = forecast['daily']['data'][0]['precipProbability']

return data

This takes the entire forecast returned by the API and whittles it down into just the datapoints that I need. First I create a dict with no data in it to clear out any existing data. Next I get the seven-day forecasts for low, high and precipitation, creating a list for each measurement. Finally I work on the current conditions. I decided to display the current temperature, the low and high for the next 24 hours and the current day’s precipitation probability. So I set all three values equal to the current temp, then loop through the first 24 hours and update the low or high value whenever I find one that’s lower or higher than the one already stored. I may decide to do the same thing with the precipitation probability. As it is now, the “current” screen just shows the current day’s chance of precipitation, which isn’t that useful at 10 p.m.

Then after I’ve updated the data from the API and prepared the data, I update cur_time to the current system time (line 117), so I won’t check the API again until the interval has passed.

Now, on to displaying the data!

showCurrent(data['current'])
time.sleep(delay)
showSevenDayTemps(data['lows'], 'low')
time.sleep(delay)
showSevenDayTemps(data['highs'], 'high')
time.sleep(delay)
showSevenDayPrecip(data['precip'], 'precip')
time.sleep(delay)

(this is all still in the while True loop)

I have three functions called four times, each one followed by a delay. The first screen shows current conditions:

def showCurrent(data):
blinkt.clear()
# set status light
color = status_colors['current']
blinkt.set_pixel(7,color[0],color[1],color[2])
# get current temp (use color scale)
color = getTempColor(data['temp'])
blinkt.set_pixel(0,color[0],color[1],color[2])
# daily high and low (use color scale)
color = getTempColor(data['low'])
blinkt.set_pixel(1,color[0],color[1],color[2])
color = getTempColor(data['high'])
blinkt.set_pixel(2,color[0],color[1],color[2])
# precip (red, yellow, green)
color = getStoplightColor(data['precip'],.25,.75)
blinkt.set_pixel(3,color[0],color[1],color[2])

blinkt.show()

blinkt.clear() is part of the blinkt library that sets all the pixels to nothing. This just ensures that nothing carries over from the other screens.

Next, I set the status indicator. This uses the status_colors dict to get the color, and blinkt.set_pixel() to set the last pixel to the color (in this case, white).

The first three pixels indicate current temperature, 24-hour low and 24-hour high, respectively. I wrote a getTempColor() function to return the appropriate color. Here it is:

def getTempColor(temp):
if temp &amp;lt;= 0:
color = [10,0,30]
elif temp &amp;lt;= 32:
color = [0,0,30]
elif temp &amp;lt;= 50:
color = [0,15,30]
elif temp &amp;lt;= 65:
color = [0,30,0]
elif temp &amp;lt;= 80:
color = [60,20,0]
elif temp &amp;lt;= 95:
color = [60,10,0]
else:
color = [30,0,0]
return color

It just takes a temperature and figures out which bucket it falls into, returning the appropriate color. I chose the breakpoints somewhat arbitrarily. I knew I didn’t want to have too many colors to distinguish between, so that limited the number of buckets. The buckets and colors are:

  • Really really cold (< 0°F) — purple
  • Below freezing — dark blue
  • Cold — light blue
  • A little chilly — green
  • Nice — yellow
  • A little warm — orange
  • Really hot – red

The fourth pixel on the current screen gives the precipitation probability. I wrote a getStoplightColor() function to take a probability and two thresholds and return a stoplight value. Here’s that one:

def getStoplightColor(prob,low,high):
if prob &amp;lt; low:
color = [0,30,0]
elif prob &amp;lt; high:
color = [60,20,0]
else:
color = [30,0,0]
return color

Pretty simple there. For precipitation, I decided to go with buckets of less than 25%, 25-75% and greater than 75%, showing green, yellow and red respectively.

I’m only using four pixels, plus the status indicator on the current screen. Once I have those all set, all that’s left is to call blinkt.show() to update the display.

The next two screens are the seven-day low and seven-day high temperature forecasts. Those both use the same function, showSevenDayTemps(), which takes the data and which value it is (high or low). Here’s that function:

def showSevenDayTemps(temps, which):
blinkt.clear()
# set status light
color = status_colors[which]
blinkt.set_pixel(7,color[0],color[1],color[2])
for i in range(7):
color = getTempColor(temps[i])
blinkt.set_pixel(i,color[0],color[1],color[2])
blinkt.show()

Again I clear the pixels of their previous values and set the status pixel. Next is simply stepping through the list of temperatures, getting the correct color with getTempColor() and setting the pixel. After I’ve done all that, I call blinkt.show() to update the display.

And finally, we have the seven-day precipitation forecast, with showSevenDayPrecip():

def showSevenDayPrecip(precip, which):
blinkt.clear()
# set status light
color = status_colors[which]
blinkt.set_pixel(7,color[0],color[1],color[2])
for i in range(7):
color = getStoplightColor(precip[i],.25,.75)
blinkt.set_pixel(i,color[0],color[1],color[2])
blinkt.show()

This is almost identical to the temps function, except it calls getStoplightColor() instead.

And that’s it — the program just cycles through that while True loop, updating the data from the API as necessary.

Conclusions and future

The full code is available at this Gist.

Overall, the Blinkt is really easy to work with, mostly due to the library it ships with and the fact that there are only 8 LEDs to manage. It can be tricky to get the LEDs to display the color you’re looking for — adjusting yellow to be distinguishable from orange, for example. The brightness is also tricky to manage — brighter colors are easier to differentiate, but a white pixel at full brightness is painful to look at unless you’re using a diffuser of some kind. If you want to mount this permanently with a diffuser, you’d probably want to modify the code to account for it.

Some other stuff I’ve thought of that might be useful to add:

  • Ask user for location at runtime
  • Screen depicting image of current weather (e.g. oriented vertically, a clear day would be one bright yellow pixel for the sun, several bright blue pixels for the sky, and one green pixel for the ground). Could perhaps even animate between screens to show progress over a day or something
  • Blinking current precipitation indicator to show it’s happening now or soon, rather than just probability
  • Blinking alert indicator to show any weather alerts
  • Moon phase indicator
  • Cloud cover indicator
  • Start script automatically on boot to allow running without computer connection (would need Wi-Fi adapter, and automatic internet connection)

In conclusion: It’s a fun project with lots of opportunities to continue hacking on.


  1. I had already soldered some headers onto one of my Pis, but unfortunately I couldn’t get the Blinkt working. It did work on another Pi, so I figured it was my soldering job. I de-soldered and re-soldered the headers from the Pi and it works now. 
  2. There are also commands to clear out all the pixels, set them all to be the same, and change the brightness of all pixels at once, among others.