How to connect the Iphone/Ipod touch to an Arduino

How to connect the Iphone/Ipod touch to an Arduino.

You can even communicate/read/control your Arduino anywhere in the world!

Equipment/devices required:

  1. PC with Windows XP SP2/3 (always on) with high speed internet connection.
  2. WiFi wireless router
  3. Azeotech DaqFactory Starter Version (16 channel) ($45)
  4. Iphone Ipod Touch
  5. PC2Me Iphone/Ipod Touch application from the iTunes store ($10)
    This application runs, as a proxy server, on the “always on” PC
    and as a local application on the iphone/ipod touch.

I tried to keep the software as simple as possible.
With Azeotech DaqFactory you can build a simple command/response
serial driver which communicates with the Arduino.
Since there is a limit of 16 I/O channels, with this low cost version,
then I constructed 16 analog channels to be transferred along with
16 digital channels encoded into one analog I/O channel. (Using setBit/clearBit on a word)
See Arduino example code reference below.

The AZeotech DaqFactory is a full blown serial data acquisition package with trending,graphing, symbols, sequence automation and is one of the best communications packages
on the market. You can also send email alerts from this package using the Arduino.
Recently they reduced the cost from hundreds of dollars to $45 for a 16 channel “starter package”

My DaqFactory use includes trending, data acquisition, home automation, security and enviromental control
using the Arduino. Attached to my Arduino is uMega’s FPU V 3.1 (Floating point processor) which
off loads any floating point calculations needed by my application to speed up and save resources on the Arduino.

The DaqFactory serial driver documentation is excellent and it took hardly any time to create “from scratch” a poll/response code for the Arduino. Only one line of code was needed for each channel in the “protocol setup”
<return(StrToDouble(Poll(“0”,13,10)))>
The code instructs the DaqFactory serial driver to poll the Arduino with an ASCII “0” Dec 48 and
wait for the data with a CR dec 13 LF dec 10.

To view DaqFactory or any other application on your PC, a new “Remote Desktop Access” software application
appeared in the itunes application store from Apple. With this application you can remote your PC to your Ipod Touch via Wifi
and or iphone via 3G or Wifi $10. You can control your PC with the iphone/ipod Touch just as you do with your keyboard and mouse,
but with Apples unique touch sequences.The setup was fairly simple and you need to go to their website and read the instructions,

There you have it … You can communicate/read/control your Arduino anywhere in the world!

Arduino Example Code:
My abbreviated example code

//The Azeotech serial driver polls the Arduino with one ASCII byte (no CR LF)
//The Arduino via case statement reads the byte and response with the data and a CR LF
//using the Serial.println(“21234567”) command/function .

int incomingByte1 = 0;

void setup()
{
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps 8 N 1
Serial.flush(); // flushes 128 byte receive buffer
}

