Archive for November, 2013

Raspberry Pi Bed Warmer Controller

29 November 2013 at 9:45 pm
by Berck

Andrew asked for a write-up, but this is probably shy of that. Feel free to contact me with questions.

The motivation for the project is that our house is cold in the winter, and it’s painful to go to bed without the bed warmer on. It’s difficult to remember to turn it on every night until it’s time to go to bed, but it takes a good 45 minutes to get nice and warm. The solution? A Raspberry Pi!

Sure, an entire computer is overkill, but there’s actually not an obvious solution that’s smaller. A simple lamp timer or X10 sort of device won’t work because it’s a soft-power switch. Even if you could make it turn on when power’s applied, it’s difficult to manually override.

The bed warmer has separate controls for each side, and this solution handles them separately. I started by wiring leads to one of the warmer controls. First across the switch contacts to be able to control and, and then also across the LED so that I could detect whether or not it was on.

I was able to determine that the GPIO pins on the raspberry pi should be sufficient on their own and I didn’t need anything fancy like a gertboard for this project. I ordered a pi breakout cobbler as well as a dish and solderless breadboard and some jumper wires from Adafruit. I bought a giant pack of resistors from Amazon.

I started with a sainsmart relay module to close the contacts on the switch. I initially figured I could do it with a transistor, but I was worried about interference and strange things happening if I tried a common ground between the Pi and the warmer. I ended up needing some NPN transistors anyway because 3.3V wasn’t going to flip the relay, but the +5V available on the GPIO worked fine.

There’s a ton of ways to access the GPIO pins on a Pi (Python seems to be the most popular). Probably for the purposes of this project the /sys interface and a bash script would have been sufficient, but being the C kind of guy that I am, I was very happy with the well-documented and very robust BCM2835 C library.

After demonstrating that I could flip the relays and turn the warmer on and off, I set about figuring out how to read the LEDs. Once again, I could use a transistor, but I was still worried about interference. Some searching on the internets led me to the wonderful world of optoisolators. I’d never heard of such a thing, but it’s exactly what I needed.

Unlikely the NPN transistors I was able to pick up at the Radio Shack in Woodland Park, optoisolators turned out to be more difficult to come by. I picked up a pair of NTE3083’s from a local store in Colorado Springs I had no idea existed, but they have a huge selection of components. the NTE3083 has a darlington step-up transistor which I don’t believe was at all necessary in my case, but worked just fine. I had to play around quite a bit to find a resistor value to power the LED side of the optoisolator that was just right. Too small, and the LED on the warmer would dim noticeably. Too high, and the optoisolator wouldn’t trigger. Once I figured that out by trial and error, I had a working prototype.

I wasn’t satisfied, though. The clicking of the relays was annoying, and I didn’t want to be woken up by them. (One of the design goals is that if we forget to turn a warmer off, the Pi can do that for us as well, because it’s seriously annoying to wake up at 1am drenched in sweat because you forgot to power the thing off.) Fortunately, my discovery of optoisolators would work well for activating the switch as well. I ordered some more optoisolators from Amazon.

A week later they still hadn’t arrived and I checked the Amazon order status. I failed to notice they were being shipped from Hong Kong and were scheduled to arrive at the end of December. So I gave up and ordered from Radio Shack. This time I went with an NTE3086, which had two opto-isolators on a single 8 DIP IC. Perfect.

Today I finally got around to testing with that. The only problem with this setup is that I used the same color leads from both sides of the switch contacts, because with a relay the order didn’t matter. Now that they’re going through a transistor, it very much matters. It was even simpler to connect the optoisolators than the relays (especially with the very nice and easy-to-locate datasheets that NTE puts on the web), and so I was ready to convert the prototype into something more functional.

I got a solderable breadboard that’s nearly identical to the solderless one I had so transferring the layout would be simple. Were I planning ahead, I would have put the solderable breadboard on top of the solderless one (as it was designed to do), because then you can just lift the solderable one up, flip it over, solder the connections and be done. As it was, I had to transfer it all without forgetting what went were. Not a big deal, but I’ll know if I ever do this sort of thing again.

