Breathalyzer running on the MBED 1768 Platform; EE4427 Group 3 Spring 2018

Dependencies:   4DGL-uLCD-SE mbed

Committer:
phred754
Date:
Mon Apr 23 22:18:27 2018 +0000
Revision:
0:35f90b280233
EE4427 Final Project Group 3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phred754 0:35f90b280233 1 //Written by Todd Clark
phred754 0:35f90b280233 2 #include "convertToBAC.h"
phred754 0:35f90b280233 3
phred754 0:35f90b280233 4 float getBAC(float input){
phred754 0:35f90b280233 5 float voltage = input * 3; //Conversion from input resistance to voltage.
phred754 0:35f90b280233 6 float calibratedVoltage = voltage / 0.6; //Convert voltage to work with our 3 volt output signal.
phred754 0:35f90b280233 7 float ppm = 1033.992 + (55.84479 - 1033.992)/(1 + pow((calibratedVoltage/4.540421), 8.423297)); //Calculate ppm from our voltage values based on specs for MQ-3 gas sensor.
phred754 0:35f90b280233 8 float bac = (ppm * 0.21) / 100; //Calculate BAC from ppm. Formula taken from http://nootropicdesign.com/projectlab/2010/09/17/arduino-breathalyzer/
phred754 0:35f90b280233 9 float calibratedBac = bac - 0.12; //Calibrate sensor based on value at 0% alcohol.
phred754 0:35f90b280233 10 return (calibratedBac < 0.0) ? 0 : calibratedBac;
phred754 0:35f90b280233 11 }