Hello forum,
I want to communicate with a serial glucose monitor device that runs with a 3.3V coin cell battery.
Purpose:
- send HEX (array) commands to the device
- receive the response(HEX array)
- Store the data on inbuilt EEPROM of arduino or transmit it via bluetooth or any wireless device.
Progress:
Successfully sent command to the gluco monitor (acknowledgement message "PC" shown on the glucometer screen).
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
bool x = 1; //to make sure the loop runs only once
int led = 13; //indication LED
void setup()
{
Serial.begin(19200); // Open serial communications and wait for port to open:
mySerial.begin(9600);
pinMode (led, OUTPUT);
delay(500);
}
void loop() // run over and over
{
if (x == 1) { //to make sure the loop runs only once
digitalWrite(led, HIGH);
byte message[] = {0x02, 0x12, 0x00, 0x05, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x00, 0x84, 0x6A, 0xE8, 0x73, 0x00, 0x03, 0x9B, 0xEA, }; // HEX code to check device serial number
mySerial.write(message, sizeof(message));
digitalWrite(led, LOW);
x = 0;
}
else;
}
the device's response is clearly screen in its LCD. ("PC" is written in its LCD).
Problem:
The device is supposed to send an acknowledgement & information to the arduino in turn. I am stuck at this stage.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
bool x = 1; //to make sure the loop runs only once
int led = 13; //indication LED
void setup()
{
Serial.begin(19200); // Open serial communications and wait for port to open:
mySerial.begin(9600);
pinMode (led, OUTPUT);
delay(500);
}
void loop() // run over and over
{
if (x == 1) { //to make sure the loop runs only once
digitalWrite(led, HIGH);
byte message[] = {0x02, 0x12, 0x00, 0x05, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x00, 0x84, 0x6A, 0xE8, 0x73, 0x00, 0x03, 0x9B, 0xEA, };
mySerial.write(message, sizeof(message));
while(!mySerial.available()); // wait for the serial port to senr data
int incomingByte = mySerial.read();
Serial.println(incomingByte,HEX);
digitalWrite(led, LOW);
x = 0;
}
else;
}
The output shows this
:ø
instead of this
02 06 06 03 cd 41 02 11 02 05 06 47 58 47 34 34 35 44 45 52 03 be 25
Any thoughts on this issue shall be appreciated.
Thank you.
PS- I tried to sniff the serial port using serial monitor(communication between glucometer & the propitiatory software via desktop computer) & the information is enclosed in the attached .txt file.
All I am trying to do is to communicate with the device with arduino without using the proprietary software.
Sniff_Dump.txt.txt (32.1 KB)