This blogpost will describe how you can get the ECG Sports prototype running on your iPhone.
Before you get started make sure you have following equipment:
- iPhone
- iPhone Developer SDK, provisioning profiles, etc.
- Arduino BT + Developer Tools
- HRMI Module for Arduino
- Polar T31 Transmitter
- Soldering iron (never bad)
- Cables
- Breadboard
Lets get started
Make sure you follow the tutorials on how to get btstack running on your iPhone (this enables the full bluetooth stack on your device.
Also read the blog post on how you initialize a new humanapi project so you can get started right away. In this case the HumanApi project is called “ceg”.
Connecting the HRMI to the Arduino
You can use a breadboard to connect your HRMI to the Arduino or simple cables. Make sure that the outputs of the HRMI get put into following inputs/outputs of the Arduino BT:
| HRMI | Arduino BT |
| 5V | 5V |
| GND | GND |
| RX-I/SDA | Analog in 4 |
| TX-0/SCL | Analog in 5 |
Setting up the Arduino source code
If you haven’t yet cloned the git repository, do so now and take a look at the prototypes/src/ceg/arduino folder.
You need to have the Arduino Editor installed to be able to open the ecg.pde which contains all important code.
Before you can test the Polar gear with the Arduino BT, make sure you set the correct HRMI_I2C_ADDR in the Arduino source. It should be 0 which means that you have to install jumpers on the HRMI (If this sounds unclear to you, read the manual coming with the HRMI, everything is clearly explained there).
Also don’t forget to remove the SJ1 jumper and add a jumper at OP0 (Again, all of this is explained in the HRMI manual but I am explaining it anyways).
Testing the Arduino HRMI connection
To test the connection, open the serial monitor of the Arduino SDK and start wearing the Polar T31. After some time you should see the yellow LED on the HRMI blink according to your heart rate. At the same time the HRMI should transmit to the Arduino and you should see data in the serial monitor.
Baudrates
Set the baudrate in the Arduino source to 115200 – other values should work without problems but this always works well for me.
Installing the Sports CEG application on the iPhone
Creating HumanApi applications is simple and usually involves the same process. If you have read the tutorial everything should be working for you, otherwise take a look at the following screencast.
Does it work?
Now when wearing the T31 in not too far distance to the HRMI you should be able to record your ECG on your iPhone which should be connected to the Arduino via Bluetooth.
If you have trouble getting everything set up, join the forum and don’t hesitate to ask questions there. It is very likely that, to me, obvious steps are still missing in this guide and I will add them once they appear.
Hey ,
i d like to contact the dude who did this pretty amazing stuff. anybody knows him?
Hi Arno,
thx for leaving feedback!! You can send me an email at no ~a.t~ uxebu.com – I will put up contact info asap
Hi Nikolai,
I got a problem.
I run the below commands and got a clone of your files but the structure is not the same as u have in the video.
$ git clone git://github.com/nonken/humanapi.git
$ git submodule init
$ git submodule update
after run the above command, I got a “humanapi” folder which only have:
a LICENSE file,
README file
and a “prototypes” folder
as I saw in your video, there should be one more folder name “apis” ?
At the step where u make the ecg project, I used the make command as u shown in the video: make ecg
It said: “sed Application/: no such file or directory”
but It did copy a “ecg” folder into “dev” folder but missing a lot of files, like no xcode project file, no “classes” folder,…
would you help me with this ?
Thanks,
Jason
and in the “prototypes/src/phonegap/iphone/” doesn’t have any file in it. It’s empty
Hi Nikolai,
I have one more question.
Is the Arduino BT you used in this project, running SPP profile at the time when it’s connecting to your iphone (which is running btstack rfcomm profile) ? what I meant is: you are using rfcomm.c in btstack to communicate with Arduino BT’s SPP ? or you have to download a rfcomm profile firmware to your Arduino BT in order for it to be working ?
I asked so because, I have a KC21 bluetooth module from KC Wirefree which using SPP profile. I have rfcomm.c compiled and run it on my iphone. I tried to connect to KC21 with this command:
./rfcomm -a BDADDR -c 1 -p 1234
(BDADDR is my KC21 address in format aa:bb:cc:dd:ee:ff)
but nothing happen, it keep saying: “Waiting for client to open /tmp/rfcomm0…”
Jason
Hi Jason,
I didn’t have to download any additional firmware to the Arduino BT.
How does your Arduino code look like?
Nikolai
Hi Nikolai,
I’m not using Arduino. I’m just trying to clarify that you used rfcomm in btstack to make a connection with a SPP bluetooth module without any special firmware because my bluetooht KC21 only has SPP profile.
Jason.
Hi Jason,
yah, I just used RFCOMM in btstack to make the connection to Arduino BT module (http://www.bluegiga.com/WT11_Class_1_Bluetooth_Module) and pretty much was able to connect straight away.
Let me know how it goes for you.
Nikolai
Hi Nikolai,
I have questions on how you setting up the WT11 bluetooth module.
Did you use the ASCII commands which are provided to talk to the iWrap on WT11 or the Arduino’s SDK ?
If you used the ASCII commands, which ones did you use ? How did you set WT11 up so that it would be able to accept a connection from your iphone which uses btstack’s rfcomm protocol ?
Sorry to ask this again, I just wanna make sure I get this. You just used the “rfcomm.c” and the include files in the btstack folder (btstack.h, hci_cmds.h, linked_list.h, run_loop.h, utils.h). That was all you need to make your xcode project work on iphone and successfully communicate with WT11, right ?
PS: can you upload your ecg xcode project to rapidshare.com or something, so that I can download it ? I’m having problems with git and make file (as I already posted in forum). Really frustrated now
Heya Jason,
I am on the road at the moment (so replying a bit slow) – I’ll try to upload a ready package before the weekend!
Maybe we should setup an irc channel so we can walk through your issues?
Nikolai
Hi Nikolai,
.
It’s ok, take ur time.
I ordered the WT11 bluetooth module (Not the one on Arduino board, just bluetooth module) because it seems like I can do more for detail configurations for RFCOMM or L2CAP. It’s still on the way here so I’ll get back to you when I have my hand on it
Cool. We should setup one. It will be easier. I have never used IRC before so I think I need some time to learn how to use it first..lol..
Jason
Hi Nikolai,
I wonder if u got any problem when u compile ur code to iphone ?
I tried to experience on the bluetooth inquiry part of the wii mode sample code in btstack. I compiled and got the below error. I google it and found that this is a problem with linking library (I guess ?). I haven’t found any solution to this yet.
Do u know how to fix this ?
Line Location Tool:0: collect2: ld returned 1 exit status
Line Location Tool:0: symbol(s) not found
Line Location Tool:0: _hci_link_key_request_reply$non_lazy_ptr in BTInquiryViewController.o
Line Location Tool:0: “_hci_link_key_request_reply”, referenced from:
Line Location Tool:0: -[BTInquiryViewController dealloc] in BTInquiryViewController.o
Line Location Tool:0: -[BTInquiryViewController startInquiry] in BTInquiryViewController.o
Line Location Tool:0: “_bt_register_packet_handler”, referenced from:
Line Location Tool:0: _hci_inquiry_cancel$non_lazy_ptr in BTInquiryViewController.o
Line Location Tool:0: “_hci_inquiry_cancel”, referenced from:
Line Location Tool:0: _hci_inquiry$non_lazy_ptr in BTInquiryViewController.o
Line Location Tool:0: “_hci_inquiry”, referenced from:
Line Location Tool:0: -[BTInquiryViewController handlePacket:channel:packet:size:] in BTInquiryViewController.o
Line Location Tool:0: -[BTInquiryViewController handlePacket:channel:packet:size:] in BTInquiryViewController.o
Line Location Tool:0: -[BTInquiryViewController handlePacket:channel:packet:size:] in BTInquiryViewController.o
Line Location Tool:0: -[BTInquiryViewController handlePacket:channel:packet:size:] in BTInquiryViewController.o
Line Location Tool:0: “_btstack_set_power_mode”, referenced from:
Line Location Tool:0: _hci_remote_name_request_cancel$non_lazy_ptr in BTInquiryViewController.o
Line Location Tool:0: “_hci_remote_name_request_cancel”, referenced from:
Line Location Tool:0: -[BTInquiryViewController stopInquiry] in BTInquiryViewController.o
Line Location Tool:0: -[BTInquiryViewController stopInquiry] in BTInquiryViewController.o
Line Location Tool:0: -[BTInquiryViewController startInquiry] in BTInquiryViewController.o
Line Location Tool:0: -[BTInquiryViewController getNextRemoteName] in BTInquiryViewController.o
Line Location Tool:0: -[BTInquiryViewController handlePacket:channel:packet:size:] in BTInquiryViewController.o
Line Location Tool:0: -[BTInquiryViewController handlePacket:channel:packet:size:] in BTInquiryViewController.o
Line Location Tool:0: -[BTInquiryViewController myStartInquiry] in BTInquiryViewController.o
Line Location Tool:0: “_bt_send_cmd”, referenced from:
Line Location Tool:0: _hci_remote_name_request$non_lazy_ptr in BTInquiryViewController.o
Line Location Tool:0: “_hci_remote_name_request”, referenced from:
Line Location Tool:0: _hci_link_key_request_negative_reply$non_lazy_ptr in BTInquiryViewController.o
Line Location Tool:0: “_hci_link_key_request_negative_reply”, referenced from:
Line Location Tool:0: _btstack_set_power_mode$non_lazy_ptr in BTInquiryViewController.o
Line Location Tool:0: “_bt_flip_addr”, referenced from:
hi Nikolai,
this is a great app !!
this is a bit off topic, but do you know if you can use the board for two way communication between the iPhone ?
i would like to be able to run stepper motors via iPhone.
would be great if you could let me know if you have tried it think that it should be possible.
cheers
Martin
A theory like this one seems impossible to fathom. A common question is whether the government is attempting to maintain calm among the populace while some openly question about the upcoming events. If this theory is accurate, we wonder who the people who are on the list will be.
Thank you for sharing this with us all and I shall definitely try this out.
However, I just have one minor criticism.
A Polar monitor derives heart rate from an ECG. The ECG looks like this:
http://eleceng.dit.ie/tburke/biomed/ecg.png
The Polar HRM measures the spikes of the R wave and the HRMI derives heart rate by measuring average R-R interval.
Anyway what you have is a heart rate monitor, not an ECG. If the ECG is not visible it should not be called ‘ECG’.
It may seem a minor point but I think it is important to name things correctly.
This does not detract from what is otherwise an excellent idea.