Thursday, June 3, 2010

Arduinomation Server version 2.2 release

It's been a while since I posted but I've finally made some changes big enough to warrant a post.

I'm releasing my newest version of Arduinomation Server, version 2.2. There is no code change to the Arduino sketch.

Changes I've made:

  • Bug fix: Solar Heat "On"/"Off" text wasn't accurate probably due to averaging
  • Move the drawing location for the water probes on the exterior view so they're bigger
  • Add a date/time stamp to house/exterior views
  • Created an averaged value to show all indoor room temperatures as a single line on the graph
  • Change things so that our maximum value that sizes the graph is updated to go up and now down
  • Change drawing method from points to lines for house/exterior views (spark lines)
  • Change frame rate from 3fps to 1fps
  • Turn on smooth() for spark lines
  • Add vertical lines at the current time on each spark graph
  • Add hour indicators along the top of the graph view
  • Change fonts and change to createFont from loadFont

I changed the font stuff since I was and still am having drawing issues to the buffered images (but not the direct to screen drawing). I'm beginning to suspect that this is a Processing bug. It manifests itself most noticeably on horizontal lines on numbers like 5 and 7, where the top of the numbers gets cut off. I thought it might have to do with anti-aliasing but I've turned off smooth() and moved smooth() below the text drawing code - both didn't fix the problem. Anyone have any ideas?

Download the code here: ArduinomationServerV2_2.zip

Please feel free to leave a comment or question.

Wednesday, May 5, 2010

Finally: Code!

After several hours of updating my code with comments and/or getting things more sensible in my code I've finally got some code for the Interwebs to gobble up. My code isn't the best in the world, and it's still very much a work in progress, but I wanted to give back to the community that helped me so much. Although I just realized that I didn't put any licensing information in my code I'll just say here that I'm providing it free to the community - as in open source (unless I've mistakenly and unwittingly borrowed someone else's code that has a restriction, in which case let me know and I'll do my best to fix it immediately!). It'd be nice if you would let me know if you've used it and how. It'd also be nice if you gave me attribution if you distribute anything based on my code.

My Processing code is what I spent the most time on and what came mostly from my head, rather than copy/paste from other sources. The Arduino code is more stale than my Processing code too since it "just works".

Both sketches are quite customized to my specific situation, with lots of hard-coded values for my temperature probes, names, etc. But I think it should be fairly easy to identify those customized parts and change them to suit your needs. The images of my house that Processing draws to are obviously also very specific to my needs but you should be able to create your own in any way you see fit.

And in case it matters I'm doing all of this development on a Mac, so some things may differ if you're on Windows or Linux. I know that I have a Serial port "auto selector" bit of code that will definitely not work in Windows without a tweak or two. I also save my images to my web server path that's surely different that yours will be. Other than that I'm not sure what differences there may be, so watch out and feel free to let me know what I could do to make this more cross platform.

So here's my code:

I think I failed to mention in my code that my Processing sketch originally was a client/server configuration. The server side took in the Serial data from the Arduino, wrote it to logs and sent it out to the client sketch than graphed it. I've since altered things so that the server sketch does the logging AND the graphing. But I still have code in there for the client that isn't being used right now since the client hasn't been rewritten to understand this new code properly. The server makes smaller iPhone size graphs and the client did a 3x bigger graph where every pixel represented a minute (width=time). I may or may not continue along this path. Right now I've found that my lower resolution graphs are just fine. I setup a Dashboard widget to show each graph image I create then host on my web server - so a key press pops open the dashboard where I can see everything at a glance. And the iPhone web app works great when I'm away from my computer. (But my iPhone doesn't have cell service now, so I just use it over WiFi. But my web server is public so the web app should theoretically work anywhere.) I'll post my web app too when it's less ugly.

So download my sketches and please let me know what you like or dislike. I hope it helps someone out there!

Sunday, April 18, 2010

My circuit board pics

Here are some pics of my circuit as it currently stands.


