One Million Monkeys

…because 999,999 just isn't enough.

Temperature Monitoring With Tasker and Raspberry Pi

So I wanted to be able to use my Android phone to check the temperature in my house. I have a  temperature sensor attached to my Raspberry Pi. I use Tasker plugins AutoRemote to send commands to the Raspberry Pi, and AutoNotification to format the respose as an Android notification. I’m using a DS18B20 digital temperature sensor, that uses the 1-Wire protocol to send data to the Pi. I wrote a python script that queries the sensor and returns the temperature in degrees Fahrenheit. To see how to set up the sensor on the Pi, you can follow Adafruit’s tutorial. The problem is that accessing that data requires root access. On the Pi terminal, you would just run scripts with the sudo command and it’s no problem. However, to do this via AutoRemote requires sending your root password in clear text over the internet–not something I like to do, as a matter of course.

I came up with a solution that involves splitting the process of querying the temperature sensor and returning the data into two parts: a server and client. You can then start the server script on the Pi using sudo. Then you can use AutoRemote to run the client, which gets the temperature from the server and returns it to AutoNotification.

Raspberry Pi Python Scripts

The server and client scripts are pretty small and simple. You can get them from my Bitbucket repository on your Raspberry Pi. First change into the directory where you want to keep the files. Then issue the command

git clone https://SDreher71@bitbucket.org/SDreher71/tempserver.git

Once you have the files, you’ll need to make them executable with the command chmod u+x filename.

Start the temperature server with sudo ./temp_server.py

AutoRemote Setup

AutoRemote is a plugin for Tasker. Both Tasker and the plugins used here are available in the Google Play store.

Follow the instructions for connecting your Raspberry Pi to AutoRemote. Then open Tasker and create a new task. Add an action to the task: Plugins > AutoRemote Message. Configure the message: Device: your Raspberry Pi, Message: cd path/to/your/scripts && ./get_temp.py.

On my phone’s home screen, I added a Tasker Task widget, and connected it to this task. Now, pressing the task Icon on my home screen sends the get_temp command to my Raspberry Pi with a listening temp_server running. The message returned by the Pi to the phone is ‘linux=:=70.3′ or whatever the temperature is.

Now, create a new Tasker Profile. I called mine Temperature. Add a State context, and select Plugin > AutoRemote. Select the configuration icon and check ‘Event Behavior.’ Under Message Filter enter ‘linux=:=’ (without the quotes). This will allow the task to filter only messages coming from your linux machine. Then select Advanced on the configuration screen and touch Command. Enter ‘temp’ (again, without quotes). This tells Tasker to assign whatever is to the right of the =:= in the incoming message to the variable %temp.

AutoNotification Setup

Now create a new task for this profile and give it a name (mine is Read Temp). Add an action: Plugin > AutoNotification. Open the configuration and enter settings. Most of these are up to you, depending on what you want the notification to say. The main thing is in the Text setting, I have ‘House temperature is %temp F’ (without quotes). Yours can say whatever you like, but the actual temperature is substituted for the variable %temp. Play around with the other settings until you get it the way you want. This Pocketables tutorial does a nice job of explaining the various options.

That’s it. Now when you touch the Task widget on your home screen, you should get a message in your notifications telling you what the temperature is.

Thanks for nothing!

There’s been a rash of bills lately in the Missouri state legislature that have given me pause. First was a bill to allow home brewers to transport their beer away from home. The second is a proposal for a state constitutional amendment to specify that parents have a right to raise and educate their own children how they choose. The latest one I’ve read about is another constitutional amendment proposal to specify the right of farmers to employ modern farming practices.

These all seem like good ideas. What homebrewer doesn’t want to be able to take his beer to a party or share a few bottles with a friend? And what parent doesn’t want to be assured of his or her right to bring up their children without outside interference? I’m not a farmer, but if I were, it would be good to know that I was allowed to use whatever methods I thought would give me the best yields, right?

But here’s the problem: we already have these rights! They are natural rights to life, liberty, and property. While I understand the legislature’s intent in proposing these measures, by being so specific, the implication is that these rights are granted to us by the state. Rights or privileges granted by the state can be revoked at the whim of whoever is in power.

