July
27
Posted on 27-07-2009
Filed Under (Arduino) by Dan

I needed some web-based gauges for my ArduinOil project frontend and I wanted them to be driven from PHP if possible. I came across Flash Open Gauges (FOG) written by Charles Nichols, which looked really slick and gave plenty of options as to the style of gauge and the methods that you feed it data. I started playing around with the scripts to customize them for my purposes. As I was learning about the feature of dynamically feeding the gauges data via PHP, I started thinking about how easy it would be to make the gauges live. A little tinkering, and voila! This won’t be particularly helpful in any of the projects I have going on at the moment, but I thought it might help someone else, so here’s how you’d make it work:

  1. You will need and Arduino (duh!), Ethernet Sheild, and some type of analog input device (potentiometer, photoresistor, etc).
  2. Go get the FOG files here.
  3. Download the demo scripts and sketch files I’ve created here.
  4. Extract the FOG into a folder on your server (can be either Windows or Linux, but must have PHP installed).
  5. Extract the demo scripts into the same folder as the FOG code on your web server and change the configurable variables in arduino_fetch_data.php to reflect the IP of your Arduino.
  6. Change the sketch code to reflect the IP you’d like your Arduino to have, upload the sketch and connect something to analog pin 5.
  7. Open the index.html in a browser by navigating to your server’s address.
  8. Read the FOG documentation and hack the scripts to do what you want!

I recorded a quick demo this morning of the script in action which you can find below. Also, keep in mind that I just threw this together on a side trail to a larger project that I’m currently working on, so there may be some refining that should be done to the code. I just don’t want to spend the time on it now, but if you need this functionality, it might be worth your while to poke at the code and try to improve it. Have fun!

(18) Comments    Read More   
July
22
Posted on 22-07-2009
Filed Under (Arduino) by Dan

It has been a few months, and I’ve had a few other projects come and go in the meantime. However, I’ve always had this project in the back of my mind. Not too long ago, I had a much better design idea for detecting the amount of oil in the tank. At first, I was trying to read the meter that is already on the tank, but the results were less than perfect and the hardware was going to be a major PIA to mount and maintain. One day I caught a video of a guy that made an automatic water dispenser for his cat or something crazy like that. But the thing I noticed was he was using a Parallax PING sensor to detect the amount of water in the bowl…enter proverbial light bulb. So I ordered one (a PING sensor) and started playing around with it. The results were amazing…not only is it amazingly simple on the hardware end, but the responses were more accurate and the code implementation was simple too.

Now that we have the data, we have to find some place to store it. I signed up for a BETA account at www.pachube.com and had a lot of fun programming the Arduino to speak pachube. I even got fancy with some Asterisk code to report pachube information via the telephone. But at the end of the day, there was still something missing…history. I really wanted to be able to look back on my fuel usage and get some trending information for curiosity’s sake…and I could not get such functionality from Pachube. So I did what any self-respecting nerd would do…I wrote my own. Here is the way it works:

The Arduino is listening on port 23 (telnet) for traffic. A cron job runs a script on the hour from a server that connects to the Arduino and sends a “p” (for percentage…”i” would return inches), which prompts the Arduino to pulse the PING sensor 5 times, average and convert the value to a percent based on the total tank size. The Arduino returns this information to the script which records the value and a time/date stamp to a database. From here I have a script that checks the database once a day and alerts via email if the level gets too low…however, I can do any number of things with that information. I have yet to write a “front end” to the database to make the information viewable over HTTP, but that is definitely in the works as well.

My next order of business will be mounting the ArduinOil components in the tank / furnace room, and doing the final hardware prep. I’d post some pictures, but honestly, at this point it’s just a bunch of code and tanggled wires. Hang in there…more to come!

(3) Comments    Read More