Posted on 14-05-2009
Filed Under (Arduino, Asterisk) by Dan

I’m currently working on a project that works with pachube to post information to the web. It’s really handy to be able to get the sensor information from my Arduino to the web with an ethernet shield and a few lines of code. However, I want to take this functionality a step further and make the pachube feed available from my Asterisk phone system in the rare event that I’m away from civilization and don’t have access to an internet connection. The script I came up with is geared towards my ArduinOil project, but could easily be converted and used in any way with any information. The way it works is this: user calls extension (or could be made available from an AVR), the AGI script requests pachube feed information, flight or cepstral is used to read information to user. Here’s what you’ll need to do to get it up and running:

  1. Download the pachube PHP library, and pachube AGI script.
  2. Unzip the pachube_functions.php file from the PHP library zip and copy it and the AGI script into /var/lib/asterisk/agi-bin/
  3. Unzip pachube.php from the AGI script zip and copy it into /var/lib/asterisk/agi-bin/
  4. chmod +x and chown asterisk:asterisk both files
  5. Make changes to configurable options in pachube.php (ie. api key, feed id, etc.)
  6. Add the following dial plan code to your extensions.conf or extensions_custom.conf (FreePBX)
  7. exten => 750,1,Answer
    exten => 750,n,Wait(2)
    exten => 750,n,AGI(pachube.php)
    exten => 750,n,Hangup

  8. Reload your asterisk dial plan: asterisk -rx dialplan reload

There is more feed information available from the pachube PHP library such as latitude and longitude of the project, multiple datastreams, etc. But this should be enough to get you on your way. Enjoy!

(0) Comments   
Posted on 13-03-2009
Filed Under (Arduino, Asterisk) by Dan