The bottom line for me is that I am entitled to use and dispose of my property however I like, so long as I am not hurting or defrauding someone else. To tell me I now have the state’s permission to bring a six-pack of beer that I made with ingredients that I bought is absurd. Similarly, if I own a piece of farmland, I shouldn’t need permission from the state or anyone else to grow what I want how I want. My right to life and liberty means that my children are my responsibility to raise and educate–to allow me to raise them in accordance with my family’s beliefs and desires makes no sense whatsoever.

Forum on Missouri Economic Prosperity

image

My wife is a member of the St. Charles County Liberty Project. The group is sponsoring an event today to address issues related to sound monetary policy. I expect the forum to be pretty informative. They have several members of the Missouri legislature present to speak, along with economist Tom Woods.

Epiphany

So with all the hubbub lately about the “fiscal cliff,” sequestration, gun control, pot legalization, and gay marriage, it seems like our ideas on how the country should operate are pretty varied, to say the least. While ruminating on these issues and wondering how we will last with all of this discord in our political system, I have some suggestions for how we can all get along.

What if, instead of a centralized government calling all the shots for everyone, we divided the US up into smaller geographic areas, and allowed each of these areas to govern themselves? Each of these areas, let’s call them “states,” could decide for themselves whether they wanted to allow people to smoke pot or marry someone the same gender as themselves. They could also decide if they wanted to subsidize farmers or punish people for being rich, or whatever the people of that state thought was best. Suppose we had maybe 50 of these states. Imagine the variety we could have in government. And if you didn’t like the laws and rules in one state, you would be free to move to another state. One state might tax everyone and everything so they can give free money away (until the obvious limit is reached when there’s no one left actually earning anything to tax) and tell hapless residents what they can and cannot eat, drink, or smoke–we could call this state “Illinois,” which means “land of incarcerated governors.” Another state might allow people to pretty much live however they like and trust people to make their own decisions and live with the rewards or consequences. This one would be called…well, we’ll think of a name for this one.

However, we would still need some sort of limited national government to see to national level functions like international diplomacy and defense. We could draft some sort of overarching document that would define the structure, responsibilities, and limitations of this central government. We would state explicitly in this document that any power not specifically assigned to the central government would remain a power of the states, or even the people themselves. We should also clearly define the natural rights that we each have, and commit the central government to protecting those rights from encroachment.

The more I think about it, the more brilliant this whole idea seems. I don’t know why no one thought of this before.

Fruitcake

image

I don’t know why fruitcake gets such a bad rap. If you spread a little butter on it and stick it in the microwave for about 20 seconds, it is quite delicious.

My mom and dad make these every Christmas.  They took over the tradition from many grandparents several years ago. The best part for me is knowing they had to buy some liquor for the recipe.

Raspberry Pi Laser Tripwire

So I’ve been playing around with my Raspberry Pi computer, especially with the general purpose input/output pins available for controlling external hardware. Before getting my Raspberry Pi, I had exactly no experience with electronics, but thanks to the various forums at the Raspberry Pi website, and especially the excellent tutorials provided by Adafruit, I am finding my way around both the Raspberry Pi as well as Arduino microcontrollers.

My latest project has involved setting up a laser tripwire that will do something when the laser beam is broken. Ultimately, I plan to wire up a motorized Nerf dart gun to fire a couple of darts when the beam is broken. For now, though, it sounds a buzzer. Here’s how it works:

image

Laser diode powered by 2 AA batteries. Beam is adjusted to shine on the LDR on the other side of the doorway.

image

Breadboard layout of LDR connected to Pi with MCP3008 ADC. The buzzer is connected to Pi pin 22.

The basic principle is straightforward. The laser beam, which is powered by two AA batteries, is adjusted so that it shines on a CdS light-dependent resistor (LDR). If the voltage across the LDR falls below some threshold value, determined by experimentation, then some action is initiated, in this case a buzzer is powered on for two seconds.

One small complication is that the Raspberry Pi only has digital IO pins, and reading the voltage on the LDR requires an analog input. The way I have dealt with this is to use an MCP3008 analog-to-digital converter. Adafruit sells these for $3.75, and has a good tutorial on using it with an analog temperature sensor. In this case just remove the temperature sensor, and connect one lead from the LDR to an ADC input pin, and the other LDR lead to the Pi’s 3.3 volt power. I also put a 10K Ohm pull-down resistor on the ADC input pin. I connected my LDR to two of the four wires inside an old telephone cable to give some extra space, and mounted the business end of the LDR inside a hole I drilled in a small block of wood. This helps block out some of the ambient light that might otherwise mask the breaking of the laser beam.

