Wednesday, December 17, 2014

Measuring Electricity with an Arduino

A few of us have been working on a project to try and figure out what is the most cost effective temperature at which to set our thermostats if we plan to be away for an extended period. I'll write about the details of that at a future date, but clearly an important factor in that determination is how much electricity our air conditioners use. That is a question that I have focused on recently.

 FPL (Florida Power & Light) provides hourly data, as shown here.

For my purposes, however, this has a couple of drawbacks. First, I would have to pull it from the website every day. Second, the highest resolution is on an hourly basis and I am looking for much more detail than that.

I nosed around the internet and I found a website called Desert Home. This is a fascinating collection of home automation projects with detailed how-tos. Dave from Desert Home referenced OpenEnergyMonitor. They sell a bunch of products for doing this kind of monitoring, but they also have a large number of educational posts that give the theory behind measuring electricity. Since I'm retired and have more time than money I decided to build the tools myself.

I ordered up some CTs (current transformers). They clip around the electrical feed lines coming into the house and produce a small current that is proportional to the large current that is flowing through the feed wires. You can see them near the bottom of the picture below. For those of you not familiar with household electricity, in the US we commonly use 120Volt 2-phase 60 Hertz current. That is, the voltage on each of the feed lines alternates between a root-mean-square voltage of +120V and -120V relative to the neutral wire (the thick white wire in the picture) 60 times per second. That's why there are two transformers in the picture, one for each feed line. Incidentally, the 60 cycle wave-forms on the two feed lines are 180 degrees out of phase (thus it's called 2-phase) with each other, so when one is at +120V the other is at -120V. Thus the potential between the two feed lines, rather than between the feed line and the neutral, alternates between +240V and -240V 60 times per second. That's how you get 240V for your electric dryer or pool pump or whatever. But I digress.

You might think that's almost the end of the story, but you would be mistaken. The way power companies charge for electricity is on the basis of "real power." Real power is the instantaneous voltage multiplied by the instantaneous current, giving the instantaneous (real) power (in watts). The reason that's important, the folks at OpenEnergyMonitor taught me is that electrical devices draw different amounts of current at different voltages. The plots of voltage and current draw might look something like this. So what you have to do is measure the voltage and current a bunch of times a second, multiply them, and then total them up. 

Okay, so here is what my setup looks like with all the covers off.

I have two 200amp panels, each with two feeds so I have four measurements that I take. I ran a piece of conduit from each panel to the blue box. I then connected them to a circuit I built, again based on guidance from OpenEnergyMonitor that conditions the current coming from the transformers so that it can be measured using an Arduino microcontroller. You can see it hanging from the wires in the bottom of the above picture. You will remember that the two components needed to measure the power used are current and voltage. That's why there are two "wall wart" transformers plugged in in the picture. One powers the Arduino and one just delivers the alternating current waveform to the conditioning circuit.

Here is a closer picture of the circuit stacked on top of the Arduino.  And here is everything all buttoned-up.

The Arduino takes around 45,000 readings a minute from each of the four current sensors. That may seem like a lot but you must remember that the voltage is alternating 60 times per second so 45,000 readings per minutes is 750 readings per second and if there are 60 cycles per second that is only 12.5 readings per cycle. The Arduino takes the readings and averages them for one minute then stores that number. Then every five minutes it uploads the data to a small computer up in my office. That computer stores the information in a SQL database that I can access via web browser from any computer on my network.

I was a little concerned that I was only getting about 12.5 readings per cycle but the electrical usage that I measure is within less than 2% of what Florida Power and Light reports so it's pretty close, and I think I can get it even closer if I tinker with my calculations a little.

Here is a graph of the electrical usage on a minute by minute basis. The four colors are the four electrical feeds. I know what circuits are connected to what feeds so I can use the information to track down what equipment is using the electricity. I've just gotten this working but there are some features that jumped out at me. Specifically, the blue, yellow, and red lines all have trains of more or less evenly spaced peaks. The blue ones repeat about once every forty-five minutes, the yellow once every two hours, and the red once an hour.

