Peripherals pt. 2 – Input

Input

Alcohol

You are having a party? Everybody likes to drink one or two beers? – That is a great opportunity introducing your personal alcohol-meter. An alcohol (MQ-3) sensor is available on Ebay for about 1-1,5€ and just awaits your order. I prefer the ready-to-use devices already being mounted on a separate board.

This small device gives you an analog output signal which corresponds to the current measurement. It is driven by simply connecting power (5V) and GND for operation, furthermore the output pin has to be connected to an analog port of your microcontroller.

As soon as you have your analog reading, you may want to at least calibrate the non-alcoholic environment – any differences may be a result of a person breathing against the sensor who had several drinks lately.

It is going to be fancy if you put out your readings encoding by 7-segement devices, an LCD display or an LED array.

Reading this sensor now becomes quite easy by using our generic class:

Methane

Have you ever thought about some kind of fart detector? – Maybe a methane sensor (MQ-4) will be the right choice. This device is pretty much the same like the alcohol sensor.

Note: I have not yet tested the capability of detecting farts or bad smell in the restroom – but you may use your imagination (maybe your microcontroller plays a heroic sound in case of a new ‘high score’)…

Reading the methane sensor is the very same as the alcohol sensor.

IR

You usually have a lot of different IR remotes in your living room for the TV, AV-Receiver, DVD/Blu-ray Player or other stuff. Probably there are some buttons typically unused? – Why not enable your IR remote triggering certain actions with your microcontroller?

Here again, there are pre-mounted IR diodes available on Ebay for less money. You may want to read my post about using this sensor on a ATtiny85 here.

Ultrasonic

An ultrasonic measurement device is quite simple. It usually has a trigger pin and an echo pin. Triggering the device sends an ultrasonic impulse – in case something is in front of the device, the ultrasonic wave gets reflected and returns towards it. The answer can then be measured on the echo pin.

The time between sending the impulse and receiving the reflection lets you calculate the distance of the object quite accurate.

distance measurements may either be useful for any kind of robot moving around – or as some kind of sensor barrier in case you permanently take measurements. This allows detecting e.g. persons passing this sensor.

You also may even communicate between different devices per ultra sonic waves.

Temperature and Humidity

There are lots of different device available for measuring temperature and humidity. However, e.g. a DHT11 device is cheap and gives you all information you need. However, they usually are not very accurate.
Reading the sensor is a bit more complicated, but still easy: There generally are several devices available providing temperature and humidity measures. Therefore, it will be a good idea introducing the following interfaces:

The actual interface and implementation of e.g. the DHT11 chip then looks like the following (note, I have used some publicly available DHT11 source); As the values are not likely to change very fast, I have also added a delay which caches the last readings:

And finally the implementation:

I do not want to focus on the actual implementation – the third party library works with our hooks. This may now be used as follows:

Compass

Have you ever tried making a robot navigate autonomously? – This is what you need for measuring your direction.

Keypad

A microcontroller is fine, but you very want to make it do things for you. A keypad is an easy way using several named buttons. This will be useful for more complex applications / user input.

Button

A simple button is inevitable – they enable you triggering certain actions.

Motiondetector

Maybe the motion detector may not be used often. However, if you use your Arduino battery powered as e.g. a wearable, this little device will be your friend. There different devices available: gyroscopes measuring the current angular momentum, whereas an accelerometer is able to measure movement directions.

Using this data is a bit more involved and requires advanced signal processing. This is a complete topic for itself and very interesting. Record some movement data and try different filter on it with Matlab…

Previous Part – Basics here. Next Part – Output here.

Leave a Reply