I’m also a big fan of Adafruit’s Pi Cobbler for connecting things on the breadboard to the Pi’s GPIO pins. If you don’t have one of these, do yourself a favor and spend the 8 bucks. For me, it had the added benefit of making me learn how to solder.

At this point the only consequence to breaking the laser beam is a small buzzer that sounds for two seconds. It’s a garden variety piezoelectric buzzer with a positive lead connected to one of the Pi’s digital pins, set as an output, and the ground lead connected to the Pi’s ground. The output pin is set to low, unless the LDR voltage falls below the threshold, at which point the buzzer output pin is set to high for two seconds, and then returned to low. The code is Python, and can be downloaded here:

git clone https://SDreher71@bitbucket.org/SDreher71/rpi-tripwire.git

The ADCpy.py file is used to read the data from the ADC, and is modified from Adafruit’s MCP3008 tutorial code.

Let me know in the comments if you have any problems or questions. Enjoy!

Update: In response to a comment, here’s a couple of photos of the the LDR mounted in a small block of wood. The phone cable has four wires in it. Two are as soldered to the leads on the LDR. At the other end, I soldered a couple of male header pins for plugging into the breadboard.
image

image

Baseball Justice

Baseball season is nearly upon us, and I for one could not be happier about this. I love the St. Louis Cardinals and cannot wait to see the new team in action this spring. As we approach the 2012 season, though, a bit of news was all the talk recently: the Ryan Braun steroids appeal.

First, a summary for those who may not follow baseball. Ryan Braun, Milwaukee Brewers’ outfielder and the 2011 National League Most Valuable Player, tested positive for “performance enhancing drugs,” PEDs (aka steroids) last October. This news was leaked to the press along with the detail that a second test a week or so later came back clean. Naturally, Braun appealed  50-game suspension that was handed down from Major League Baseball. This is no surprise, as every player that gets caught using PEDs appeals the suspension with claims that, “My trainer gave it to me and I didn’t know what it was,” or “It was just a supplement or prescription or fertility treatment.” These excuses never go anywhere, because MLB’s policy is that regardless of the source, each player is responsible for what goes into his body. If you don’t know what’s in a supplement, you probably shouldn’t take it.

The surprise came in the Braun case last week, when, for the first time ever, a player’s appeal was actually successful, and here’s why: Braun’s defense wasn’t some lame excuse for why he took PEDs but didn’t mean to. Instead, he argued that the original result was invalid because the sample was improperly handled. The story, last I read, was that the collector couldn’t get the sample to FedEx to send to the lab before the FedEx office closed, so he took t sample home with him over the weekend. Predictably, fans were incensed that “just because he’s the MVP, he gets off on a technicality.” The spokesman for the League stated that MLB “vehemently disagrees with the decision rendered today by arbitrator Shyam Das.” and MLB columnist Richard Justice warns that Braun should be careful not to squander the gift of a second chance that he’s received. Apprently fashionable outrage trumps common sense, justice and proper science.

In any laboratory procedure, there are certain protocols that must be followed to ensure that what you measure is what you think you’re measuring and what you intended to measure. If you aren’t confident in the integrity of the sample you’re analyzing, your results are exactly meaningless. In other words, if some guy takes a bottle of Ryan Braun’s pee home for the weekend, it raises some questions. First of all, who takes Ryan Braun’s pee home for the weekend? Second, if you’re going to take Ryan Braun’s pee home, wouldn’t you think that selling it on eBay would be more lucrative than a career as a pee courier? Finally, What might have happened to the urine sample between when it was collected, and when it finally made it to the lab? Since it was out of the proper sample-handling chain of custody for a significant period, we don’t know. And that’s the point. You don’t really know what you’re analyzing at all  anymore, and is it fair punish someone for an analysis of what could just as easily some bike messenger’s bong water?

An acquaintance told me the other day that none of these sample-handling arguments are relevant, because, “everyone knows he used drugs, and he just got off on a technicality.” How does everyone know he’s guilty, if the positive test result is suspect? At best, it’s ambiguous. You didn’t “know he’s guilty” before the test result was leaked, so you’re basing your conclusion on bad evidence. I wish the courier had spilled some gasoline in the sample on his way to FedEx. If he had, it would confirm my suspicion that Ryan Braun is a robot with an internal combustion engine.

