Anip Shah
Published © MIT

Human Breathalyzer to monitor ketosis

It is a tool to monitor the presence of acetone in our breath. It uses gas sensor MQ-135, 1.3inch OLED display, DHT22 & Arduino Uno.

IntermediateFull instructions provided2 hours2,184
Human Breathalyzer to monitor ketosis

Things used in this project

Hardware components

MQ-135 Gas Sensor Module
Any MQ-135 gas sensor will work.
×1
DHT22 Temperature and Humidity Sensor
DFRobot DHT22 Temperature and Humidity Sensor
It is basically DHT-22 Module
×1
Arduino UNO
Arduino UNO
×1
Adafruit Monochrome 1.3" 128x64 OLED graphic display
1.3-inch SH1106 i2c Monochrome OLED display 128x64 (4pins)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematics

Refer to the index above.

Code

Code with calibration for MQ-135 to measure amount of acetone in breath.

C/C++
Make sure you have installed all libraries. To make the device more efficient, calibrate the sensor MQ-135 in your environment.
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <Adafruit_SH1106.h>
#include <Wire.h>

#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

#define MQ_PIN A0
#define RL_VALUE 10.0
#define RO_CLEAN_AIR_FACTOR 3.08

float readMQ();
float getResistance(float sensor_volt);

#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);

void setup() {
  Serial.begin(9600);
  display.begin(SH1106_SWITCHCAPVCC, 0x3C);
  dht.begin();
//display.setRotation(2); (in case you want to rotate display.)
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println("Initializing");
  display.println("Breathalyzer...");
  display.display();
  delay(2000);
}

void loop() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float sensor_volt = analogRead(MQ_PIN) / 1024.0 * 5.0;
  float rs = getResistance(sensor_volt);
  float ratio = rs / RO_CLEAN_AIR_FACTOR;
  float ppm = pow(ratio, -1.179) * 4.385;
  float mgL = ppm * 1.995;
    display.clearDisplay();
  display.setCursor(0, 0);
  display.println("Human Breathalyzer");
  display.drawLine(0, 12, 127, 12, WHITE);
  display.setCursor(0, 15);
  display.print("Acetone (ppm): ");
  display.print(ppm, 2);
  display.setCursor(0, 30);
  display.print("Acetone (mg/l): ");
  display.print(mgL, 2);
  display.setCursor(0, 45);
  display.print("Temp: ");
  display.print(t, 1);
  display.print(" C");
  display.setCursor(0, 55);
  display.print("Humidity: ");
  display.print(h, 1);
  display.print(" %");
  display.display();
  delay(2000);
  display.clearDisplay();
  display.setCursor(0, 0);
  display.println("Blow into sensor");
  display.display();
  delay(2000);
}

float readMQ() {
  int i;
  float rs=0;
  for (i=0;i<10;i++) {
    rs += getResistance(analogRead(MQ_PIN) / 1024.0 * 5.0 );
    delay(100);
  }
  rs = rs/10.0;
  return rs;
}

float getResistance(float sensor_volt) {
  return RL_VALUE * (5.0 - sensor_volt) / sensor_volt;
}

Credits

Anip Shah

Anip Shah

9 projects • 4 followers
Tech enthusiast and programmer who also happens to be a Biomedical Engineer.

Comments