Share My Creation eBreathalyzer : wifi enabled cheap eBAC sensor

miker2069

Active Member
Licensed User
Longtime User
Extremely nice JP. I am doing quite a bit with NodeMCU (which is a dev board for the ESP8266), and interestingly stumbled across this when reading up on providing a 12V and 5V (I need to drive the NodeMCU and a 12V solenoid lock). Anyway, very nice tutorial, great IoT device and of course using B4X. I drive myself crazy with all the wonderful possibilities of things to create
 

freedom2000

Well-Known Member
Licensed User
Longtime User

Beware that the solenoid is a coil and thus produces a lot of back EFM. You should protect the mosfet with a diod in // to the coil



see here : driving inductive loads
 

miker2069

Active Member
Licensed User
Longtime User
Thank You for the tip! In testing so far, I haven't had much issue with back EMF generated by the magentic field of the coil when in transition (energized to non-energized and visa versa). Good precaution though and to be safe I'll take your advice - thanks!
 

freedom2000

Well-Known Member
Licensed User
Longtime User
Sorry, no...
I can help but not provide the code.

Basically it's however quite simple :
- acquire the analog output of the sensor
- wait for several readings and average them
- do not blow and get the zero value to substracts to further readings
- blow with alcoohol and get the "drunk value"
 


ok thanks, will dring than
 

freedom2000

Well-Known Member
Licensed User
Longtime User
finally here is the "clever" part of the code on the ESP side :

B4X:
void GetAlcohol()
{
      int i;
      AlcoholRaw = 0;
      for (i = 0; i<10; i++)
      {
        delay(10);               //wait 50ms to allow good ADC conversion
        AlcoholRaw  += analogRead(A0);
      }
      AlcoholRaw = AlcoholRaw/10; //average /10
      //Serial.println(AlcoholRaw);
}

As I said it's simple !
Most of the processing is done on the android side
 


Thanks a lot
how do you calculate the BAC out of the voltage inputs?
for calibration?

just by drinking?
 

freedom2000

Well-Known Member
Licensed User
Longtime User
Thanks a lot
how do you calculate the BAC out of the voltage inputs?
for calibration?

just by drinking?
Yes you drink, you measure your BAC with another device and you calibrate !

But be sure that these sensors are not reliable, they drift with temperature and BAC is also dependent on your lungs volume... as long you blow, as long alcoohol goes into the sensor and as long the BAC increases...

So to have almost consistent measurements :
- wait for the temperature to be "hot"
- measure several times
- blow "full lungs" to "empty lungs" to have your own calibration reliable
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…