HiJack In the Box – Part 1 – iPhone HiJack Tutorial
August 21, 2011
Another weekend tutorial!
This time, I would be demonstrating HiJack, a device that can integrate sensors to your iOS gadget using only the headphone jack. Isn’t it amazing? For more details about the project, you can visit the HiJack project site and also Seeedstudio on where I got this amazing product from.
The HiJack is a nice platform to build external sensors that can provide analog input iOS device. You can do lots of analog-ish devices like temperature sensors, moisture sensors, humidity sensor, etc.. So why this? I can opt to do sensors through iPhone SoftModem (waay cheaper) but it would need an external controller board (like Arduino) and an external power source.
Lets get it on!

The prerequisites for this demo are:
- Follow Seeedstudio’s procedure on loading the firmware of the HiJack mainboard (you have to make sure, mine was not loaded).
- Download the HiJack application from iTunes, it is free don’t worry.
- Get any rotary potentiometer, I know you have somewhere stashed on your bin. It does not matter what value, I used a 5kOhm one.
- Get some jumper wires. I used 1 pin female wires for easier setup.
- You can use a breadboard if needed
For this demo, we would be using a rotary potentiometer, which will emulate an analog input device for us. We can wire up the pot as below:

Following Seeedstudio’s schematic diagram for the HiJack mainboard, we will connect the potentiometer to the GND, VCC and A6 pins on the HiJack device. For the uninitiated, we can say that the middle pin on the potentiometer connects to the A6 pin and the two other pins can connect to either GND and VCC.

This is from Seeedstudio
After wiring it up, you may now start the HiJack app on the iOS device and play around with it:

And that’s the end of the tutorial right?
Hmm so what better way to play around with it than testing it with an oscilloscope!
My bear likes to see the squiggly lines of the oscilloscope:

It may be a bit of a paradigm because it would be an oscilloscope testing an oscilloscope:

I connected the probes to the A6 and GND pins and started the signal generator to put out 10hz (it is the lowest possible frequency that the Seeedstudio DSO Nano 2 can produce):

True to the test, the HiJack app can detect the 10hz frequency. But let us try out the other pins
From the output jack, we can see the 22khz frequency which is used to power the device:

Below is the mic pin:

Each L and R pins output a different signal:

But I won’t care for now as I don’t know anything about what protocols the HiJack device uses to communicate with the iOS.
For the next part, we will try to create our own iPhone app to interface with the HiJack! Great!
;
the bear is so cute.
Nice post, I just got my pack. I followed your setup and I got it to work with the HiJack App. However, it is very sporadic. It was working, now it doesn’t do anything. Turning the potentiometer does nothing. I can’t figure it out. Did you by any chance encounter the same problems.
I think the delegate eats way too much time from the main thread. This is also encountered by the other people, even the hijacklib team. However I am still trying to do a non-delegate approach but so far I am not getting any good result too.
I agree Babak. Got my kit, and tried the tutorial. I’ve flashed the binary to the device, but for me it just doesn’t work.
I see a low voltage (0.6v)on the vcc and gnd from the board, suggesting that it is powered up to a degree. But I don’t see the app working as expected.
My conclusion is this doesn’t really work.
Hello Paul, is the volume turned up to the max when you plug in the module? The power supply of the module depends on the volume output of the phone.
Thank you for your quick response.
Yes I have the volume up full. I’m using an early generation ipod touch – I don’t know if that has anything to do with it.
I have also written some code for Windows Phone, and here I see only 0.3v. Could this be due to the amplitude of my sine wave or its general quality? Not sure how this affects things but sure it does in some way
any advice greatfully received.
In this URL “http://www.eecs.umich.edu/~prabal/pubs/papers/kuo10hijack.pdf” says that u need to generate a 22Khz waveform. In the “2.3 Harvesting Energy Efficiently” part.
Yes indeed, a constant 22khz waveform, stacked up with each other is needed to power the device.
Hello Paul, indeed it depends on the frequency you send from the phone. It needs 22khz (as said from their site) and we would have to stack them up so it will be a constant 22khz tone. If we would be looking the signal from an oscilloscope then we should be seeing multiple 22khz frequencies stacked up on each other. But I have not yet tried to manually do it.
Yes I’m producing a 22khz wave form in mono at the moment. When you say ‘stack them up’ what do you mean? Sorry I don’t follow. As well as my own code, I have used other signal generator apps. By increasing the amplitude I did see an increase in voltage on.
I don’t have a scope to test this with, but I’ve today ordered the DSC Nano V2 you are using, so I hope to be able to prove the hijack board is working when this arrives (hopefully by the weekend).
Quick q: The Seeed Studio Wiki shows this demo using their proto-typing board, with the analog twig connection. Can you tell me if the hijack board binaries differ between your implementation and theirs?
I’ve tried to do the implementation in both ways, and only once saw the expected App Store ocsilloscope result. I haven’t been able to reproduce it again.
Any additional thoughts? Appreciate your help here
mmm… I already test my pack and it’s working with the part 1 tutorial. But I cant install the hardware drivers in my compurer :S. So i cant change the firmware. Another question that I have is if I can change the code in the mainboard. I want to use some other pins.
Thank u…
Yes you can change the code on the main board. I have something in the works but I am not yet able to document it here due to that I cannot get it to work. You can see a sample of a build here: http://t.co/ooMYilNm. As you would see, it produces the .ihex file that you can use to upload the firmware. The firmware is TinyOS.
Oops I am sorry, I am wrong and seem to talk about a different thing about the “stack em up”. Sorry again. But yes indeed I tried a signal generator too and cannot seem to get something out of a 22khz signal. You can see the one that the sample code signal output here: http://t.co/eXrKNRRL. Apologies for the blur but I also cannot reproduce this from a signal generator. I can investigate further. The voltage that comes out of it is 480mV.
mmm… are you already gave the dev/ttyUSB0 permission? i posted u my gmail in your twitter account.
Ow, for the usb port, I think the error is ok because I don’t have the module plugged in too. The one I am after is the .ihex file output. It will be the one that we will use to upload using the program created by Seeedstudio.
Does anyone have this Hijack kit and may not be using it?
I would not mind paying you a little premium in top of your expenses. I have couple of ideas that I would like to test.
Wendel,
Thanks for the post!, any updates with the DSK or iPhone software tools?
Hello Rene,
I was busy a bit these days and I am still not able to get back to them but thank goodness I’m just done during the weekend. Maybe I can try FSK this weekend and I’ll post one here.
Hi Wendel,
This is a great job.
We hope to show us things and FSK.
Redards
Tatko
Thanks Tatko! I’ll put up FSK soon.
Hi Wendel,
Do you have any idea how to configure USART MSP430 for communication with the audio ports?
Note:
In HijackMgr.h I think there is bug – see variable unitIsRuning.
Correct me if I’m wrong.
redards
tatko
Hello Tatko,
First for the unitIsRunning, I don’t think that it is used by the code so we can comment it out.
For the MSP430 as a serial, I haven’t really tried loading the HiJackUARTPassThrough binary to the HiJack module. Maybe I can try it over the weekend. But I saw the code though and it seems that is is indeed using serial (refer to: http://www.tinyos.net/tinyos-2.x/doc/nesdoc/micaz/ihtml/tos.interfaces.UartStream.html). My apologies as I have not yet tried this sooner.
Hi wendellinfin,
There is a solution to hijack based on Atmega88 (FSK in AVR Studio) and i Phone communications.
Note: 15μA at 32kHz, 1.8V for Atmega88 (MSP430 has nearly so)
redards
tatko
Great! I’d like to hear that too! Have you tried it also? We can put it up as another tutorial too. I was working on something like that (avr based) but I failed, and I failed hard.
Hello!! you have a very nice post here. I want to develop a similar project but using Android. Do you have some new post using it? Thank you!
Hello Pedro,
Thanks! Unfortunately, I don’t have an Android phone to experiment on. Though there are some hardware kits made for Android such as the IOIO and the ADK kit by Seeedstudio. You can check them out here:
http://www.seeedstudio.com/depot/microcontrollers-android-c-132_206.html
Hope it helps,
Wendell;
mmm… the problem here is that i dont want to use arduino or anithing similar. I want to use a pic in order to develop the project. But i thing that i can use your device and use it on android. Your kit only needs some data to receive and transmite aren’t you?.
My apologies as I’m afraid that I won’t be able to provide much help in using the HiJack module with Android but the module is using Manchester encoding (I’m not an expert on this) and relies on the way you transmit the bits using frequencies on the output jack. Its like converting a byte into a series of high-low frequencies per bit for the module to understand and should follow transitions on how to represent bits. Maybe when something is about to be transmitted, lets say number 38 or binary 100110, the frequencies we will transmit are: [high-low]-[low-high]-[low-high]-[high-low]-[high-low]-[low-high] because a “1″ is a high-low and a “0″ is a low-high transition. The high frequency of the module is “1378.125″ as from the iOS code and the low is 1378.125/2. You can hear this frequency when played on any sound generator.
Someone please do can correct me if I’m wrong.
I want to adquire the kit but there is no more in stock on seeedstudio.com do you have some other kit? or when would be possible to buy one of them in seeedstudio.com
Im from mexico
Thank you
My apologies as I am not also sure on when they would have stock. Though for now I found a project and I think you can try this circuit out. It fits your approach (with the pic+android):
http://robots-everywhere.com/re_wiki/index.php?title=Serial_on_Android_using_the_audio_port
Hope it helps.
Starting a new thread – so I can read it!
I’ve tried my board on an iphone 4 today. The example Hijack app sees 0.9 volts. On my WP7, with a maximum sampling rate of 48khz I can achieve 0.6 volts.
I am wondering if this is purely a volume thing. Both devices are up full volume
I’m going to reflash my device and see if that makes a difference.
But the gist is the power harvesting isn’t working – or am I measuring from the wrong place (VCC/GND pins) to find the expected 3.3v?
By going stereo on my output and increasing the amplitude I can get to 0.36v at maximum volume.
You may want to try using different frequencies with your WP7 – the 22kHz listed in the HiJack paper is the result of several factors including the impedance of the iPhone 3.5mm port. As far as I know, the hardware of the iPhone 4 and the 3GS is the same, but it varies between Android phones and WP7 phones. Unfortunately, the ideal frequency for energy harvesting using HiJack for many phones is outside of spec. This is one of the problems with using this board for developing on other platforms.
I bought the HiJack from Seeedstudio. (http://www.seeedstudio.com/depot/hijack-development-pack-p-865.html?pages=2&cPath=174&r_q=q) and I followed the tutorial to reinstall firmware. http://www.seeedstudio.com/wiki/index.php?title=Hijack#Download_the_firmware
However, I keep getting timeout during Mass erase(-e). I already made sure that
(1) the mainboard and program board are connected to my laptop. (LED is on)
(2) I changed port to COM1 when I use windows
(3) I also try using Linux after I downloaded TinyOS. (/dev/ttyUSB0) Still the same error
(4) I don’t get error from reset(-r) though. I saw there is an orange light coming from the board blinking. So I guess reset is working.
One thing I noticed is that the picture of the mainboard in Seeedstudio website is a little different from the one in tutorial. I hope it’s just some reallocate of component. The firmware package on the website should still work.
Could you please tell me how to debug so that I will be able to reinstall the firmware you provided and I can modified it to have I2C function later.
Thank you very much.
Hello Tiffany, my apologies for the late reply. I have encountered that problem before and it was due to the FT232 driver of the HiJack programmer. I was using Windows 7 then.
Hope it helps!
Thanks for the reply. In my case, it is actually because of the one of the pins on the programmer board is shorter than others. After fixing it, it works.
Good to hear that Tiffany!
hi tiffany, I am having the same “timeout” error. I am wondering how you solve that problem. The weird thing is that I can upload code onto hijack when I first used it, but suddenly it stops working.
Reblogged this on C World and commented:
What I will be using to get EEG data into the iPhone – unless I can find something better!
Hi, I cannot seem to find the HiJack app on the apple appstore.
Has it been removed?
I’m afraid that it is now only available in the US App Store.
Thanks for the quick response.
I am located in the US but when searching for “HiJack” app from the App Store search tab it wont show up. I have a 4S device. Any ideas? Thanks in advance, Victor
Hello Victor, you may try this direct link:
http://itunes.apple.com/us/app/hijack-oscilloscope/id43438887
Hope it helps.
Nope. no luck. probably an issue on my end. Anyways, thanks for your help. i will see if I can figure it out by myself.
Just in case, you can do a compile of the app from their source code.
Hi, I’ve had great luck following all of your HiJack tutorials and using the information to integrate the HiJack into one of my projects! Thank you.
Now for my project I need the VCC to output set values synchronized with the clock. I know I can’t do this with libHiJack so I’ve installed tinyOS on my machine. Should I go about this by making changes to their source code then upgrading the firmware to include the changed files? I’m not experienced with tinyOS, but I have written an nesC routine which tells the MSP430 to output a triangular wave. Now I’m hoping that there’s a straightforward way to drop my code into their project and get it onto the hardware. I know this could be a tough question, so any help is greatly appreciated!
Hello Will, I’m glad the post helped. For loading the new firmware: once you have compiled a new one from your VM, get the .hex file and then use the loader by Seeedstudio that can be found here: http://www.seeedstudio.com/wiki/index.php?title=Hijack#Introduction. Their .exe file will be the one to load the new firmware to your HiJack. My apologies for the late reply, I have not made any updates lately to this blog.
Thank you for replying! Have you tried to do this? I’m having trouble compiling the .ihex file. I followed the instructions posted on the HiJack main tree, but I can’t get tinyOS to recognize hijack as a target platform. I tried putting the platform file in tos>platforms with the others to no avail.
I got the code to compile! I took the files and folders found in MSP430>support>make and placed them in tinyos-2.x>support>make. Then I added this line to the Makefile found in the HiJackMan folder:
CFLAGS += -I/opt/tinyos-2.x/tos/platforms/
Thank you!
sorry the line should be CFLAGS += -I/opt/tinyos-2.x/tos/platforms/
CFLAGS += -I/opt/tinyos-2.x/tos/platforms/hijack
Great! Thanks for this
Angry Birds Space is one of the most original games out there. I think it surpassed previous versions of the game. One should think of planes very different from Newton. Another success of the Finns!
Hi, what transistors were used in the bridge in power harvesting circuit?
Hello Popiol, a transformer, LPR6235, was used along with a MIC5231 regulator. Hope it helps!
Not use !
Audioport generate to 13 Volts when starting app driver iPhone.
We use TPS62120 .
Redards
Tatko
Thanks for the correction Tatko, I mistakenly got it from the schematic. Much appreciated
Note.
For we applications use iPhone 2 , current is 3.2 mA /3.0V
They say that the iPhone 4 provides about 7 mA!
Is there such a thing?
Anybody have any information?
Redards
tatko
As for me, I am not sure also