void loop()
{
//code start
// Serial communication channels (9600,8,N,1)
// Poll time from Daqfactory is 5 secs.
// Analog channels for serial tranmit - 16 Max for Azeotech DaqFactory
//1 ch0 - analog channel encoded with digital bits 16 Bits (1 Word) of digital Multi Sensor status
//MS_Status_Bit_0 0 // Trip1 Status / IR1 / Int0
//MS_Status_Bit_1 1 // Trip2 Status / IR2 / Int1
//MS_Status_Bit_2 2 // Alert Relay output status (0 = Off 1 = On)
//MS_Status_Bit_3 3 // PIR Motion Sensor detection (1 = PIR detection)
//MS_Status_Bit_4 4 // Piezo/Buzzer output status (0 = Off 1 = ON)
//MS_Status_Bit_5 5 // Light Sensor (light = 0 dark = 1)
//MS_Status_Bit_6 6 // Sound Sensor (1 = triggered from alert setpoint)
//MS_Status_Bit_7 7 // Sonar Sensor (1 = triggered from alert setpoint)
//MS_Status_Bit_8 8 // FPU Failure Status
//MS_Status_Bit_9 9 // Sunrise/Sunset (0 = sunrise 1 = sunset)
//MS_Status_Bit_10 10 // Spare 1
//MS_Status_Bit_11 11 // Spare 2
//MS_Status_Bit_12 12 // Spare 3
//MS_Status_Bit_13 13 // Spare 4
//MS_Status_Bit_14 14 // Watchdog
//MS_Status_Bit_15 15 <----------Do not use!
//2 ch1 - Temperature F - Sensirion SHT71
//3 ch2 - Humidity % RH - (temperature compensated) Sensirion SHT71 (±3%)
//4 ch3 - Dewpoint F - Sensirion SHT71
//5 ch4 - Ambient Light LDR - Cadmium Sulfide 10K
//6 ch5 - Ambient Light TEMT6000
//7 ch6 - Sonar Distance EZ0 distance in inches
//8 ch7 - PIR Motion Counter
//9 ch8 - Sonar Counter
//10 ch9 - Sound Counter
//11 ch: - Spare
//12 ch; - Sunrise time - FPU calculation
//13 ch< - Sunset time - FPU calculation
//14 ch= - RTC date/time - Unix time - converted from DS1307 I2C RTC by FPU
//15 ch> - Spare
//16 ch? - Spare

// send channel data on poll command(s):

if (Serial.available() > 0) {
// read the incoming bytes:

incomingByte1 = Serial.read(); // 0-9,:,;,<,=,>,?
switch (incomingByte1) {
case 48: // Ch0
//do something when var == “0” Status
Serial.println(MS_Status); // CR LF <--------Make sure you return a CR LF
if (WD == 1) //WD variable channel
{
WD = 0;
}
else
{
WD = 1;
}
break;
// break is optional
case 49: // ch1 - Trip1 <------Temperature F - Sensirion SHT71
//do something when var == “1”
Serial.println(“11234567”); // CR LF
if (WD == 1) //WD variable channel
{
WD = 0;
}
else
{
WD = 1;
}
break;
// break is optional
case 50: // ch2 - Trip2 <------Humidity % RH - Sensirion SHT71
//do something when var == “2”
Serial.println(“21234567”); // CR LF
if (WD == 1) //WD variable channel
{
WD = 0;
}
else
{
WD = 1;
}
break;
case 51: // ch3 - <------ Dewpoint F - Sensirion SHT71
//do something when var == “3”
Serial.println(“31234567”); // CR LF
if (WD == 1) //WD variable channel
{
WD = 0;
}
else
{
WD = 1;
}
break;
case 52: // ch4 <-------Ambient Light LDR
//do something when var == “4”
Serial.println(“41234567”); // CR LF
if (WD == 1) //WD variable channel
{
WD = 0;
}
else
{
WD = 1;
}
break;
case 53: // ch5 <------Ambient Light TEMT6000
//do something when var == “5”
Serial.println(“51234567”); // CR LF
if (WD == 1) //WD variable channel
{
WD = 0;
}
else
{
WD = 1;
}
break;
//default:
// if nothing else matches, do the default
// default is optional
} // end of case

}// end of if (Serial.available)

// user code

// user code

} // end of main loop
:sunglasses: :sunglasses: :sunglasses:

why not just an ethernet shield?

Is there a software application that can be linked directly from the ethernet shield from the iPhone/ipod Touch and have it work as a local application? Also, the Azeotech's DaqFactory gives me the flexibility to trend, monitor and control the Arduino from the PC. 8-) 8-) 8-)

This guy has demo in youtube... http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235716581/0

I am tracking his development - wondering if he will produce/sell the wifi shield anytime soon.

@ArduinoAndy I think most people use the OSC, Open Sound Control for use with iphone and arduino. there are sample osc apps in the app store.

Which is easier ... writing an OSC specific application or just moving your PC's complete desktop to the iphone ipod/touch for remote control of the Arduino? 8-) 8-) 8-)

hehe, if it was all about being easy, i would stop to build useless application just to seem them work.

besides that i use a mac and can't run your software, and i don't want to spend 55 dollar if it can be done with fos sofware that runs on all platforms.

i don't say your solution is bad, thanks for showing. just that i can't use it, even if i wanted to.

Don't get me wrong. I would like to have a "cheaper solution" but since I already have all the devices eg PC/w DSL,router with Wifi and iphone/ipod touch then the added expense of $55 is trivial. If I had a choice, a bit-banged solution using an ethernet shield could work but time is not on my side. 8-) 8-) 8-)