I showed them to Peg and asked her what she thought they were. She said, "What about the refrigerator?" I said it couldn't be that because they each have periods of even units of time, forty-five minutes, one hour, two hours. They must be things that are running on timers. I unplugged my cable box and TV. I unplugged the printer. I turned off the breaker on the security system...nothing. As it turns out they are three different refrigerators. The red one is the one in the kitchen, the yellow one in the outdoor kitchen, and the blue one a small beverage 'fridge that we have in the guest room. Who'd have thought? Well, Peg I guess.

That's it for now. As I said earlier, we're working on a project to measure air conditioner usage and I'll give you an update on that in a later post.

Thursday, December 4, 2014

Housewarming present

I've mentioned in the past that my brother John and his wife Doreen are building a vacation home here in Venice. It was supposed to be done in July, then August, then September. Well, I guess new houses asymptotically approach completion, half way, half way half way but never quite there.  Each time I go by there are a tradesperson or two over there tinkering with something. However, they were down a few weeks ago, and they got a certificate of occupancy and actually stayed in the house. I thought that was official enough to give them their housewarming present.

It's what is sometimes called an ambient device. The idea is that is kind of conveys information to you almost subliminally. For instance, I've seen these small globes that sit on the table in your living room and glow green when the stock market is going up or red when the stock market is going down.

Well, down here in Florida we focus a lot on the weather. Considering how little weather we actually have here relative to the rest of the country it's a peculiar fixation, but it is what it is. Here is a picture of the device. It has two display modes, one is temperature and one is barometric pressure.

Here it is displaying a temperature of 83 degrees Fahrenheit. The top two lights represent the tens place and the rest represent the ones place.

In Barometric Pressure mode the top light shows the current pressure, the next one down the pressure three hours ago, the next one three hours before that, etc. etc. Here we can see that the current pressure is  between 30.00 and 30.20 inches of mercury, down slightly from three hours ago.

The device is made from alternating layers of cedar and acrylic. In the center of each acrylic layer is an RGB LED. It's really three LEDs (Red, Green, and Blue) built into one. Each color can be illuminated at 4096 different intensities and thus, theoretically, each LED can display 4096 x 4096 x 4096 = 68,719,476,736 different colors. Of course humans can't discern anywhere near that many colors so I settled on Red, Orange, Yellow, Green, Blue, Indigo, and Violet (Roy G Biv) White and Black (no light at all.)

I went over to Lowes and picked up cedar board meant to be a fence rail and ran it through the planer. Then I cut it into isosceles triangles.

I made some jigs and glued the cedar into squares.

Then I made another jig to drill holes to fasten them together and for the LEDs and wires.

I made a bigger square of cedar for the bottom and hollowed it out for all the electronics. Then fastened them all together.

Friday, October 31, 2014

What's the difference between a coffin and a casket

Historic Spanish Point in Osprey, Florida is re-enacting a Victorian funeral for Halloween. (Some people know how to have fun.) A few weeks ago Kara Pallin from over there called me up and asked if I could make them a casket in the Victorian style. I told her that if she could show me a few pictures of the kind of thing she was looking for I could probably cook it up. Well, I just thought I'd show a few pictures.

Built out of pine and plywood.
Painted classic black

With fittings added, including period appropriate decorations

Ok, that's it. Oh, by the way, while they are often used interchangeably, a casket is usually rectangular in shape while a coffin is the elongated trapezoid of this one.

Anybody who's interested, just hop in.

Happy Halloween.

Tuesday, September 23, 2014

Solar calendar

Yesterday was the equinox, equal day and night. It's not really equal day and night for a couple of reasons. One, daylight is generally considered to begin when the first part of the disk of the sun is visible above the horizon, and to end when the last of the disk is no longer visible. Whereas, the equinox refers to the center of the disk of the sun. Two, the curvature of our atmosphere causes refraction that allows us to see the sun before it is actually above the horizon, but I digress.

For some time I have been thinking about building a device that is kind of the equivalent of a sun dial, but instead of telling the time it would tell the date. We all realize that the fact that the earth is tilted relative to the plane of the ecliptic gives us our seasons. As the earth moves around the sun that tilt causes the sun to appear higher in the sky at some times of the year than at others. I wanted to use the changing height of the sun, and thus the change in the location of the shadows that it casts, to mark the passage through the year. It would work kind of like this.
I also wanted it big enough so that the day-to-day changes would be observable as a way of connecting with the movement of the earth through space.

