I just migrated from Processing to OF and I think it is great how easy you guys are making it for the rest of us. Thanks.
I am wondering if there is any way to establish communication (one way would be ok) to a micro controller (like the arduino).
I don’t care if it is via the iPhone’s serial port, Bluetooth or Wifi (maybe using OSC).
Any help would be greatly appreciated.
sorry that this is a pretty vague answer, but you could communicate through osc if you could get your arduino onto a wifi network, which sound complicated. also, you could communicate through osc to a computer and then serial that to an arduino… this is pretty inconvenient though depending on your setup.
also, i remember reading something about someone who had set up a code library to communicate via the headphone jack.
I guess you could just take apart part of an audio cable and plug one end into your iphone and the other end into an analog port on your arduino, generate some sounds with ofxALSoundPlayer, and see what the readings are. obviously having direct access to the sound buffer would be much better, and hopefully that’ll come soon in ofxiphone, but you might be able to communicate basic things without that
Thanks for the reply.
Does the OSC addon that comes with OpenFrameWorks also work for the iPhone?
I know the arduino can be equipped with a wifi connection and can receive OSC communication.
What I don’t know is how to make my iPhone app to talk OSC via wifi.
It works with a few minor changes. I hae a version with these made, but I’m not at home now. I’ll try and post it later.
i cant remember which version of ofxosc this is based on, although likely it’s slightly out of date, but should preform fine
Hey Thanks I got it to work.
I am posting the links to the small project i build. It runs on the iPod touch, send my mouse location via OSC to my laptop.
I am also posting a little processing app that I am using as the receiver.
There are probably people out there, just like me that really need very simple examples to get the ball rolling.
All that needs to be changes is 1. add your personal Identifier, 2. give it the right Code Signing Identity.
All described here:
Next step for me is get a wifi shield for my arduino and patch it all together.
Thanks again for you great help.
does anyone know if the serial library for OF also work for the iPhone?
i know i will have to jail break the iPhone.
i am still on the pursuit to connect an iphone to an arduino.
Have you seen the WiSheild http://www.asynclabs.com/ ? They have an example vid where they control an Arduino with an iPhone via the web browser.
i already bought a wishield and got a similar example running.
the wishield can even create an adhoc network, so there is no need to setup a wireless router.
they have example sketches for UDP and Sockets but I am not sure how to use the ofxNetwork library for the iPhone.
Also, I already got the OSC working between iPhone and Computer and would really like to the arduino to do OSC.
Someone already wrote a OSC library for the ethernetShield but not for the wiShield.
i am hoping some of the awesomely smart openframeworks people can port the serialExample and the ofxNetwork library so to work with the iPhone.
Wouldn’t Arduino BT allow for direct communication with the iPod Touch?
I believe I will need to have a self-contained iPod reading a couple of sensors and was wondering if attaching an Arduino BT to it would do the trick. I believe it would be easier than having the extra WiShield.
So, I need Arduino to send sensor data directly to iPod. No computer involved.
Can anyone suggest the best approach?
I am not sure if OF has code to get data via bluetooth. would be interesting to know.
I am currently using the WiShield via the UDP sketch. And it works pretty good, not very fast and sometimes does not catch all the data.
I also read that you can use a bluetooth keyboard to write text on the iphone. maybe there is possibility for a hack.
Also things to consider are range of the wireless signal, and speed of the data transfer.
keep us posted,
I also read that I could try to connect the Arduino to the iPhone directly via the serial cable but this is way beyond my humble knowledge on Arduno. I would have to hire someone to research and implement this for me.
just to follow up on the iphone to arduino path using serial:
I have successfully been able to communicate using the iphone´s serial port from an iphone terminal program (minicom), and I am now trying to figure out if I am able to access the serialport also from openframeworks.
The oFserial for the iphone 0.6 version is not really configured for the iphone though, as there are no test cases for iphone, only osx, linux and windows. I just added target_iphone to the osx and linux parts. I was able to compile but so far no luck in connecting to the serial port.
It would be great if anyone has any info on specific iphone settings for the serial port. The name of the serialport when accessed from minicom is /dev/tty.iap.
that sounds very interesting. please keep us posted on your progress.
i found a link to serial over audio. but i have not seen any schematics.
I didn´t really understand what they were doing in the iphone hacks series, I couldn´t find any reference to the serialport in the code? Are they modulating the audio signal to do the serial communication, or did I look in the wrong place in the code?
Anyway, it is supersimple to do the physical connection to the iphone if you have a breakout connector. You only need tx-rx,rx-tx,gnd-gnd and that´s it. If you are using the arduino on 5v you would need a 1k resistor between the tx of the arduino and the rx of the iphone.
The minicom setup is not difficult, and is fairly well explained here:
Somebody wrote code for the iphone serialport back in 2007 but I have no idea if that would still work. If anybody wants to have a go at it the code is available at the bottom of this page:
Ideally I would like to include this code in my iphone app, but I am still very new to openframeworks so that´s not so easy for me to figure out yet.
This is as far as I get:
after doing some small modifications to oFserial.cpp I am able to see the serial ports:
device 0 - tty.iap
device 1 - tty.umts
device 2 - tty.bluetooth
device 3 - tty.debug
but if I try to open the serial port using open("/dev/tty.iap", O_RDWR | O_NOCTTY | O_NONBLOCK);
I have no luck with that.
Slightly annoying since it works from the terminal, but I guess I am missing something essential.
Does anybody know where I can find the documentation for the open command? Maybe there are some other parameters I need to set?
Hmm it could be that your app is running with different permissions than the terminal.
This would make sense as the apps are meant to be running in a jailed environment of sorts.
Even if you do have a jailbroken iphone there is probably some things you need to do to have your app run with the mobile or root user permissions.
PS - a company is working on a serial adapter for the iPhone - could lead to a non-jailbroken solution. http://www.engadget.com/2010/02/12/redp-…-pod-touch/
I have been playing with different permissions the last few days, as the app needs to be run as root (something I found out through the xGPS developers). No matter what I tried, it didn´t make a difference.
But last night I had a breakthrough:
I moved the app to the same place as where the apps are installed by Cydia, and it worked straight away!
I will post more info later.
I have made a relatively thorough write-up of my adventures leading to being able to create a functional application for serial communication. You can read it here:
would it be possible to see you modified version of the serial example.
i am currently trying to follow you instructions on the above posted link but i get error messages like these:
ofSerial does not name a type
ok i noticed i forgot to add the following line to testApp.h
But now i get new errors, like:
"ofSerial::readBytes(unsigned char*, int)", referenced from:
testApp::update() in testApp.o
"ofSerial::writeByte(unsigned char)", referenced from:
testApp::update() in testApp.o
"ofSerial::ofSerial()", referenced from:
"ofSerial::~ofSerial()", referenced from:
"ofSerial::enumerateDevices()", referenced from:
testApp::setup() in testApp.o
"ofSerial::setup(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int)", referenced from:
testApp::setup() in testApp.o
ld: symbol(s) not found