Reading data from a glucose meter 'Diagno-Check Smart'
The very (barebones) script is in my github if you’re curious:)
Hello again, welcome to my silly corner, i’ve had a glucose meter called Diagno-Check Smart for a bit now, their site has a download link for a software, but it never worked for me, (its also only for Windows/MacOS, no Linux which is always -1pt), but i haven’t thought about plugging it into my (linux) pc and checking if it recognizes it for some reason…. but today is different!
IT DOES RECOGNIZE IT
for some reason i didn’t expect it to show up at all, but it does, lsusb returns this:
Bus 005 Device 004: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port / Mobile Phone Data Cable
wow.. this is exactly what i needed to know, like, exactly, i can’t believe the first thing i tried gave me useful information :D
I love cereal serial
if you didn’t know yet, its very easy to interact with serial devices, if you’ve ever tried using arduino or esp32 or any other mcu, you likely know that (in linux) they show up as ttyUSBx devices under /dev/ttyUSBx, where x is a number, usually in the order that you plugged in the device, in this case it’s /dev/ttyUSB1 since /dev/ttyUSB0 is taken up by an esp32 i have plugged it, same one i used in the last esp32 blog btw, check it out :3
so it’s as easy as using cat /dev/ttyUSB1 and boom here’s the output:
as you can clearly see, this guy’s sugar level are prett- hold on wait where’s the data?..
Of course it won’t be that easy
turns out, alot of serial devices operate under a “don’t speak unless spoken too” principle, you have to first send an ASCII ENQ control character, i won’t pretend to know alot about this, because i do not, i only ‘figured it out’ because i got some external help, without it, i would’ve thrown the project out the window and called it a day since i looked online and nothing mentioned this ENQ control character at least from what I could find, im sure alot of people know how to use search engines more than i do, but it worked out in the end
turns out, if you send the ASCII ENQ control character, then read the data sent by the device to the computer with 9600 baudrate, you get useful data!
stty -F /dev/ttyUSB1 9600 raw -echo to configure the port then
cat /dev/ttyUSB1 to read the data and voila, you get legible data
(snippet, there were 500 entries..)
35,2017,06,25,15,22,123,mg_dL
36,2017,06,25,13,18,186,mg_dL
37,2017,06,25,09,32,256,mg_dL
38,2017,06,25,03,58,238,mg_dL
39,2017,06,25,01,51,73,mg_dL
after some python code, you can format the data nicely into .xlsx or .csv, and get something that resembles this:
| Index | Date | Time | Value | Unit |
|---|---|---|---|---|
| 35 | 2017-06-25 | 15:22 | 123 | mg_dL |
| 36 | 2017-06-25 | 13:18 | 186 | mg_dL |
| 37 | 2017-06-25 | 09:32 | 256 | mg_dL |
| 38 | 2017-06-25 | 03:58 | 238 | mg_dL |
| 39 | 2017-06-25 | 01:51 | 73 | mg_dL |
Conclusion
it was suprisingly easy, the data was just.. there, not much encoding, not even leaving mg_dL as some obscure number or storing things as bits, just straigh up data, which of course i always love to see, i wish more things were this easy.
Well, i had fun, and learned alot so it’s a win win, cya in the next project where i…. decode… a blood pressure sensor or something idk