Version 38 (modified by Ken Suzuki, 13 years ago) ( diff )


Audio Jack modem for Iphone and Android


With this board, data communication between Arduino and iPhone become possible . The communication speed is 1225bps (※ The actual data transfer rate slightly lower.) It is suitable for a small amount of data communication like switch inputs and sensor information.

This is a semi-finished product.

In most cases, you want to solder the audio jack on the board. The audio jack is included in this kit but not pre-soldered. Also, you may need a pin header or a pin socket to this board. But neither pin header nor pin socket is included, so you have to prepare it by yourself.

Dimensions: 33 x 18mm ( without audio jack )


Android with this board

Softmodem Terminal application for Android

Android to control the camera shutter in a SLR

Make voice audio with JavaScript and play it as a way of data communication

iPhone RFID Tag Reader


  • Because data communications with this device uses audio, data corruption may occur sometimes. Please consider incorporating checksum processing and retrying.
  • Please set the iPhone's volume maximum.


Use a 4 pin male to male cable to connect to iPhone. With some cable, cross-talk may occur that causes communication errors. Please use gold plated shielded cables. The shorter the cable, the better.

Connect to Arduino as follows (right side is the Arduino's pin.)

AIN1 → D7

Volume Adjustment

Measure the voltage on AIN1 with tester to make it (VCC / 2) + 300mV.

5V VCC: 2.7V AIN1
3.3V VCC: 1.95V AIN1

Arduino Library: SoftModem

Sample Sketch

# Include <SoftModem.h>
# Include <ctype.h>

SoftModem modem;

void setup ()
 Serial.begin (57600);
 delay (1000);
 modem.begin ();

void loop ()
 while (modem.available ()) {
   int c = ();
   if (isprint (c)) {
     Serial.println ((char) c);
   else {
     Serial.print ("(");
     Serial.print (c, HEX);
     Serial.println (")");      
 if (Serial.available ()) {
   modem.write (0xff);
   while (Serial.available ()) {
     char c = ();
     modem.write (c);


  • Two hardware timers and analog comparator are in the library. Therefore, its not possible to use these features in the application.
  • Tone function is not available.

iPhone Apps:

SoftModemTerminal is a simple terminal application for iPhone. With the sample sketch, Arduino sends and receives alphanumeric. Please note that big sound will come from speakers if nothing is put into the iPhone's audio jack.

Currently, SoftModemTerminal is not distributed in AppStore. Download the source code, please use your own build.

SoftModemTerminal is able to be build with Xcode and iPhone SDK. Xcode is included in the MacOSX installation DVD. Also available for download at Apple's developer pages.

You can download the Apple SDK iPhone developers to register with the developer page. To make it work on iPhone, You must participate iPhone Developer Program which costs 10,800 JPY a year.

iPhone Apps: Onkyo Denbun is now available for download from the AppStore. If you don't have iPhone application development environment, please download the application from this URL.

How to use the iPhone source code

Currently, the source code of the SoftModem is not made as a framework. If you want to use SoftModem in your project, the source code related to the SoftModem must be copied from the source code of the SoftModemTerminal. The following is the list of source code related to SoftModem. Please copy these to the project source code.

  • AudioQueueObject.h
  • AudioQueueObject.m
  • AudioSignalAnalyzer.h
  • AudioSignalAnalyzer.m
  • AudioSignalGenerator.h
  • AudioSignalGenerator.m
  • CharReceiver.h
  • FSKModemConfig.h
  • FSKByteQueue.h
  • FSKRecognizer.h
  • FSKSerialGenerator.h
  • FSKSerialGenerator.m
  • lockfree.h
  • MultiDelegate.h
  • MultiDelegate.m
  • PatternRecognizer.h

SoftModem uses the following two framework for audio input and output. Please add them to your project.

  • AudioToolbox.framework
  • AVFoundation.framework


First, set the category of application with AVAudioSession class. To do voice recording and playback, AVAudioSessionCategoryPlayAndRecord need to be set.

AVAudioSession * session = [AVAudioSession sharedInstance];
session.delegate = self;
[Session setCategory: AVAudioSessionCategoryPlayAndRecord error: nil];
[Session setActive: YES error: nil];

Next, for analysis of the voice, make instance of class AudioSignalAnalyzer and FSKRecognizer. AudioSignalAnalyzer parses the input waveform from the microphone to detect the falling and rising edge of the waveform. FSKRecognizer restores the data bits based on the results of the analysis of AudioSignalAnalyzer.

recognizer = [[FSKRecognizer alloc] init];
analyzer = [[AudioSignalAnalyzer alloc] init];
[Analyzer addRecognizer: recognizer]; // set recognizer to analyzer
[analyzer record]; // start analyzing

Then create an instance of a class FSKSerialGenerator for sound output. FSKSerialGenerator converts the data bits to audio signal and output.

generator = [[FSKSerialGenerator alloc] init];
[Generator play]; // audio output starts


Register the class that implements the CharReceiver protocol to the FSKRecognizer class.

@ Interface MainViewController: UIViewController <CharReceiver>

Register FSKRecognizer class at initialization.

MainViewController * mainViewController;
[Recognizer addReceiver: mainViewController];

receivedChar: method is called when one byte of data is received.

- (Void) receivedChar: (char) input
     // Receive handling


Sending data is much easier than receiving data. FSKSerialGenerator class's writeByte: method to sends a single byte.

[Generator writeByte: 0xff];


More Infomations

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.