I’d also spent an insane amount of time ordering some 22 AWG solid-core wire, because threading stranded wire through breadboard holes is a pain. I finally found what seemed like the best value on Amazon and ordered it. When I went to use the wire today, I discovered it’s stranded! I went and looked at the Amazon order and the one I ordered is clearly labeled “stranded”, though the solid core version looks exactly the same.

Anyway, after a day of soldering, modifying the second warmer controls, and then fleshing out and cleaning up the code, it’s done and it works! It’s the first bit of electronics I’ve ever created, and if it weren’t for the existence of the raspberry pi, its great documentation and an internet full of people messing with it, it probably would never have occurred to me to even try it. I really enjoyed hacking on hardware for a change, and I’m guessing that there’s more projects to come.

The source code is nothing fancy and contains nothing non-obvious, but if you’d like to take a look, I put it up on github.

Screw you, Jason Jones

12 November 2013 at 9:37 pm
by Berck

On the very episode of the Daily Show that takes 60 minutes to task for not bothering to fact check their interviews, the Daily Show airs a segment that’s either demonstrative of their own laziness or ignores the facts of a situation in order to score comedic points.

The segment revolves around John Morse, who was recalled for supporting entirely sane legislation that required background checks for conceal carry permits and limited legal magazine capacity to 15 rounds. They interview John Morse, which was just fine. But then, Jason Jones wanders the streets of Denver and asks residents if they voted in the recall election. All but one say that they didn’t vote. Why didn’t they vote? BECAUSE THEY WEREN’T ELIGIBLE TO VOTE. John Morse’s district is a small subset of El Paso county, in Colorado Springs, and those are the only people who got to vote in the recall election. The dude who claimed to vote (for the recall) was probably lying, but it’s possible he was a Colorado Springs resident who just happened to be in Denver when Jason Jones was there. Denver is extremely liberal and makes up the majority of the people who supported the legislation, and exactly 0% of the people who were even eligble to vote for the recall.

So, screw you, Daily Show. Next time you want to make fun of my state, how about you actually take the time to get it right?

Counting blue cars

9 November 2013 at 1:27 pm
by Jonah

Today I have an especially good reason to be thankful.

See this blue car? It’s in the middle of a crime scene. In my parents’ front yard.

blue car

Berck and I took a load of firewood to my parents’ house today. As we were pulling into their driveway, we noticed an unmarked cop car with its lights on down the road at the other corner of their lot. The cop car followed us down the driveway, bleeped its siren, and a tiny deputy stepped out and demanded to know why we didn’t stop. (We were stopped.) She asked if we lived here, and I told her my dad did. She said that there was a car parked among the trees in the front yard and it was an active crime scene and to please not come down there. Berck asked her what it was, and she said it involved a homicide.

I went over and found Dad, who was working on the shed. (Mom is in Seattle.) He said his neighbor had called him this morning, asking why there a blue car parked in his front yard. Dad went out and looked at it and called the Sheriff’s department. When the deputies arrived, they were concerned because the house was unlocked and Dad wasn’t in it, because was working in the shed. They told him that they were so glad he called because that was a missing piece of the puzzle they needed.

The deputy still there came back up the driveway and asked Dad what time he’d seen the car. We looked on his phone and saw that his neighbor had called at 8:54 that morning. She had Dad fill out a form. She showed us a picture of this guy and asked if we’d ever seen him before (the news posted his picture several hours later).

She said there were two homicides and one other shooting victim, but that was all she could tell us. She warned Dad that the media might converge on his house once they found out that’s where the car was found, and if they did, she’d put up crime scene tape across the driveway so they wouldn’t drive up, but that she’d put it high enough so Dad could drive in and out if he needed to.

She said they were pretty sure they knew who the shooter was. She said they thought he knew at least one of the victims and at least one of the other victims just happened to get in the way. She said her department had it on their to do list yesterday to see if they could find this guy, but something else had come up and they hadn’t been able to. That night he shot three people.

So we’re not really sure of all the details, but it appears this guy shot someone during a burglary not too far from their house, shot someone else the next road down from their house, then ditched his car in my parents’ front yard.

Today I’m grateful my Dad is okay!