History Is The Best Predictor Of Future Events

Last Christmas my wife got me a big cheap Double Horse co-ax helicopter. I was instantly hooked. The helicopter on the other hand was quickly destroyed. So I ordered another big, cheap helicopter. This time a Double Horse single rotor, fixed pitch. This helo so far has survived. Plus it taught me a lot about flying. Unfortunately, there is not a lot of room for follow on projects with the Double Horses. They don’t lift very much and they are hard to control.

So I set out to find the next step. For me that was building from scratch a 450 Trex clone. For those who don’t know a 450 Trex is the Honda Civic of the RC helo world. Basically you can go into any hobby shop and they will know exactly what you are talking about and have parts. Furthermore the parts are dirt cheap (although they get expensive when added together).

So in my process of trying to understand this whole new world of helicopters and trying to select the right parts from among that world, I discovered Hobby King. Hobby King is a online retailer of VERY cheap Chinese made RC parts. Basically they copy everything Horizon makes and sell it at 1/4th the price.

This downside of this (other than notable quality issues), is Hobby King is plagued by backorders. I think at any given time, if I made a basket of things I wanted, half would be on backorder. When you ask Hobby King about those backorders their stock answer is 7-30 days. If you press them (via their 24×7 chat support, which is cool), they will say 1 of three things: 1) 7-30 days 2) 1-4 months and 3) never/unknown.

So being frustrated with these answers, I did what I normally do. Which usually involves reading every word on the site and often looking at the source. I discovered that they had an API that allowed you to check inventory levels. Furthermore their API returns text. Ah ha! I have been wanting to learn the php/mysql fu but I had yet to find the right project. Other possibilities required me to learn xml or json parsing, which made the learning curve to steep. But with my recent arduino adventures, php was starting to feel safe so really I would be just bolting on the mysql component.

Essentially the core questions when shopping at hobby king are, when will this item be back in stock and how fast are they selling. One can be answered with historical data, the other can be predicted by knowing how often shipments come in.

What followed was a weekend of PHP/mysql tutorials, frustration and hobbyking-watch.com. In short I designed a site and series of databases that aim to track Hobby Kings prices and inventory on a daily basis. For now, I am just reporting data. Hopefully, in a few weeks I will have enough data to start making predictions and performing analytics on Hobby King’s performance.

I submitted the link to hobbyking-watch.com to Reddit and got a lot of great feedback. The first suggesting I implemented was coloring the cells on the main page to indicate hobby king’s inventory level and backorder status. Lots more to follow.

Anyway, it was a hobby weekend. For the time I was not building the big silver 450 trex, I was working on a website to help others build theirs.

Posted in helicopters, mysql, PHP, Random Projects, RC

Never enough hack

Hypothetically, say you build a device that would show tweets on an LCD screen and you put this device in your closet, with a live stream… and you told people about it… and it crashes…. regularly.

Those of you in the audience with skillz might looks at the SocialBot9000′s code and try to isolate the memory leak. However I do not have mad-coding-fu. Sooooo… I grabbed a 5v Arduino Pro Mini, a relay, a breadboard, an 82 ohm resistor and a bunch of jumper wires.

Basically I used the “Blink” sample sketch and just lengthened the last delay to 60000.

In place of the LED I have my relay. The business end of the relay is connected to SocialBot9000′s ground and reset pins. So when it kicks over. Blam, SocialBot9000 resets.

Memory leak solved.

For future google searchers: If you want to reset our arduino uno using the arduino reset pin (extra keywords for Google’s pleasure) connect the arduino reset pin to ground. I say all these keywords because for some reason this information was hard to find.

Posted in Arduino, Pro-Mini, socialbot9000

SocialBot9000: Arduino Based Twitter Display

If for some reason the ustream embed does not appear, refresh the page.

UPDATE: The SocialBot9000 device has returned to meet it’s parts box. Look for something new and exciting… when I think it up. I am leaving the rest of the post as is.

Display Your Message on the SocialBot9000. (UPDATE: SEE ABOVE NOTE)

  1. Enter your message in the form below.
  2. Press “Tweet”. You will be redirected to twitter.
    • If you are not logged in you will be promoted to do so.
    • You will see your message with the required syntax ready to tweet.
    • tweet your message.
  3. watch the ustream for your message to appear
  4. Be Patient: you are waiting for twitter to put your tweet in the search results (30 seconds or so), the socialbot to see it (5 seconds-ish), ustream to catch up (30 seconds).

Project Origins:

I was watching Ben Heck’s show on revision3. For Valentines day he made a device that would show love messages sent via twitter. Ben Heck being a nerd master, with more fu than I, WAY over complicated the project. It had custom microcontrollers, php, serial interfaces and all kinds of crap cool stuff. So I thought to myself, I can rebuild it simpler, smaller and with basically the same hardware setup I just used for my Arduino Thermostat.

Required Hardware:

  1. Arduino Uno
  2. Ethernet Shield
  3. LCD Display
  4. Protoshield
  5. Jumper wires

Basic Steps:

