Skip to content
〰️ FSK Library for iOS interface with Arduino Development
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
FSK Revert 9888726..0920f69 Oct 15, 2016
LICENSE Fix broken Markdown headings Apr 16, 2017


Build Status Badge w/ Version Badge w/ Platform wercker status

Dependencies for iOS Development, using Sofmodem Arduino library, with FSK communication.



How to use

This libraries have a propouse work with an Arduino using a Sofmodem Shield* to communicate with iOS using FSK. Currently, the source code of the SoftModem is not made as a framework. If you want to use SoftModem in your project, you have two ways:

Adding FSK-Arduino-iOS to your project


CocoaPods is the recommended way to add FSK-Arduino-iOS to your project.

  1. Add a pod entry for FSK-Arduino-iOS to your Podfile pod 'FSK-Arduino-iOS', '~> 0.0.2'
  2. Install the pod(s) by running pod install.

Source files

Alternatively you can directly adding source files to your project.

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. The Folder /FSK must be copied from the source code of your project. The following is the list of source code related to FSK. 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];   
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(interruption:) name:
AVAudioSessionInterruptionNotification object:nil];

[session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
[session setCategory:AVAudioSessionCategoryPlayback error:nil];
[session setActive:YES error:nil];

interruption selector method

- (void) interruption:(NSNotification*)notification
    NSDictionary *interuptionDict = notification.userInfo;
    NSUInteger interuptionType = (NSUInteger)[interuptionDict valueForKey:AVAudioSessionInterruptionTypeKey];
    if (interuptionType == AVAudioSessionInterruptionTypeBegan)
        [self beginInterruption];
# if __CC_PLATFORM_IOS >= 40000
    else if (interuptionType == AVAudioSessionInterruptionTypeEnded)
        [self endInterruptionWithFlags:(NSUInteger)[interuptionDict valueForKey:AVAudioSessionInterruptionOptionKey]];
# else
    else if (interuptionType == AVAudioSessionInterruptionTypeEnded)
        [self endInterruption];
# endif

Next, for analysis of the voice, make instance of class AudioSignalAnalyzer, FSKRecognizer and 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];     
        [recognizer addReceiver:self];
        analyzer = [[AudioSignalAnalyzer alloc] init]; 
        [analyzer addRecognizer:recognizer];

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];


Register the class that implements the CharReceiver protocol to the FSKRecognizer class, and AVAudioSessionDelegate.

@interface YourClass : NSObject <AVAudioSessionDelegate, CharReceiver>

Register FSKRecognizer class at initialization.

YourClass *yourClassInstance;
[recognizer addReceiver: yourClassInstance];

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];

Links and Credits

arms22 - Creator of Softmodem hardware, libraries for Arduino and ARC version lib for iOS.

Arduino Libraries

iOS 4/5 ARC version

FSK Wikipedia

FSK Explanation


This code is distributed under the terms and conditions of the MIT license.

You can’t perform that action at this time.