Hello, World!

When you start programming, or pick up a new programming language, often the first program you write is referred to as a “Hello, World!” program, because for the most part all you want to do is be able to produce a working program, so printing something like “Hello, World!” to the screen often feels like a great start. Once you have that working, you can expand upon it.

So we have a MOD-t 3-D printer that we bought a couple of years ago, and I’ve printed a bunch of things on it, but they were all things that other people designed. I’d always wanted to be able to do my own designs, and had two particular projects in mind. One is a part of a cover for a Starbucks travel mug. I have one that I really like, but the small piece which closes over the mouth hole keeps coming off. It doesn’t really stay in the cover, and is constantly at risk of being lost. So I’ve wanted to create a replacement. But that would seem to require considerable design skill. On the simpler end, I have a portable phone charger that I carry, which doubles as a flashlight. I like it, but periodically the light will come on in my pocket, and I may or may not notice. If I don’t, the battery will die. So I’ve wanted to create an end cap for it, to protect the switch from being pressed accidentally by all the other things in my pockets.

And so I have! I created such a cap using the program OpenSCAD which allows you to design things by describing them with code. For this particular item, it is essentially 3 things: a pretty flat cylinder for the base, a hollow cylinder for the body, and another hollow cylinder that sits just inside the larger one, which is very small to make a tiny ridge inside the body, enabling the cap to “snap” fit on the device at its seam. On the 8th try, I have something I am now happy with:IMG_2764

And I have “published” this design to a site called Thingiverse, which is the biggest repository of shared 3-D designs on the web. We’ll see if anyone else finds it useful.

Whither Weather?

A long, long time ago, we had an amateur weather station (Oregon Scientific WMR-968) at our house. It had a wind vane/anemometer; a rain gauge; an outdoor thermometer/hygrometer; and an indoor thermometer/hygrometer/barometer. It came with a nice LCD display, and all the instruments communicated their data to the display wirelessly. The instruments also had a small solar panel, and a battery compartment, all weather-tight. The solar panels charged a built-in pair of small rechargeable batteries, and the batteries would power the instrument and the radio. There was also room for you to install fancy/expensive Lithium AA batteries which would allow the instruments to work down to -40 F. The console could be connected to a computer as well, and the computer could run software to gather the data from the instruments, log it, and even post it on the internet! We ran our own little weather site, a sub-domain of tastewar.com, but also posted the data to some other sites, notably The Weather Underground. (Not to be confused with the Weather Underground). It was fun knowing that we were helping to provide a “public service” and conceptually having all that weather data on file.

Well, eventually (after a good number of years), the instruments began to fail. I think a big part of it was the built-in rechargeable batteries. I made a half-hearted attempt at building new battery packs from rechargeable cells I bought on eBay, but never really succeeded, and the station fell into disuse until it was only a clock (yet another clock that had to be reset whenever the power went out). And long before that, the PC that had been logging the weather and posting it to the internet had been replaced with a Mac, and I never took the time to find good Mac software to do the same thing. So we’ve been out of the weather picture for a long time. But it’s always been on my mind to get back in the game.

This Christmas, I used my Christmas money to buy an inexpensive weather station from Costco.

It’s an Acurite 5-in-1 with a snazzy display.

It provides the same basic instruments as the old station, but all the outdoor instruments are housed in a single package. This certainly makes installation easier, but the downside is that the location for each instrument is somewhat compromised. Your anemometer/wind vane is supposed to be up as high as possible, away from any obstructions. Temperature readings, on the other hand, are supposed to be taken at four feet above ground, and the instrument should be out of direct sun, yet away from buildings, etc. Similar for the rain gauge, etc. Oh well! I am just excited to have a weather station again!

The console for this station can also be connected to a computer, and of course, you can run software on the computer to log the data, post to the internet, etc. This time, though, it’s not connected to a big, traditional PC, but rather to a Raspberry Pi,

so it’s very unobtrusive. We are using Meteohub software which is the only Linux package I could find that supports this station. You can view our weather data at The Weather Underground. Someday, we may re-create our own weather site as well.

Winter Hobbies

During the good weather, I enjoy riding my bike a bit with my free time, but in the winter I am often de-motivated. That makes it a good time to focus on one of my other hobbies: electronics. I had a pretty fruitful weekend (so far!) on the electronics front. For Christmas, I had bought Tyler a “Game of Life” kit. This isn’t the board game you are likely thinking of, but rather a one (or zero, depending on how you look at it!) player computer simulation of a colony of organisms. A grid of cells is represented by LEDs, and their death or birth is dependent on the level of crowding in their neighborhood. Tyler did a great job soldering the kit together, I think we counted over 100 connections had to be soldered! Certainly, the most challenging project he’s put together thus far.

Trouble is, although you can connect multiple boards together (very clever!), they do cost $$ and a single board ends up with very fleeting generations. I thought to myself, “Well, since this is a board with a software programmed micro-controller, I ought to be able to change the delay between generations!

That idea ended up causing me a lot of work (and/or expense…). First, I had to build the AVR programmer kit that I’d bought previously, figure out how to install a driver for it (on my Win64 system), install all the AVR dev tools, solder a programming header on the board, figure out just enough to be dangerous, mod the code, and upload the new firmware.

Happily, this all worked pretty well! Except for the final step. It should be obvious, but I can’t figure out where the delay between generations comes from, ultimately. But, in preparation, I did all the rest of the above, along with re-building the current firmware, and just reloading that.

I’ve posted a question or two in the Adafruit forums on where the delay might be coming from, so hopefully someone will help me out there.

Sign Switcher

For our church pageant, we retold the Christmas story in the guise of a Christmas Trivia game show. There was going to be a person responsible for holding up signs like “Applause!” etc. but I thought to myself, “I have some scrolling LED signs. I bet with a little effort, I can build/program a device to let someone select from a list of pre-defined messages.” And it turns out, I was right! Pictured below is a slightly updated version of the device. It now has a (lighted) power switch, to save battery, and the Display on/off switch has been upgraded from a bat handle toggle to a nice rocker. Oh, and I changed the messages to some that could be used in a sermon…

20120111-205156.jpg

So intuitive, even a (very bright) dog can use it 🙂

Useful

On Thursday (2 days ago) I ordered an electronics prototyping kit based around an Atmel ATmega8U2 microcontroller. The kit is called an Arduino, and I ordered it from Adafruit Industries (funny name, I know), and paid for UPS ground shipping. I’m glad I didn’t pay for 2-day or 3-day “Priority” shipping, because it arrived Friday, the very next day.

The hardware is “open source” and there are many freely available open source tools for programming it. Tyler and I played around a little with it last night, and made it blink an LED. I played a little more after he went to bed and made it light up a series of LEDs in various patterns. Cute. The programming environment is C-based, so it is pretty familiar to an old programmer like me. Today (Saturday), I spend a couple of hours (chopped up into 5, 15 or 30 minute increments) and was able to make something, well, useful. It also uses a separate LCD display that I also purchased (seemed like it could be a fun add-on), and a temperature sensor that came with the kit. Using the display meant also using my nice new soldering station to solder 21 connections! Here it is:

It is a thermometer that displays the temperature when you press a button. It displays for 5 seconds, then the display turns off to conserve the battery.

I was partly inspired by a friend who also bought a kit and has been enjoying it. I had heard of Arduino starting a few years ago from the Make: blog and magazine. It is very popular among hobbyists and artists of a certain bent. It has lots of useful means of interacting with the real world, and a bevy of enthusiasts who have contributed lots of code and made add-on hardware for the platform. We have plans for a much more involved project, but for now, these little steps are still exciting.