November 22, 2024, 11:47:49 PM

MEGA-ADK_SHIELD-EKG_Nexus4

Started by svan, November 14, 2013, 03:11:14 AM

Previous topic - Next topic

svan

The following video demonstrates using an Arduino MEGA-ADK (for Android) with an Olimex SHIELD-EKG to display an electrocardiogram on a Nexus 4 cellphone (Google/LG):

http://youtu.be/h7nysCmyWiU

LubOlimex

Nice svan,

I have the same phone. However, why are you showing only a demo signal, not an actual reading? I'm also curious where have you connected the micro USB? Can't clearly see an output port on the MEGA-ADK.

Thanks for sharing your project.

Best regards,
Lub/OLIMEX
Technical support and documentation manager at Olimex

svan

> why are you showing only a demo signal, not an actual reading

That's not a demo signal.  It is my own electrocardiogram in real-time.

> where have you connected the micro USB

The micro USB to the Nexus 4 phone plugs into the center port of the the MEGA-ADK; it looks like a regular USB port.  The MEGA-ADK has three ports.  One USB goes to the computer (I used a Mac) for uploading Arduino code and power, one USB goes to the cellphone, and the third is for a 9V battery.

[img]MEGA-ADK/img]

metin

Hello swan.. When I received my sample project your project.
I am sending the signals bluetooth.But
I can not edit a kind of signals.My final project.
Can you share the Arduino code.Thanks..

svan

The Arduino code for this project was taken from "Beginning Android ADK with Arduino" by Mario Bohmer, page 119.  I modified it slightly:

#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>

#define COMMAND_ANALOG 0x3
#define TARGET_PIN 0x0
#define INPUT_PIN A5

AndroidAccessory acc("Manufacturer",
           "ECG_Android",
           "Description",
           "Version",
           "URI",
           "Serial");

byte sntmsg[6];
int analogPinReading;

void setup() {
  Serial.begin(19200);
  acc.powerOn();
  sntmsg[0] = COMMAND_ANALOG;
  sntmsg[1] = TARGET_PIN;
}

void loop() {
  if (acc.isConnected()) { 
  //  analogPinReading = analogRead(INPUT_PIN) >> 2 ;
    analogPinReading = analogRead(INPUT_PIN) >> 1 ;
    sntmsg[2] = (byte) (analogPinReading >> 24);
    sntmsg[3] = (byte) (analogPinReading >> 16);
    sntmsg[4] = (byte) (analogPinReading >> 8);
    sntmsg[5] = (byte) analogPinReading;
    acc.write(sntmsg, 6);
   // delay(100);
  }
}

If you are interested in bluetooth, I have another project on You-Tube entitled "ECG_Bluetooth" which demonstrates this: youtu.be/Exx215-yEFs.  The source code for that project is at github.com/vsquared/ecg; the Arduino sketch is in a file called "ECG_BlueSerial.txt".

P.S. If you see an emoji with sunglasses in the code, the missing text is 'eight)'.

metin

#5
but I used Hc06 Bluetooth Module and passive electrodes.
How do I adapt the passive electrodes in Arduino??
Because graphics so irregular and bad.And txtrecive Value on Android came out on top 80.
my Arduino Code;your project code your ECG_BlueSerial.txt.
And Can I show your name as a reference in the report.
Thanks...

svan

> How do I adapt the passive electrodes in Arduino??

As far as I know, there is nothing that you can do with the Arduino code to reduce the noise.  The Olimex shield is inherently noisy.  In my experience, the noise was reduced by using Bluetooth.  Using an ecg cable with adhesive snap-on electrodes also helps somewhat.

> Can I show your name as a reference in the report

This is an open-source project, so you are free to use it and use me as a reference.  Thank you for your interest in the project.

metin

Arduino sketch is in a file called "ECG_BlueSerial.txt" at  at github.com/vsquared/ecg;
I used ecg cable with adhesive snap-on electrodes and later passive electrodes.
But In both signals ireegular and values very slow
I would be very happy if you help me.Thanks very much

svan

1) Is your ecg trace slower than what is seen in the video "ECG_Bluetooth"?
2) Your project uses a different bluetooth module than the one that I used;  that may or may not be important.  I used an Adafruit E-Z Link, while you used HC06.
3) Are you using the same baud rate for both the HC06 and the Arduino?  The video used 9600 for both.
4) If the data is coming in slowly, you could try increasing the baud rate to 19200 or higher for both.  I have not tried this, so I don't know if it will help or not.
5) I don't understand "values very slow".  Does that mean that the signal amplitude is a short spike?  If so, you could try turning up the gain on the Olimex shield.  In the Arduino code, shifting the sensor value >> 1 instead of 2 should also change the signal height.
6) If it's possible, posting an image of the smartphone output would be helpful.
7) This discussion should probably be moved to a new thread since it does not pertain to the MEGA-ADK project.

metin

primarily in English is not good.sory..
HC06 and Arduino same bound rate.9600
signal amplitude short spike.very short.

my arduino code:
#include <SoftwareSerial.h>
SoftwareSerial myBluetooth(10, 11);
const int analogInPin = A5;
char outStr[5];
unsigned long LoopTimer = 0;

int sensorValue = 0;        // value read from the pot

const int LoopTime5000 = 5000;

void setup()
{
  myBluetooth.begin(9600);
}

void loop()
{
  if (micros() >= LoopTimer+LoopTime5000)
  {
   LoopTimer += LoopTime5000;
   sensorValue = analogRead(analogInPin);           
   sensorValue = sensorValue >> 2*;
   sprintf(outStr,"%03d",sensorValue);
   myBluetooth.print("*");
   myBluetooth.write(outStr);
  }
}

metin

And my Arduino power comes from the laptop
image of the smartphone output

http://imgur.com/UCVrLRF

svan

Thank you for posting the image.  I'm not certain that there is an ecg in the trace.  Do you have the jumper on the Olimex board set to A5?  Pins 11,12 should be jumpered together.

>SoftwareSerial myBluetooth(10, 11);

I'm not familiar with SoftwareSerial; what are the two parameters, 10 and 11?

> sensorValue = sensorValue >> 2*;

Why is there an asterisk(*) after the two?

What software are you using on the smartphone?

If you are unable to get it to work, and you send me an e-mail address, I will try to work with you off-list to get it running.

metin

pin 10 get bluetooth value, pin 11 is send bluetooth value..

This is feature of bluetooth library.. very thanks for your advice and attenion..

(*) is my mistake in writing to forum..

i using your project at this adress github.com/vsquared/ecg..

i am importing this code on eclipe..

my device is samsung tablet, android 4.4.4

svan

1) It appears to me that the ecg signal from the Olimex shield is not being sent.
2) Would it be possible to post an image of the Olimex shield so that I can see how the jumpers are set?
3) How is the HC06 attached to the Arduino?  Is it attached to a shield or are you using a breadboard with wiring?  If it is attached to a shield, is there a 'micro', 'USB' switch; if there is a switch, how is it set?