As it turns out I have a wall in the courtyard of my home in Florida that was crying out for some decoration, So here it is.

My plan was to cut pieces of wood in short arcs and assemble them end-to-end. I was discussing the project with my friend Jim Nemec, who is, among other things, a boat builder. He allowed as how that was the incorrect way to do it, and that I should cut thin strips and laminate them into a curve. As it turns out, he was correct.
I bought a piece of mahogany and ripped it into strips a little over five feet long.

Then I cut some particle board to form an arc of a circle with a ten foot diameter, the arc being a little longer than my mahogany strips, and screwed the particle board to my workbench.

Jim and I then slathered a bunch of epoxy onto the strips and clamped them to the form.

The next day I popped it off, sanded it and trimmed it.

Then I finished it with boat varnish.

As luck would have it, I finished it just in time because, as I said earlier, yesterday was the autumnal equinox (in the northern hemisphere or the vernal equinox in the southern hemisphere). That was important because I want the equinoxes to be exactly in the middle of my calender. Thus, I had to note the position of the shadow yesterday, and mount it such that it fell right in the middle, and such that the brass rod that I attached to the wall was at the center of the circle determined by the arc of the calendar.

Getting it in the exact position, both technically and aesthetically was no mean feat and required the assistance of my brother John and his wife Doreen, holding...looking...holding...marking.... But it's up, and here it is.

I have a measuring tape on the calendar so I can record the position of the shadow each day. I'm not sure how I'm going to mark the days on the calendar, But I have a year of recording before I need to figure that out. I'll report back next September.

Monday, September 15, 2014

Basket Bench

These projects have a lot of hidden costs.

Peg thought we needed a headboard for our bed down here in Florida. She opined that I could probably whip something up in not too much time for not too much money. We haven't decided whether to buy a king size bed (I'm not sure you realize how much mattresses cost) or stick with the queen size, so while we're wrestling over that I made a bench for the foot of the bed that would work for either size.

 I made the bench from cherry. Here is the top with mortise and tenon joints, and biscuits for the mitered corners, and here it is assembled.

This is the body of the bench where I used half-lap joints.
I used pre-woven caning material for the seat sections of the top, the sides and the back.
 Here is the body assembled.
 These are all the parts, varnished and ready to put together.
 This is the completed top ...
 and the back with the caning installed.
All put together.
And in place. I'll give you an update on the headboard once we decide that mattress question.

Monday, June 30, 2014

Wedding Present

It was pointed out to me that I never posted anything about the chest of drawers that I made for my daughter and her husband as a wedding present. I built it in what's commonly referred to as the Greene & Greene style, after Charles and Henry Greene, brothers who were architects and furniture makers who worked in the first part of the 20th century, and who were strongly influenced by the Arts & Crafts movement.

I  built it from lyptus, a farm grown hardwood similar in appearance and workability to true mahogany.

Here I am working on laying out the boards for the top of the cabinet. This can be a fairly time-consuming process if one wants to make the transition from board-to-board appear as natural as possible.

Now I am edge-gluing the boards. This can be tricky, especially when working by oneself because the boards must be carefully aligned, with no gaps, and clamped tightly enough for a good joint but not so tightly that all the glue is squeezed out.

And here is the assembled top before the "breadboard ends" are added. There is a fair amount of engineering that goes into making pieces of furniture of this size out of wood, because wood expands and contracts due mainly to changes in humidity. Further, almost all this expansion and contraction occurs across the grain and almost none parallel to the grain. Thus, if not properly designed a piece of furniture can pull itself apart.

This is the skeleton of the piece, test-fitted together.

Here you can see the sides and back of the cabinet. Those panels that fit between the rails and stiles are not glued in place, but rather just float in grooves. Again, this is to allow for expansion and contraction of the wood.

This is the layout of the drawer fronts. I am again matching grain for the best appearance and working on the arrangement of the carved ginkgo leaves, before I inlay them.  The leaves are carved from a wood called yellowheart. I also patterned the drawer pulls after some Greene & Greene architectural details.

