13°- ¡IM BACK!


Input devices

Inicio

Wednesday ,April 7

Have you ever felt that pressure that you have many things to do and you don't even know where to start? Sometimes it is good to take a break from everything but on the condition that one day you have to go back to take everything back, it is like going back only to gain momentum and go further.

Components/Functioning/Bootloader Attiny85/Group assignment

The mission - Group assignment

This week's mission is not an impossible mission at all, it is quite the opposite, it is one of the simplest missions that I have seen in all these weeks, however there is a small problem, as you will remember my project is Parkyt, a device with many qualities Among which is to be a breathalyzer, therefore the input sensor that I must test is the breathalyzer and in honor of science I will be the one who tests the sensor just to confirm the veracity of its data.

Only a couple of components will be needed for this mission:
-Programmable electronic board (attiny 85) or Parkyt :

-MQ3 sensor :
-A lot of alcohol:

The MQ3 sensor is a very versatile sensor because it is an analog sensor, however in this case we can use it with a dual purpose because on this test board where the mq3 sensor is located it has a comparator OPAM which allows us to place a threshold voltage to be able to emit a digital signal so that the sensor can be used in digital mode, this is obviously calibrated by means of a potentiometer that will be on the mq3 board.

To have more information about this sensor, it is important to know the data sheet of this component as well as all the other components that we have previously used in other missions, in the case of this component, as we have already indicated, it is a sensor that begins being analog but by means of an opam it can be modified so that it is a digital and analog sensor at the same time.

Functioning

To be able to program this sensor we first have to know how a breathalyzer works, we have to know that the breathalyzer is a device which will help us to know the amount of alcohol per liter of blood that we have in our body, for this I will use The MQ3 sensor which has the quality of reacting towards ethyl alcohol or ethanol, this sensor will collect this information from the breath of the users who are going to blow directly to the sensor.In the following image we can see the limits of the MQ3 sensor.

Now what we must do is a simple rule of three, if the reading ranges of this MQ3 sensor are from 0.05mg / L to 10 mg / L and the output voltage that it gives in the form of an analog signal is 0.1v to 5v means the following:

But as we know in the analog inputs we have a reading from 0 to 1023 as a digital reading of the arduino, this reading represents the range from 0.1 v to 5v, if we put the latter together with the readings of our MQ3 sensor we would have the following:

Once this relationship is known, it is time to program.
Notes:
-It should be noted that the maximum level of alcohol in the blood for a driver is 0.5 gr / L (in the blood) and 0.25mg / L (in the air) according to D. S. N. ° 016-2009-MTC, art. 307 in the country of Peru.

Programming - Individual assignment

To start we must know which will be the programmer that we will use on this occasion, this time we will use a modified version of our already known fabtiny.

To this Fabtiny we only have to add our entrance sensor and that's it, we would have everything we need for our mission today.

We did the circuit based on the same electronic card that we baptized with the name of Fabtiny, after making all the connections and also the programming in arduino, our system has the following appearance:

For programming, the arduino ide is being used, but first we must understand how our system will work, the attiny85 has the possibility of having a somewhat curious serial monitor. One of the most interesting ways to do it is using our Fabtiny as if it were a keyboard, but for this we must first download the corresponding library, it is the following:

Once the library is installed, we must understand that what this library does is execute the keyboard digitally, once this is done you can print data in any program that allows you to write, such as a notepad, but before that we need to place the program that we will use, remember that what we want to obtain is the reading of the MQ3 sensor, so it is this data that we will print with the help of the following programming:

		#include "DigiKeyboard.h"
		void setup() {  
		}
		void loop() {
		  int MQ3 = analogRead(A1);
		  DigiKeyboard.sendKeyStroke(0);
		  DigiKeyboard.print("Lectura del sensor");
		  DigiKeyboard.println(MQ3);
		  DigiKeyboard.delay(1000);
		}
			
			

Finally we will have the following result:

To transform these values ​​into the reading range of the MQ3 we must use the "map" function which will give us the value converted into the new range from 0.05mg / L to 10mg / L.

*The final code will look like the following image:

		#include "DigiKeyboard.h"
		void setup() {  
		}
		void loop() {
		  float MQ3 = analogRead(A1);
		  MQ3 = map(MQ3, 220, 1000, 5, 1000);
		  MQ3=MQ3/100.00;
		  DigiKeyboard.sendKeyStroke(0);
		  DigiKeyboard.print("Lectura del sensor");
		  DigiKeyboard.println(MQ3);
		  DigiKeyboard.delay(1000);
		}
			
			

Chef's Notes:
-These sensors are electrochemical and vary their resistance when exposed to certain gases, internally it has a heater in charge of increasing the internal temperature and with this the sensor can react with the gases causing a change in the resistance value and that is why we must wait a few seconds for our sensor to reach an optimal temperature and be able to measure.

And now the most exciting part has arrived, it is time to test our alcoholometer.

Taste (or tasting)

As you can see in the graph, only 2 glasses or 330 ml bottles are necessary to reach and pass the allowed limit, let's check it!

After about 4 bottles of 330ml taken the result is very clear and indicates that I have an approximate of 2 mg / L of alcohol, this as it is in the air would be reflected in approximately half which would give me 1 mg / L, that it means that it is a bad time to drive and my sensor is perfectly calibrated and ready to be implemented in Parkyt.

Next-Week 11Previous-Week 8