Now listen, I am no Brewers’ fan. In fact, my team, the Cardinals, would really benefit from Braun’s absence for almost a third of the season. But I have to agree with the arbitrator on this. Braun’s suspension should have been reversed as it was, and MLB should apologize to him for wrecking his off-season. Besides, it will be more fun watching the Cards thump the Brewers without any excuses. Besides, the mouthing off by that goofy little center-fielder they have (what’s his silly self-applied nickname? Timmy the Teddy Bear? Something like that…) will certainly be more entertaining this way, rather than him pouting that “You only beat us ’cause Braun is out.”

I Love to Fly, and Here’s Why

So I’m flying home from a business trip this evening. In fact I’m sitting in a plane right now typing this, reflecting on my experience thus far, and pondering how it could have gone better. If I was telling this directly to executives at American Airlines I could collect a handsome consulting fee. As it is, I’ll tell you, some stranger on the internet, for free.

Here’s what happened, along with references to my typical traveling experience for comparison. I arrived at the terminal well in advance of my scheduled departure time. I do this I order to have a better shot at success when requesting an exit row seat. So I walked into the ticketing area, looking for a self service kiosk at which to check myself in, select my own seats, print my own boarding pass, and essentially do the job of the ticket agents for them, and then pay a checked baggage fee as my reward for faithful service to the company. As has become the norm, there were several kiosks labeled “For Military Customers” or something to that effect. Now at my departure airport, on several occasions, I have been faced with similarly labeled kiosks when no service men or women were anywhere to be found. In those cases I’ve been instructed by the ticket agent to go ahead and use the otherwise idle terminal. So today, seeing no soldiers, sailors, airmen, or marines lining up to check in at their dedicated kiosk, I decided to avail myself of its service.

I got about half way through the check-in process,when a very sour-looking woman asked me from behind the desk if I was an active-duty military member. “No, I’m not,” I replied.

“Well, you’re not supposed to use that kiosk. It’s for military only,” she scolded as she approached from behind the counter. I looked around at the nearly empty terminal, wondering if I had wandered into a reenactment of Meet the Parents. Not only were there no military members anywhere to be found, there were maybe seven other people in total anywhere in the vicinity of the American Airlines counter, and three of them were employees, including Mrs. Sunshine who was presently scowling at me. I was a bit taken aback, not knowing exactly what response was expected from me, so I continued checking in, while my new friend watched over my shoulder. After my boarding pass printed, I collected my document, gathered my bags, expecting to follow her back to the counter to have the baggage tag fixed to my suitcase. But she just stood there, frowning at me.

“Where should I go to get my luggage tagged?” I asked.

“Did you pay the checked baggage fee at that machine?” she simpered.

“It didn’t ask me to pay a baggage fee,” I reported. Somehow this caused her face to pinch into an even tighter, more menacing glower. I think she might have hurt herself a little, because she made some sort of pained sighing sound as she climbed back across the threshold, into the source of ticket agent power behind the counter. I think she was disappointed that my luggage tag had actually printed, because she then repeated her assertion that had I followed the directions and used the non-military kiosk I would have been assessed a $25 baggage fee. First of all, this is not much of an incentive to follow the rules. Second of all, I know this assertion to be false, because I’ve used the military kiosk before and not only been assessed a fee, I’ve paid it without being publicly berated by Satan’s sister-in-law. I’m confident the software controlling the check-in procedure can keep track of the details of my ticket class and determine whether I’m to be charged the fee or not. I didn’t pay extra on my trip out, either, incidentally.

“What would you like me to do about it?” I asked.

At this point, ticket agent backup arrived on the scene. The deputy scowler was a somewhat younger version of the check-in sheriff I’d been dealing with so far.

“All she’s saying is that you weren’t supposed to use that kiosk, and not to do it again.”

This obviously was quite helpful information, because up until this point I was unclear on what the problem was. Unfortunately, it did nothing to answer my question of how to make amends for my egregious sin. I took my boarding pass, collected my bag and carried it to the baggage screening area.

So I’ve learned my lesson. I’ll never use the military only check-in kiosk at Reagan National Airport again. Unless its not being used by anyone else. Also I’d like to publicly apologize all of our brave military men and women, for my callous behavior, even though none of you were there to be offended by it.  So, you know…sorry for that.

A Little Help For My Liberal Friends