This is the overall circuit with the Arduino Diecimila on the left (underneath) with the NKC Electronics Terminal Block Shield attached and my Radio Shack PC board on the right. The boards are "attached" to some white foam-core board with some bits of yellow HandiTak (a non-permanent putty that just barely holds these things together).

A large view of just my PC board.

The terminal blocks along the top of the PC board are for the Dallas Semiconductor DS18B20 temperature probe hookups (using the 1-wire/one-wire protocol). I have two buses for the DS18B20s because I was having trouble keeping them reliable with just one. I'm using parasite power and could have probably overcome that issue by directly powering them but I wanted to keep the wire count down since I was piggy-backing on my home network wiring.

The terminal block on the bottom of the PC board is the output from the relay that basically tricks my existing solar pool water heater controller (a HelioMatic - Model HM4000C) to turning on or off by switching one of the two resistors inline. So the HelioMatic thinks it just got really hot or really cold depending on which resistor has been switched inline. There's a fixed 10k resistor inside the HelioMatic to compare against. Normally these terminals would be hooked up to the thermistor embedded in an aluminum block and glued to the roof where the solar heat tubes are, and the other would be on the intake water thermistor which is inline with the pump.

To mock my soldering job you can see the back side of my board:


And here's my Photoshop created schematic view. It's not perfect and I'm not sure if I have the symbols correct (especially the diode directions). Click the photo for a larger version.


I hope this is clear and correct. Feel free to ask questions or correct me.

Wednesday, April 7, 2010

Welcome to my Arduinomation blog!

I started this blog to document my journey with the Arduino and my desire to automate my home, and to give back to the community that has helped me so much in my efforts to do so.

I've already been working on this project for several months so much of this will be catching up to reality but I'll start by summarizing where I am now. I mostly started this project to help me learn Arduino programming and to make something useful. I learned about the Dallas Semiconductor DS18B20 temperature sensor on Sparkfun, bought two and got hooked. I later found a source on eBay that cut the price down to just over $2 each (rather than $4.50 each + shipping from most places on the internet). So I bought 13 of them and have been installing them around my house. In addition to the DS18B20 sensors I currently have 3 thermistors outside that relate to my swimming pool and its solar heater, plus a relay to turn that solar heater on and off. All of this is connected to my Arduino Diecimila with a small prototyping board in between with simple electronics on it. The Arduino is powered and talks to my old Mac server via USB. I wrote a sketch in Processing that listens to the incoming data from the Arduino, formats it, uploads it to Pachube, saves local log files, graphs the data, and saves the graph image to my server. Older versions of my software also served the data to a client program I wrote in Processing that graphed data too, which I'll be recreating again soon.

My initial versions of the software for Processing and the Arduino were starting to become too difficult to maintain and improve upon lately so I've started version 2.0 this last week. I'm hoping to improve code readability (lots more commenting), improve my coding practices which are still fairly beginner level, and improve functionality and expandability.

Hardware-wise I'm also planning on expanding. Even though I call this automation it's really only automating one thing at the moment - whether or not to turn on the solar heater for the pool. In a rough order I'm hoping to first add more sensors:
  • A shaded DS18B20 temperature sensor outdoors
  • A thermistor a couple feet under the surface of the pool in the water (so I can get an accurate temperature reading without the pool pump needing to be on)
  • A couple more DS18B20 sensors indoors in rooms I don't currently have sensors in
  • Something to track wind speed and direction
  • A rain detector and/or gauge
Further beyond that I also hope to actually automate things.
  • Turning the pool pump on and off
  • HVAC
  • Sprinklers
Lastly, I hope to be able to get wiring run to my meters outside - at least power and hopefully gas, so I can monitor my usage in real time. I know my power meter has an infrared LED that blinks once per (unknown kilowatts), and my gas meter is a PG&E "Smart Meter" that phones home but I don't know if I can intercept it.

So there's my not-so-brief opener. Hopefully this blog will eventually help others interested in this type of stuff. Photos and code to come soon.