Finally, here is the completed piece. I wanted it to be able to be used as either a dresser or a dining room side-table. For that reason I used hidden ball-bearing drawer glides so if it was used to store dishes or other heavy items the drawers would be up to the task.

Well that's it. I hope you like how it came out.

Wednesday, May 21, 2014

Intervalometer and the stars

I periodically get an email newsletter from Make Magazine. In a recent issue Ron Risman had an article about how to take time-lapse pictures of the stars. You can find the article here. I thought it would be fun to try, but I don't have a digital SLR camera. As luck would have it, my brother Jim does, and he was coming down to Florida for a long weekend a couple of weeks hence. He brought his camera down and we thought we'd give it a try.

Just to manage expectations, we don't yet have any pictures worth looking at. We followed the guidance in Ron Risman's article, but realized we needed an intervalometer. Now I didn't actually know what that was but Jim educated me, saying that is was a device that could trigger a camera at specified intervals, hence the name. Further he explained that his Olympus camera had an infrared receiver that could be used to trigger the shutter using a hand-held remote, which he didn't own.

We jumped on the internet and found some work by jmknapp that used an Arduino microcontroller and an infrared LED to emulate the remote. That information can be found here. As it turns out, I had an Arduino microcontroller and an IR LED. I quick downloaded jmknapp's software, and made a few little changes so it would trigger the shutter of Jim's camera at intervals we could set.

And here it is. Ok, I know, not much to look at, but this is the proof-of-concept stage. We didn't get this all done until the last evening that Jim was going to be down here. We took a few pictures, changed some settings, took a few pictures, etc. The moon was just into its second quarter so it was bright enough to wash out the pictures, and it took us a while to get the focus right, but we were closing in on it.

Since Jim left I have been working on improving the user interface and functionality and here's what I have.

For testing purposes I have temporarily replaced the IR LED with the red one you can see in the picture so I can see if it's working with the unaided eye.

As you can see I added a Delay feature so Jim can have it wait for a specified number of hours/minutes/seconds before it starts taking pictures. I also let him have it stop taking pictures after a certain amount of time or a certain number of pictures.

I also added another mode. I included a Passive Infrared sensor (PIR). Jim gets lots of deer and other wildlife in his yard, and in PIR mode the camera will be triggered by motion in its field of view.

The semi-circles at the bottom of the screen are indicators of the sensitivity of the PIR, which can be adjusted via a knob.

All that's left to do it put it in some kind of case, but I thought it would be good to test it in the field first. I'll be going up to Chicago in a few weeks and we'll try it out then. I'll post any time-lapse videos that are worth looking at.

Sunday, May 11, 2014

Talking Computer Assistant -- Fail

Some time back there was an article in Make Magazine written by George Tempesta.
Make Magazine Electronic Nag He described building a project that would play pre-recorded reminders. It uses an Arduino's clock and a proximity sensor to know when to play the reminders.

I thought I would like to take it further and have it read my Google Calendar and take the reminders from there. I didn't want to have to record a specific reminder for each event so I wanted to use text-to-speech conversion so it could read me the reminders, and then I thought it would make sense to use voice recognition so I could tell it whether to save the reminder so the next time it detected my presence it would remind me again, or delete it because I had done whatever I wanted to do. I knew that all this text to speech and speech to text stuff would as well as interfacing with my Google Calendar was going to take some extra processing horsepower, so I planned on using a Raspberry Pi which, for those of you not among the cognoscenti, is a single-board Linux computer.

Everything was going along swimmingly. I studied at the University of Google and found a great article by a guy named Dan Fountain on converting text to speech here. It had my Raspberry Pi yacking up a storm in no time. Then I found an article by Dave Conroy on using the Google Speech Recognition interface here. It worked great. I wrote the programs I needed and assembled them into a workable system, albeit version 1.0 with lots more things I wanted to do.

On this past Wednesday I started to write this post and got out my video camera to record a demonstration to show you. Well, it didn't work. I went through it and figured out that Google turned off the version of speech recognition that I (and apparently a lot of other people) were using, and replaced it with a newer version. Unfortunately, the newer version is aimed at professional developers and has a whole charging scheme in place.

