Automatic Door Opener Part 2 – Electronics. The Sound Modem

Hey. This page is more than 9 years old! The content here is probably outdated, so bear that in mind. If this post is part of a series, there may be a more recent post that supersedes this one.


I am using an Arduino microcontroller to control DC motor powering the Doggy Door Opener. I might also use the microcontroller to monitor a couple of microswitches and control a solenoid deadlock too.

An old Android phone is the brains – it has the touch screen, WiFi, Bluetooth (for dog proximity sensor), camera and whatever else rolled into one tidy package. It’s an old Samsung running ICS.

Power comes from an old power supply that has 5V for the phone and 12V to drive motor (see later), solenoid and arduino through VCC.

Arduino and phone communicate down a wire using a sound modem.

Sound Modem

The circuit below is a sound modem for the Arduino – web address reference is on the image.

It is designed by some Japanese dude (I think) under the moniker of arms22 who specialises in cool electronics and crap furniture it seems. He also has a weird RepRap i3 which is different from mine…but I cannot work out how.

Arm22’s Prusa i3. Has two more stepper motors than mine- don’t understand what they do.

Anyway, you used to be able to buy a premade Softmodem module from sparkfun, but it is now ‘retired’. Kind of shame, and would have made my job easier; I hate soldering. Echoes of the ‘Softmodem’ do exist online though – echoes loud enough for me to build and run my own and get the Android side running.

You have to do some digging for a workable arduino library – the ones that are readily available are for old versions of the Arduino IDE and/or are Arduino chip specific (ATmega328 only – the library wires straight into this microcontroller chip’s timers to do the FSK). I spent a lot of time trying to make port of code work with a Leonardo , which uses a different base chip (ATmega32u4) and thus different timer addresses. I failed. Miserably – a couple of days work down toilet. I just stumped for an Arduino Uno I had lying around in the end. Defeated.

The modem allows you to encode digital data using frequency shift keying (FSK) modulation into an electrical signal, and vice versa to decode an encoded signal. What is great about the sound modem approach is that the signal is audible and so can be decoded encoded by any device with earphone and microphone functionality and an audio jack (4 pole). So pretty much anything.

A 4-pole 3.5mm jack. Pretty much all mobiles have them.

Data (characters for example) are transmitted in binary form. Binary FSK is used, the simplest, which uses a constant time interval and shifts the frequency of the base carrier signal depending on whether a ‘1’ or ‘0’ is being transmitted.

“Fsk” by No machine-readable author provided. Ktims assumed (based on copyright claims). – No machine-readable source provided. Own work assumed (based on copyright claims).. Licensed under CC BY-SA 3.0 via Commons

I needed to do a bit of code on Arduino side to address error handling with BFSK, based on information here and stuff a dreamt up, but apart from that l had little interaction with the encode/decode algorithms under the bonnet in the arduino and android libraries.

FM (frequency modulation) radio uses a similar modulation principle, except in analogue FM the data is not digital (so not FSK) and the analogue data is transmitted on radio waves. In these analog signal applications, such as FM radio, the difference between the instantaneous and the base frequency of the carrier (be it radio waves or a signal down a wire) is directly proportional to the value of the input’s amplitude.

I initially thought that the process is similar to that classic sound modulation sound from used in Spectrum ZX tapes and dialup’s not quite the same.

“ZXSpectrum48k” by Bill Bertram – Own work. Licensed under CC BY-SA 2.5 via Commons

These use different (more involved) modulation types that allow higher baud rates, less data loss and better error correction. Old school computer cassettes used pulse-width modulation.

The advantage of BFSK, and its appropriateness to my project, is that the technology is so lightweight in terms of hardware and software. Also, the algorithms used to encode and decode run efficiently onto the low power Arduino microcontroller.

My softmodem on a breadboard, based on schematic at start of blog. Raided and old FM radio for most of the resistors and capacitors.

Since I am only transferring simple commands (say ‘o’ for open and ‘c’ for close) from the phone to the microcontroller and vice versa, anything more complex would be superfluous.