I’ve been hearing a lot of noise lately from my left-leaning acquaintances about how conservatives are mean and selfish and would rather give tax breaks to the wealthy than help the poor and needy. The liberal ethos, being enamored of the prospect of taking other people’s money to assuage their guilt, can’t grasp the possibility that there are other, usually better, means of expressing charity. In fact, there is compelling evidence that conservatives as a group are more generous that their liberal counterparts.

Never fear, though–I, your friendly neighborhood libertarian, have great news for you: the Treasury Department has made donating to the U.S. government as easy as wagging a self-righteous finger in the general direction of some vague “1%.” Let me know how the site works for you.

Get Off of My Lawn!

I have traditionally spent a fair bit of time pondering what life is all about and what I want out of it. As I get older, though, my reflections on these weighty issues are becoming less and less complex. In fact, I was just thinking about this the other day, and I have come to the realization that all I really want from life is to be left alone.

I don’t mean this in any sort of metaphysical, philosophical, or any other symbolic sense. I mean literally, I don’t want other people bothering me. That’s it. My life would be completely satisfying if I could just be left alone.

A few recent situations have come together to weave this tapestry of revelation for me. First, my neighbors: they’re renting the house and moved in sometime last year. I don’t even remember exactly when it was because it seems like they’ve been there, irritating me, forever. Like a wart that won’t go away. I’m not even sure exactly how many people actually live there. They seem pretty young–mid twenties, probably–and apparently don’t have a lot of experience being around people. They moved in at 10 PM on a Sunday night, with a big rental truck that they parked right in front of my house, so our first encounter went something like, “Hi, you must be the new neighbors. Welcome to the neighborhood, and get your truck out of my yard. Thanks.” This was the first seed of my epiphany.

Within a few weeks I found myself going to the fence between our houses, saying things like, “Hey fellas, it’s about 11:30 on weeknight…do you think the basketball game could be put on hold until a more…normal time,”  “Hey kids, I’d really love to continue listening to your frat buddy learn to play the guitar, but maybe Tuesday night at 1 AM isn’t best time for that,” and “Mondaypalooza? What the hell is Mondaypalooza?” The leave-me-alone seed was being watered by all of this.

It’s winter, now, and a little too cold to be outside bothering me with noise at all hours, so lately they’ve taken to inviting all of their friends over to see how many cars will fit in front of my house. After they’ve used every foot of my curb, they all pile into one Nissan Sentra and head out for the day. Yesterday, after I noticed the cars accumulating, I went outside and found one of them wandering around the yard. “Are these cars all here for you?” I asked. “Yeah, why?” came the muttered response. Could you ask their owners to move them from in front of my house, please?” “Why?” he asked. “Why?” I repeated incredulously, “because I don’t want your friends’ cars parked in front of my house.” He pointed to the one closest to their driveway, “That one’s sort of in front of both of our houses.” All I could do was turn around and walk back inside.

The second situation that has fostered my new outlook on life is the parade of school children knocking on my door asking for money. Most of them want it for the school, which, honestly makes it worse. Let me explain: my wife and I home school our two elementary aged kids, yet we still have to contribute to the public schools through our property taxes. And it turns out we pay significantly more tax than most of our neighbors. Now look, I know this was and still is our choice…we don’t like having to pay for services that we don’t use, but we choose to do it in order to best serve our kids. But when the schools then send other people’s kids to my house to ask me to buy wrapping paper or popcorn or coupon books or whatever it is they’re selling, that’s just too much. The way I figure, as much as I pay for services that I get absolutely no benefit from, I’m entitled to not be bothered by fourth graders selling chocolate bars for the same cost as a tour of great Swiss chocolatiers. If I can educate my own children for a fraction of what the public schools get from me and every other taxpayer, I have a right for the schools to then leave me alone. Don’t I?

Anyway, all of this makes me realize that all I really want, at this point in my life, is to be left alone. I don’t want you to remodel my basement, so don’t knock on my door to ask. I don’t want to look out my window and see your girlfriend’s 1999 Hyundai Sonata rusting in the street in front of my house. I don’t need to be told which light bulbs to buy or what to feed my kids for lunch. Just let me sit on my porch in a chest high pair of pants, shaking my fist at the kids getting off the school bus. Stupid kids…get off my lawn!

Post Navigation

Follow

Get every new post delivered to your Inbox.