Arduino Code for Blood Glucose Detector Electronic Reader
Video Link 1
Video Link 2
Video Link 3
######## Code Start Here ##########################
#include <Wire.h>
#include <SPI.h> //
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
int glucoinput1 = 0;
int glucoinput2 = 1;
int differential_data;
int push_button = 4;
int buttonval = 0;
int state = 0;
unsigned long int avgValue; //Store the average value of the sensor feedback
float b;
int buf[10],temp;
float overal_data;
float volt_gluco;
float gluco;
float gluco_mmol;
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
pinMode(push_button,INPUT);
display.clearDisplay();
}
void loop() {
buttonval = digitalRead (push_button);
Serial.println(overal_data);
if (state == 0) {
display.setTextSize(1.8);
display.setTextColor(WHITE);
display.setCursor(10,0);
display.print("WELCOME to E-Reader"); display.print(""); //OLED display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(24,15);
display.print("Insert Strip &"); display.print(""); //OLED display
display.setTextSize(1.2);
display.setTextColor(WHITE);
display.setCursor(45,25);
display.print("Press >"); display.print(""); //OLED display
display.display();
if (buttonval == 0) {
display.clearDisplay();
delay(1000);
state = 1;
}
}
else if (state == 1) {
display.setTextSize(1.5);
display.setTextColor(WHITE);
display.setCursor(17,5);
display.print("Please Put Blood"); display.print(""); //OLED display
display.setTextSize(1.5);
display.setTextColor(WHITE);
display.setCursor(20,15);
display.print("In Test Strip"); //OLED display
display.display();
differential_data = chan_diff();
for(int i=0;i<10;i++) //Get 10 sample value from the sensor for smooth the value
{
buf[i]=differential_data;
delay(10);
}
for(int i=0;i<9;i++) //sort the analog from small to large
{
for(int j=i+1;j<10;j++)
{
if(buf[i]>buf[j])
{
temp=buf[i];
buf[i]=buf[j];
buf[j]=temp;
}
}
}
avgValue=0;
for(int i=2;i<8;i++) //take the average value of 6 center sample
avgValue+=buf[i];
overal_data=(float)avgValue/6; //convert the analog into millivolt
volt_gluco=overal_data*5/1023; //to get voltage value in V
gluco=(volt_gluco-2.6835)/0.00185; //to get glucose level in mg/dl
gluco_mmol=gluco/18; //to get glucose level in mmol/L
if (overal_data >= 570 && overal_data <= 670) {
state=2;
}
}
else if (state==2){
for (int count=5;count>=1;count--) {
display.setTextSize(3);
display.setTextColor(WHITE);
display.setCursor(60,5);
display.print(count); display.print(""); //display count from 5 to 1
display.display();
delay(1000);
display.clearDisplay();
}
state = 3;
}
else if (state == 3) {
Serial.println(gluco);
Serial.println(overal_data);
Serial.println(gluco_mmol);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(25,0);
display.print("Voltage:"); display.print(volt_gluco); display.println(" V"); //Voltage generated from the reaction
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(25,9);
display.print("Glucose level: "); //OLED display
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(30,17);
display.print(gluco); display.println(" mg/dL"); //OLED display glucose level in mg/dl
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(30,25);
display.print(gluco_mmol); display.println(" mmol/L"); //OLED Dispay glucose level in mmol/L
display.display();
delay(2000);
}
}
int chan_diff () //function for differential mode
{
analogRead (glucoinput1) ;
delay (10) ;
int ch1 = analogRead (glucoinput1) ;
analogRead (glucoinput2) ;
delay (10) ;
int ch2 = analogRead (glucoinput2) ;
ch1 += analogRead (glucoinput1) ;
ch1 >>= 1 ;
return ch1 - ch2 ;
}
is it possible to see the connections of the circuit and what components did you use?
ReplyDeleteHere you go ... the link to the overall design .... https://red-arduino.blogspot.com/2020/04/development-of-electronic-reader-for.html
DeleteIs there schematic diagram for the shield designed and its integration with arduino?
ReplyDeleteYou can download the the shield design from the manufacture website. It provide the circuit and the pcb diagram. The overall design instruction you can get from here: Project Design & Schematic:
Deletehttps://red-arduino.blogspot.com/2020/04/development-of-electronic-reader-for.html
This comment has been removed by the author.
DeletePls send me circuit of this glucose meter pls
ReplyDeletehi! how did you find the relation between voltage and glucose concentration? Is there any source, or calculations? Thank you very much, great work!
ReplyDeleteSir please send shematic diagram
ReplyDelete