Introduction: HackerBox 0035: ElectroChemistry
This month, HackerBox Hackers are exploring various electrochemical sensors and testing techniques for measuring the physical properties of materials. This Instructable contains information for getting started with HackerBox #0035, which can be purchased here while supplies last. Also, if you would like to receive a HackerBox like this right in your mailbox each month, please subscribe at HackerBoxes.com and join the revolution!
Topics and Learning Objectives for HackerBox 0035:
- Configure the Arduino Nano for use with the Arduino IDE
- Wire and code an OLED module to display measurements
- Construct a breathalyzer demo using alcohol sensors
- Compare gas sensors to perform air quality measurements
- Determine water quality form total dissolved solids (TDS)
- Test contactless and water-submersible thermal sensing
HackerBoxes is the monthly subscription box service for DIY electronics and computer technology. We are hobbyists, makers, and experimenters. We are the dreamers of dreams. HACK THE PLANET!
Step 1: HackerBox 0035: Box Contents
- Arduino Nano 5V 16MHz MicroUSB
- OLED 0.96 128x64 pixel I2C Display
- TDS-3 Water Quality Meter
- GY-906 Contactless Temperature Module
- MP503 Air Quality Pollution Sensor
- DS18B20 Waterproof Temperature Probe
- MQ-3 Alcohol Sensor Module
- MQ-135 Air Hazard Gas Sensor Module
- DHT11 Humidity and Temperature Module
- KY-008 Laser Module
- Set of LEDs, 1K Resistors, and Tactile Buttons
- 400 Point "Crystal Clear" Breadboard
- Jumper Wire Set - 65 Pieces
- MircoUSB Cable
- Exclusive HackerBoxes Decals
Some other things that will be helpful:
- Soldering iron, solder, and basic soldering tools
- Computer for running software tools
Most importantly, you will need a sense of adventure, DIY spirit, and hacker curiosity. Hardcore DIY electronics is not a trivial pursuit, and HackerBoxes are not watered down. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from learning new technology and hopefully getting some projects working. We suggest taking each step slowly, minding the details, and don't be afraid to ask for help.
There is a wealth of information for current, and prospective, members in the HackerBoxes FAQ.
Step 2: Electrochemistry
Electrochemistry (Wikipedia) is the branch of physical chemistry that studies the relationship between electricity, as a measurable and quantitative phenomenon, and a particular chemical change or vice versa. The chemical reactions involve electric charges moving between electrodes and an electrolyte (or ions in a solution). Thus electrochemistry deals with the interaction between electrical energy and chemical change.
The most common electrochemical devices are everyday batteries. Batteries are devices consisting of one or more electrochemical cells with external connections provided to power electrical devices such as flashlights, smartphones, and electric cars.
Electrochemical gas sensors are gas detectors that measure the concentration of a target gas by oxidizing or reducing the target gas at an electrode and measuring the resulting current.
Electrolysis is a technique that uses a direct electric current (DC) to drive an otherwise non-spontaneous chemical reaction. Electrolysis is commercially important as a stage in the separation of elements from naturally occurring sources such as ores using an electrolytic cell.
Step 3: Arduino Nano Microcontroller Platform
An Arduino Nano, or similar microcontroller board, is a great choice for interfacing with electrochemical sensors and display outputs to a computer or video display. The included Arduino Nano module comes with header pins, but they are not soldered to the module. Leave the pins off for now. Perform these initial tests of the Arduino Nano module PRIOR to soldering the header pins the Arduino Nano. All that is needed for the next couple of steps is a microUSB cable and the Nano module just as it comes out of the bag.
The Arduino Nano is a surface-mount, breadboard-friendly, miniaturized Arduino board with integrated USB. It is amazingly full-featured and easy to hack.
- Microcontroller: Atmel ATmega328P
- Voltage: 5V
- Digital I/O Pins: 14 (6 PWM)
- Analog Input Pins: 8
- DC Current per I/O Pin: 40 mA
- Flash Memory: 32 KB (2KB for bootloader)
- SRAM: 2 KB
- EEPROM: 1 KB
- Clock Speed: 16 MHz
- Dimensions: 17mm x 43mm
This particular variant of the Arduino Nano is the black Robotdyn design. The interface is by an on-board MicroUSB port that is compatible with the same MicroUSB cables used with many mobile phones and tablets.
Arduino Nanos feature a built-in USB/Serial bridge chip. On this particular variant, the bridge chip is the CH340G. Note that there are various other types of USB/Serial bridge chips used on the various types of Arduino boards. These chips allow you computer's USB port to communicate with the serial interface on the Arduino's processor chip.
A computer's operating system requires a Device Driver to communicate with the USB/Serial chip. The driver allows the IDE to communicate with the Arduino board. The specific device driver that is needed depends upon both the OS version and also the type of USB/Serial chip. For the CH340 USB/Serial chips, there are drivers available for many operating systems (UNIX, Mac OS X, or Windows). The maker of the CH340 supplies those drivers here.
When you first plug the Arduino Nano into a USB port of your computer, the green power light should come on and shortly after the blue LED should start to blink slowly. This happens because the Nano is pre-loaded with the BLINK program, which is running on the brand new Arduino Nano.
Step 4: Arduino Integrated Development Environment (IDE)
If you do not yet have the Arduino IDE installed, you can download it from Arduino.cc
If you would like additional introductory information for working in the Arduino ecosystem, we suggest checking out the instructions for the HackerBoxes Starter Workshop.
Plug the Nano into the MicroUSB cable and the other end of the cable into a USB port on the computer, launch the Arduino IDE software, select the appropriate USB port in the IDE under tools>port (likely a name with "wchusb" in it). Also select "Arduino Nano" in the IDE under tools>board.
Finally, load up a piece of example code:
This is actually the code that was preloaded onto the Nano and should be running right now to slowly blink the blue LED. Accordingly, if we load this example code, nothing will change. Instead, let's modify the code a little bit.
Looking closely, you can see that the program turns the LED on, waits 1000 milliseconds (one second), turns the LED off, waits another second, and then does it all again - forever.
Modify the code by changing both of the "delay(1000)" statements to "delay(100)". This modification will cause the LED to blink ten times faster, right?
Let's load the modified code into the Nano by clicking the UPLOAD button (the arrow icon) just above your modified code. Watch below the code for the status info: "compiling" and then "uploading". Eventually, the IDE should indicate "Uploading Complete" and your LED should be blinking faster.
If so, congratulations! You have just hacked your first piece of embedded code.
Once your fast-blink version is loaded and running, why not see if you can you change the code again to cause the LED to blink fast twice and then wait a couple of seconds before repeating? Give it a try! How about some other patterns? Once you succeed at visualizing a desired outcome, coding it, and observing it to work as planned, you have taken an enormous step toward becoming a competent hardware hacker.
Step 5: Header Pins and OLED on Solderless Breadboard
Now that your development computer has been configured to load code to the Arduino Nano and the Nano has been tested, disconnect the USB cable from the Nano and get ready to solder the header pins. If it's your first night at fight club, you have to solder! There are a lot of great guides and videos online about soldering (for example). If you feel that you need additional assistance, try to find a local makers group or hacker space in your area. Also, amateur radio clubs are always excellent sources of electronics experience.
Solder the two single row headers (fifteen pins each) to the Arduino Nano module. The six pin ICSP (in-circuit serial programming) connector will not be used in this project, so just leave those pins off. Once the soldering is complete, check carefully for solder bridges and/or cold solder joints. Finally, hook the Arduino Nano back up to the USB cable and verify that everything still works properly.
To wire the OLED to the Nano, insert both into a solderless breadboard as shown and wire between them according to this table:
To drive the OLED display, install the SSD1306 OLED display driver found here into the Arduino IDE.
Test the OLED display by loading up the ssd1306/snowflakes example and programming it into the Nano.
Other examples from the SDD1306 library are useful to explore use the the OLED display.
Step 6: MQ-3 Alcohol Sensor and Breathalyzer Demo
The MQ-3 Alcohol Gas Sensor (datasheet) is a low cost semiconductor sensor which can detect the presence of alcohol gases at concentrations from 0.05 mg/L to 10 mg/L. The sensing material used in the MQ-3 is SnO2, which exhibits increasing conductivity when exposed to increasing concentrations of alcohol gases. The MQ-3 is highly sensitivity to alcohol with very little cross-sensitivity to smoke, vapor, or gasoline.
This MQ-3 module provides a raw analog output relative to alcohol concentration. The module also features an LM393 (datasheet) comparator to threshold a digital output.
The MQ-3 module can be wired to the Nano according to this table:
Demo code from video.
WARNING: This project is merely an educational demonstration. It is not a medical instrument. It is not calibrated. It is not intended, in any way, to determine blood alcohol levels for evaluation of legal or safety limits. Don't be stupid. Don't drink and drive. Arrive alive!
Step 7: Detecting Ketones
Ketones are simple compounds that contain a carbonyl group (a carbon-oxygen double bond). Many ketones are important in both industry and biology. The common solvent acetone is the smallest ketone.
Today, many are familiar with the ketogenic diet. It is a diet based on consuming high-fat, adequate-protein, and little carbohydrates. This forces the body to burn fats rather than carbohydrates. Normally, the carbohydrates contained in food are converted into glucose, which is then transported around the body and is particularly important in fueling brain-function. However, if there is little carbohydrate in the diet, the liver converts fat into fatty acids and ketone bodies. The ketone bodies pass into the brain and replace glucose as an energy source. An elevated level of ketone bodies in the blood results in a state known as ketosis.
Example ketone sensing project
Another example ketone sensing project
Comparing MQ-3 vs. TGS822 gas sensors
Step 8: Air Quality Sensing
Air pollution occurs when harmful or excessive quantities of substances including gases, particulates, and biological molecules are introduced into the atmosphere. Pollution may cause diseases, allergies, and even death to humans. It may also cause harm to other living organisms such as animals, food crops, and the environment in general. Both human activity and natural processes can generate air pollution. Indoor air pollution and poor urban air quality are listed as two of the world's worst toxic pollution problems.
The MQ-135 is sensitive to methane, nitrogen oxides, alcohols, benzene, smoke, CO2, and other molecules. It's interface is identical to the MQ-3 interface.
The MP503 is sensitive to formaldehyde gas, benzene, carbon monoxide, hydrogen, alcohol, ammonia, cigarette smoke, many odors, and other molecules. It's interface is quite simple, providing two digital outputs to designate four levels of pollutant concentrations. The default connector on the MP503 has a plastic shrouded male header, which can be removed and replaced by a standard 4-pin header (provided in bag) for use with solderless breadboards, DuPont jumpers, or similar common connectors.
Step 9: Water Quality Sensing
TDS-3 Water Quality Tester
Total Dissolved Solids (TDS) are the total amount of mobile charged ions, including minerals, salts, or metals dissolved in a given volume of water. TDS, which is based on conductivity, is expressed in parts per million (ppm) or milligrams per liter (mg/L). Dissolved solids include any conductive inorganic element present other than the pure water molecules (H2O) and suspended solids. The EPA Maximum Contaminant Level of TDS for human consumption is 500 ppm.
Taking TDS Measurements
- Remove the protective cap.
- Turn the TDS meter on. The ON/OFF switch is located on the panel.
- Immerse the meter into the water/solution up to the max. immersion level (2”).
- Lightly stir the meter to dislodge any air bubbles.
- Wait until the display stabilizes. Once the reading stabilizes (approx. 10 seconds), press the HOLD button to view the reading out of the water.
- If the meter displays a flashing ‘x10’ symbol, multiply the reading by 10.
- After usage, shake off any excess water from your meter. Replace the cap.
Source: Full Instruction Sheet
Experiment: Construct your own simple TDS meter (project with video here) which can be calibrated with, and tested against, the TDS-3.
Step 10: Thermal Sensing
GY-906 Contactless Temperature Sensor Module
The GY-906 thermal sensing module is equipped with an MLX90614 (details). This is a simple-to-use, but very powerful single-zone infrared thermometer, capable of sensing object temperatures between -70 and 380°C. It uses an I2C interface to communicate, which means you only need to devote two wires from your microcontroller to interface with it.
Demo thermo-sensing project.
Another thermo-sensing project.
DS18B20 Water Proof Temperature Sensor
The DS18B20 one wire temperature sensor (details) can measure temperature from -55℃ To 125℃ with an accuracy of ±5.
Step 11: HACK THE PLANET
If you have enjoyed this Instructable and would like to have a cool box of hackable electronics and computer tech projects descend upon your mailbox each month, please join the revolution by surfing over to HackerBoxes.com and subscribing to receive our monthly surprise box.
Reach out and share your success in the comments below or on the HackerBoxes Facebook Page. Certainly let us know if you have any questions or need some help with anything. Thank you for being part of HackerBoxes!