Being an avid Asterisk admin and a novice AGI coder, I decided that it would be cool to try my hand at using Asterisk to control my Arduino over ethernet. Upon googling similar projects I came across Kate Hartman’s page on doing just that with an Arduino connected via an XPort module. Well, I have the Adafruit ethernet shield with a WIZnet module, but I decided to give it a try anyway. The first thing I noticed was the Arduino code appeared to be communicating with the XPort module via serial communication. This is a bit of a problem as the WIZnet module needs to make use of the ethernet library in Arduino IDE. So I threw together a little test environment with an LED connected to pin 4 and plugged in my ethernet shield to give the code a shot. Needless to say, it didn’t work straight out of the box…so I’ve made a few minor modifications which you can find attached to this post. I also found that Kate’s Asterisk AGI code was a bit dusty, being written perhaps for an older version of Asterisk than what I have (, so I made a few modifications and was able to get it up and running. This should come in REALLY handy for some of the projects I’ve got waiting in the wings (ArduinOIL). Here’s how to get it up and running.

  1. Download source code
  2. Upload the attached sketch to your Arduino
  3. Copy the arduino_control.php file into your agi-bin (usually /var/lib/asterisk/agi-bin) and edit the configurable options to match your setup. Make sure you change the permissions on the file with “chown asterisk:asterisk arduino_control.php” and also make it executable with “chmod +x arduino_control.php”
  4. Edit your dial plan (I use freePBX so the file is /etc/asterisk/extensions_custom.conf, otherwise it would be /etc/asterisk/extensions.conf) to include the following lines (you can change the 999 to whatever extension you prefer to dial to get control of your arduino):
  5. ; Arduino Control
    exten => 999,1,Answer
    exten => 999,2,AGI(arduino_control.php)
    exten => 999,3,Hangup

  6. Restart asterisk services with “amportal restart”
  7. Hack the code apart and make it do something awesome!

(6) Comments   
Posted on 06-03-2009
Filed Under (Arduino) by Dan

A month ago, my younger brother-in-law asked me to help him with a science project that would get him some serious extra credit (over achievers!). The assignment was to create a working seismometer. Sounds like a job for the almighty Arduino, doesn’t it?! We asked the teacher and she answered with an enthusiastic “YES!” I thought it would be a good opportunity to introduce him into the world of electronics and maybe even peak his interest…so I ordered the parts and last night, we started to build.

We finally had the breadboard / sketch code worked out, and started the physical mount/build process last night. Below is what we came up with…we call it “Seismoduino”. At present, there are 2 “modes”, meter mode and graph mode. In meter mode it takes the readings from the ADXL322 accelorometer and feeds them to our little array of LEDs which display the readings as a meter. In graph mode, the information is sent to the COM port and graphed by some Processing 1.0 code. We’re still working out the kinks and features, but should be finished soon. Once we’re ready there will be some more (better) pictures and even some video…

(0) Comments   
Posted on 03-03-2009
Filed Under (Arduino) by Dan

As with most projects, my most recent project was born out of an inconvenience, an an empty wallet, and an idea.

The inconvenience: walking outside in sub-zero temperatures to check my fuel oil gauge. I know it’s lame and I’m lazy, but there’s something annoying about not having the information at my finger tips (ie. the internet) no matter where I am.

The empty wallet: checking….yep…still empty.

The idea: to be able to read the information from my current oil gauge and feed it to a web-enabled service so I can not only check the current level, but have stats and trends available from anywhere in the world.

So far I have the general process all figured out. A series of infrared emittors and sensors will span the oil gauge “tube” and scan for the indicator. A server will periodically query my ethernet-enabled arduino to get the reading of all the sensors and return a percentage value. These value will then be stored in a MySQL database and processed accordingly with some PHP code.

At this point I’ve been able to get the sensors all wired up and tested. Everything seems to be working quite well. I received my ethernet shield last week and started playing with that. I’ve got a bit more tinkering to do with that before starting the build of the actual sensor enclosure. I’ll post updates as I progress.

Testing iR sensor configuration on proto board

Testing iR sensor configuration on proto board

(0) Comments   
Posted on 28-02-2009
Filed Under (Arduino, electronics) by Dan

I was thinking about buying a BoArduino for easier prototyping…it’s easy and cheap, but not as cheap as I am apparently. I decided to build my own instead using an old proto board, some pin headers and CAT5 cable I had laying around. It’s not nearly as pretty, but just as functional, and I don’t need to reload my code to the arduino I plan on using in “production” because I actually built it in shield format. I’m working on a prettier version, using that as a pet project for learning Eagle PCB layout. But for now, this works just fine.

(0) Comments   
Posted on 20-02-2009
Filed Under (electronics) by Dan

Since I started in IT, I’ve always been a scavenger of sorts. Ripping out hard drives, memory, fans, coin cell batteries…you name it. But it wasn’t until I started building electronic circuits that my scavenging tendencies really started to run rampant. There are numerous electronic goldmines all around us, that if you’re willing to open your eyes and tap into these resources, you can save yourself a bundle of money, and sometimes even open up new ideas for projects or solutions to existing projects. One my most recent discoveries of one such goldmine can be found in public facilities everywhere: the automatic paper towel dispenser.

While at work, I was walking by a garbage can and noticed one of these dispensers. It almost screamed my name as I walked by, did a double-take, and stood there for a moment to think it over. With a quick look around I made sure no one was around, I snagged it and ran for my office. I hovered over the the dismantled appliance with an evil…OK, not really…but in about 5 minutes I did have myself a nice little collection of trinkets to play with. A short list of components: 5V DC motor with matched gears, 3 or 4 different types of switches, and momentary buttons, a proximity sensor (I haven’t quite figured out how it works yet), a few LEDs, and a board chock full of diodes, resistors, and other miscellaneous components (if you take the time to de-solder).

It is my understanding that these things are very easy to find in the dumpster because they are given out by the paper towel companies whenever a company orders of product are purchased. I guess their thought is, wherever there’s a paper towel dispenser, there’s bound to be paper towels. So the more they give out, the more product is sold. Also, most maintenance people don’t even bother changing the batteries, they just grab a new one from the back closet and throw the old one in the garbage.

OK, so what’s the take-home lesson? Keep your eyes open…one man’s garbage is another man’s robot. You never know what could be salvaged out of an old answering machine, TV, network switch, radio, or even paper towel dispenser. Oh ya, and please don’t go ripping these off the wall the next time you’re in your local 7-11…they’re actually kind of handy when they work.  : )

(0) Comments   
Posted on 28-01-2009
Filed Under (Arduino) by Dan

I received my first Arduino in the mail the other day. Of course I went through all the tutorials and started tinkering right away. But I won’t bore you with those details…God knows there are too many “I plugged in an LED and got the Blink program running” out there already. But I did design a quick little circuit that I thought might be handy as a tutorial for beginners (like myself).

For the physical setup, all you need is an LED with a 220Ω resistor connected to pin 11, and a photocell connected to pin 2 with a 5V pulldown configuration (see pictures). I’ve attached the sketch code to the post…upload the sketch to your Arduino and say goodbye to the boogie monster. Click here to download sketch code.

(0) Comments    Read More