In short we need to do the following:

  1. Build Hardware
  2. Search twitter for whatever we want to display
  3. Put it on the screen (Arduino Ethernet Client)
  4. Provide some sort of UI to let the world play with Socailbot900

Building the Physical SocialBot9000

If you have the hardware I listed above this is going to be really easy. This part of the project took me less than 30 min.

  1. Insert Ethernet Shield into Uno
  2. Insert Proto Shield into Ethernet Shield
  3. Connect jumper wires
  4. Insert LCD
  5. Start the harder part (well for me anyway)

There is a lot of information on how to hook up LCDs so I won’t go too deep. The real complication here is not conflicting with the Ethernet. So check out the source (link bellow) for the pin configuration I used.

Here is a cheat sheet:

LCD Pin Hookup
1 Ground
2 5v
3 Pot (middle pin)
4 Arduino Digital 2
5 Ground
6 Arduino Digital 3
7 None
8 None
9 None
10 None
11 Arduino Digital Pin 4
12 Arduino Digital Pin 5
13 Arduino Digital Pin 6
14 Arduino Digital Pin 7
15 5v
14 Ground

Searching Twitter:

Twitter provides a handy API thing to easily extract data and BAM:

http://search.twitter.com/search.json?q=socialbot9000

That will get ya where you want to go. So I wrote a PHP page that curls that URL, cuts out the message and gets is ready for the socialbot. So the PHP looks like this:

$ch = curl_init(“http://search.twitter.com/search.json?q=socialbot9000″Smilie: ;);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_GET, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$start = strpos($output, “start”Smilie: ;) + 6;
$end = strpos($output, “end”Smilie: ;);
$tweet = substr($output, $start, $end-$start);
echo ‘<'.trim($tweet).'>‘;

Arduino Ethernet Client:

If you read this bildr turtorial you are 90% there.

There are a few important notes.

  1. I am going crazy with the OLs in this post.
  2. Arduino 1.0 supports DHCP, so you don’t have to assign the Arduino a static. Because this is a client situation that works out well. EXCEPT when you are on a network where the DHCP server and the Arduino don’t seem to talk, then its back to static land. Moral of the story: try DHCP first.
  3. To keep this really simple I would have loved for my twitter searching part to be on the same server as everything else. However, my shared hosting account does not have an IP so I had to host this part somewhere where I could pretend. Like a linux machine in a closet somewhere in the world.

You can download and play with the Arduino code here (right click, save as, bla, bla, bla, if you got this far I really don’t need to tell you).

Provide some sort of UI to let the world play with Socailbot900
For now that UI is this post, the ustream and the iframed form. The ustream is coming from a webcam/netbook in a closet. Earth shattering I know.

I am pretty sure my form could use some help, but it was not the focus of this project.

The one cool thing that is interseting to note is how to set up a tweet, making it easy for people to interface with the SocialBot9000.

First the syntax. My twitter search of for “socialbot9000″. So twitter will return any tweet where its mentioned. Then I look for “start” and “end”. So for a message to appear you need to tweet something like “@socialbot9000 start I like cats (not really) end”. I am a online marketer for a living and I can tell you trying to get people to set that up for themselves will be a pain and rife with errors. Enter the form.

So the form submits you message to a php thing that concatenates it with the rest of the syntax. There is client side processes to make sure the message is less than 30 chars. Because anything more is just useless.

So my PHP for the UI should looks like this:

$tweet = $_POST["limitedtextarea"];
trim($tweet);
header( ‘Location: https://twitter.com/intent/tweet?text=@socialbot9000 start ‘.$tweet.’ end’ );

So in here is a marketing pro-tip. Want to set up a message that people can quickly and easily tweet. Just use the URL above. A fine example would be this.

Posted in Arduino, Ethernet, LCD, socialbot9000, twitter

Bringing It all Together – Internet Enabled Arduino Thermostat

So the Arduino that is on the wall is just one, relatively dumb part of the system that makes this work. There are several other key systems that make the Arduino thermostat a full replacement for my programmable thermostat. I am going to walk though those parts so that anyone wanting to recreate this project will know all of what is needed.

In My House:

Arduino Thermostat: Is has a very simple API that you can see by looking at the source. It has simple inputs and outputs. It’s what you can do from there that is cool.

Ubuntu Box: On my home Ubuntu box I have a series of one line scripts that use curl to access the API. These scripts set the desired temp at certain times. They are launched by cron jobs. Additionally, The Ubuntu box asks the thermostat what going on, then uploads that data to my web host. This is essentially the brains of the operation.

Router: The target temp is changed via an online interface. Because this interface lives at my web host, I need some port forwarding to allow the Arduino thermostat to talk with the outside.

Outside My House:

The Web Host: Stashed away in the bowels of one of my sites is the web interface. It puts a no so shiny interface on my data and allows the temp to be manually set. If you really wanted to, you could do away with the Ubuntu machine and do all the automatic temp changes via php+curl/cron.

Posted in Arduino, Arduino Thermostat

Mission Accomplished – Internet Enabled Thermostat Installed

Thanks to Bush “mission accomplished” means there might be some minor details to still wrap up. Smilie: :)

OK so I received my new relay. Removed the old one, installed the new one. Turns out it might not have been the relay at all. I also had to remove a resistor that I (mistakenly) was using to protect a LED and the relay. I needed 3.3v to kick the relay, so out with the resistor and the whole thing came to life.

So I put the thermostat on the wall then kicked back to watch the magic.

And the magic happened, then stopped, then happened, then stopped and repeated intermittently with some or no delay. Turns out my code was allowing the system to be far to sensitive. As a result it was kicking the heater on and off repeatedly.

The Arduino Internet Thermostat idle

I addressed the problem in V1.1 of my own code. I added a few more if statments and basically told the thermostat to wait a full min after it thinks it should turn on. If after the min it still needs to turn on, do it.

This seemed to do the trick. But is could still get yet cooler… So I adjusted the code to display a countdown on the LCD when it was getting ready to turn on. This addressed a user case. In short my wife wants instant results when she wants is warm, so the screen will show her that the thermostat is working on it, and how long she will have to wait. Also I think its awesome, bonus points!

The Arduino Internet Thermostat getting ready to start

Since I was going crazy with the LCD, I added code that would tell me how long it had been running. Look out NEST I am coming for you.

The Arduino Internet Thermostat running

Whats that you want to see the source? Fine enjoy.

Posted in Arduino, Arduino Thermostat

Summit Attempt Failed

I often think of the final stages of a build is similar to a summit attempt. You plan and plan, get everything in place and then attempt final integration. Sometimes you make it, sometimes weakness is exposed and you have to regroup.

Well I had the final version of the thermostat built and the case ready. I drilled holes in the wall to wire Ethernet and power. Just to find out the relay I had used in the thermostat is either dead or will not do the job. Ahhhhhhhhhhhh…. Fail…

So I have ordered a replacement solid state relay that should easily do the job. Now I just have to wait.

The practical up shot of the failed attempt is it reveals other weaknesses in the design. For example, the case I had built, is to big. Additionally the mounting scheme I was planning is far to unstable. So some rethinking is needed there. Finally, I need a quick way of reverting to the old thermostat. That last requirement hurts my inner hacker but is an unspoken wife mandated requirement.

Posted in Arduino, Arduino Thermostat

Arduino Thermostat on Perfboard

Last night I moved from bread board to the permanent perfboard. Things are starting to look good. The first thing to note is the major component change. I am no longer using an Arduino Uno + Ethernet Shield. The Arduino/shield have been replace with a Ethernet Pro from Sparkfun.

The only challenge with this integration was the pin layout on the Ethernet Pro. For some reason digital pins 1-7 do not line up with standard perfboard. Looks like standard Unos are like that too. Kinda a pain in the ass. I wish they would change that in the next version but it would mean revising all the shields as well, so unlikely.

If there is one thing I have learned from my last several projects its: preperation = success. Before I started soldering, I sat down and made detailed notes about what was on my breadboard. Doing so mitigated common errors I make like incorrectly connecting LCD and Arduino pins. It also made it easier to centrilize power dispribution. One of these days I will have a custom PCB made for a project, but one step at a time.

So I did all the soldering last night and then uploaded the program and plugged it in this morning. It was one of those great moments with everything magically worked. There were no software/hardware issues. and it appears I got the temp sensor and the LCD 100%. The only problem I found is the relay circuit is currently not working. Looks to be a bad connection issue.

After I fix the relay circuit its enclosure time.

Posted in Arduino, Arduino Thermostat, Ethernet, Ethernet Pro, LCD, OneWire Temp Sensor

Its Alive!… Well the temp sensor anyway.

It took me less than 1 hour from the time I received the temp sensor to having it integrated into my internet enabled Arduino thermostat project. This morning I had the pleasure of waking up and looking at the data my system had collected over the evening. Ohhhh…. Data….

Integration was made easy by a great bildr tutorial. Actually, the hardest part was adding the OneWire library. Turns out you copy the whole folder into your library folder and then restart Arduino. So pretty easy.

Next step, putting everything on perfboard.

Posted in Arduino, Arduino Thermostat, OneWire Temp Sensor

Internet Enabled Arduino Thermostat

So I was sitting on vacation, looking for something to mod when my heating system kicked on. I looked at the thermostat and thought, “I can make that a lot cooler”. Plus Dad had given me an Ethernet shield for Christmas so I was looking for an excuse.

Basic Requirement are as follows:

  • Figure out if the heating system should be on or off.
  • Accepts incoming temp requests.
  • Report out it’s current status.

I am taking a thin client sort of approach to this. I want the thermostat to be kinda dumb while my Ubuntu server does all the heavy lifting in terms of tracking time and logging temps.

Anyway, the youtube shows the bread board proof of concept. In this state it does not have a temp sensor (its on order), it’s tennativly held together on the breadboard and the code and supporting programs are nowhere near complete.

I have the parts that will be embedded permanently on order. I will update when I make progress.

Posted in Arduino, Arduino Thermostat, Ethernet, LCD

First Post

Is this thing on?

Posted in Uncategorized