September
01
Posted on 01-09-2010
Filed Under (Arduino, Asterisk, electronics) by Dan

A recent comment by the009 got me thinking…I’ve been able to get Asterisk grab info about sensors connected to an ethernet-enabled Arduino, but how about the other way around? What if you could allow your Arduino to make outbound calls through your Asterisk system to make a make-shift alarm system, or over-powered doorbell? Well, wait no longer! Here’s how it works:

Asterisk: A php script lives on your Asterisk server (hosted up by apache) that, when it’s accessed, checks to make sure the client accessing it matches a pre-defined IP of your Arduino. If so, it creates a call file with the criteria that you configure to call a number of your choice and drops it in the Asterisk outgoing queue directory, triggering Asterisk to make a call. (I would highly suggest you only set this up on a server that doesn’t have port 80 open to the world!)

Arduino: The sketch code is easy…simply trigger a client connection to the Asterisk server when a button is pushed, motion sensor tripped, or ultra sonic range finder measures a particular distance (that part is up to you). As long as the Arduino’s IP matches the allowed IP configured in the php script, your phone should ring!

Make it happen:

  1. To get started, download the code and extract the files.
  2. scp arduino_call.php into your web directory on your asterisk server.
  3. Next, add the lines from extensions_custom.conf (zip package) to /etc/asterisk/extensions_custom.conf
  4. Edit the variables at the top of arduino_call.php to match your configuration.
  5. Upload the sketch to your arduino, customizing to your configuration (of course!).
  6. Adapt it to your project!

Feel free to edit and manipulate this script to fit your needs, I just ask that you add a comment to this page explaining how you used it. Videos / pictures are always welcomed as well!

(4) Comments    Read More   
May
14
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    Read More   
March
13
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 (1.4.21.2), 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!

(5) Comments    Read More