I was very pleased with how the system was working and now I'm not sure what I'm going to do. I am looking around for another system, as well as considering joining the Google Developers Network but I haven't yet been able to figure out exactly what that entails. I'm sorry this is so anti-climactic and will report back as soon as I get it working again, but I wanted you to know I haven't been just lolling around.

Sunday, April 20, 2014

Secret Knock Gumball Machine

I want you to know that just because I haven't posted much recently it doesn't mean that I haven't been busy. I've been working on a housewarming present for by brother John and his wife Doreen. They are building a house and it's supposed to be finished in August. That project is well along now, but it's a secret so I can't blog much about it until I give it to them.

I do want to tell you about something I made a while back, though. It was adapted from an article in Make Magazine, issue 25 called Secret-Knock Gumball Machine by Steve Hoefer. As the name implies, it is a gumball machine, but instead of putting in money, you knock on it in a particular pattern. If you get the pattern right it gives you a gumball. Below is a video of one of them that I made.


The default knock, as shown is the video is "shave-and-a-haircut" but can be changed to anything the user would like. I heartily encourage you to look over the article. I think the programming that Hoefer did is particularly clever and could be used to open a door or a treasure box, or to trigger any other thing.

I built the one shown in the video for my brother Jim. However, I modified the design in the article in several respects. First, I made the dispensing wheel horizontal, rather than vertical. I did this so that it was more patterned after conventional gumball machines. Second, I added a switch so that the machine knew when it had fed a gumball, and I changed the software to add some strategies like reversing the feed wheel if a gumball did not feed in a certain amount of time, thus making the dispensing process more dependable.

I made the one for Jim out of wood. I was happy with it, and it worked pretty well, but it would occasionally jam. Nothing would break, but on rare occasions you had to turn it over and then set it back upright to clear it.

While I was building Jim's machine my sister Monica and her husband Jim visited, and I showed them how it was going to work. Usually when I show my family what I'm building they watch and say something like "Oh, that's very interesting. . . . What should we do for lunch?" but Monica and Jim asked me to demonstrate it a couple of times and asked a number of questions about the details of the design.

Therefore, I decided to build a second machine, this one for Monica. I wanted to make out of acrylic, and I wanted the feed to be more dependable.

I knew that the thing that was causing the jamming was the hopper mechanism that funneled the gumballs to the feed wheel. I was experimenting with a bunch of sculpted designs that would guide the gumballs to the holes in the feed wheel but wouldn't allow two or more gumballs to block up the mechanism. My son-in-law Tim looked at it and said, "You're over-engineering it. Get rid of the hopper and just let the gumballs fall down the throat of the machine and drop onto the feed wheel. They'll fall into the holes without jamming."

I realized that he was right. The only time it might not feed continuously is when there are only one or two or three gumballs left, but that is only a fraction of the time. Mostly it will have a bunch of gumballs and they'll easily drop into the feed wheel.

Above is a picture looking down the throat of the machine. The wheel with the holes in it turns and as it does a gumball that is in one the holes passes over the feed chute and the gumball falls out, rolls down the chute, and comes out the front of the machine. The last time I talked to Monica about it they had just about gone through the entire box of gumballs that I had given them with the machine (the standard size package has 850 gumballs) and there had been no jamming or mis-feeding.

This is a great project. People are fascinated by it. Again, read Steve Hoefer's article and look at his blog posts on

Wednesday, March 26, 2014

Fresh Mozzarella

When my sister Monica and her husband Jim were here we had to suffer through a rainy day, so we decided to make some Fresh Mozzarella. If you've never done it it's easy, doesn't take long, and is way good. I use the recipe from There are lots of recipes around but this one works well, although I think it comes out a little salty so I cut back on that a little.

There are only four ingredients, milk, food grade citric acid, rennet and salt. You can probably find the rennet at the food store, but you might have to order the citric acid on-line. The only tools you need, other than the pot and the stove, is an accurate thermometer and some cheesecloth. You mix the milk and citric acid, and heat it up.

Then you mix in the rennet and let it sit for a little while.

Then you strain it through the cheesecloth.

Then there's a little heating and squishing and stretching and heating and squishing and stretching.

Then you eat it. Tomatoes are optional.