Go organic with your Arduino
Shrinking your Arduino projects isn’t difficult with plenty of cool options, including tiny breadboards and even smaller OLED display panels. Darren Yates explains how.
Arduino is a great platform for learning digital electronics and building your own tech. We’ve used the Arduino Uno for many projects and it’s one of the most recognisable microcontroller board designs around. But to shrink your projects down, the tiny Arduino Nano is hard to beat. Featuring all the same tech as its larger sibling, the Nano is a 30-pin dual in-line package (DIP) module ideal for breadboards, even incredibly tiny breadboards. But it’s the recent arrival of even smaller OLED display panels that can really spark up your projects.
WORLD’S SMALLEST WEATHER STATION?
To show just how small and cool this tech is, we’ve combined them all to build what we think might be the world’s smallest weather station display. All you need is an Arduino Nano, a 170-point breadboard, a 128 x 64-pixel I2C OLED panel, a DHT22 environment sensor, a 4-pin-tall female header, two wire links and our free source code. It looks simple, but it includes some old-school electronics tricks that cut down the component count. Here’s how it works.
INTER-INTEGRATED CIRCUIT
The particular OLED panel we’ve chosen has just four connection pins and only two of these are needed for data. It uses a 35-year-old communications protocol developed by Philips Semiconductor called ‘InterIntegrated Circuit’ or I2C. The Arduino Nano supports I2C on its analog pins A4 and A5. To light up, the OLED panel also needs 5VDC and 0V (ground) on its remaining two pins and this is where the first of our old-school tricks comes in. We’ve connected the OLED panel to the Nano’s pins A4, A5, A6 and A7. However, A6 and A7 can only be used as analog inputs, and because they’re inputs, they have a high resistance or ‘high impedance’. This means we can get a little creative and re-route the 5V and GND pins to A6 and A7, respectively, using a couple of wire links and power the OLED panel. By doing this, we can add in a 4-pin-tall female header connector, plug in the OLED panel into the connector and lift it up and back over the Arduino Nano.
A couple of important tips — the OLED panel you buy should have only four pins, labelled GND, VCC, SCL and SDA. There are similar panels with seven connection pins — these use the Arduino’s Serial Peripheral Interface (SPI) and they won’t work in this configuration. Also, when buying the Arduino Nano, go for one that has the PC pins already soldered — otherwise, you’ll have to break out a soldering iron and solder them in place yourself, which is a pain.
DHT22 SENSOR
To get temperature and humidity data, we pull in our old-favourite, the DHT22 environment sensor, which we’ve used on previous occasions. It’s a four-pin device — two for power (5V and 0V), one for data and one that does absolutely nothing. The DHT22 needs power, but you’ll see we’ve just plugged it straight
into the Nano’s digital I/O pins D3, D4, D5 and D6, and this time, we’ve used no wire links to route power in. Here’s where our second old-school trick comes in. Because the DHT22 consumes no more than 3-milliamps (mA) of current, we can actually power it by turning digital pins D3 and D6 into power pins. All we do is code these pins as ‘outputs’, set D3 ‘high’ to supply 5V and D6 ‘low’ to acts as a pseudoground. The Arduino’s digital pins can source or sink up to 40mA of current, so the 3mA of current the DHT22 needs presents no problem. By using this trick, we can simply plug the DHT22 sensor straight into the breadboard on the same pin rows as the Arduino Nano’s D3, D4, D5, D6 pins and bingo — it’s powered and off it goes.
As a rule-of-thumb, using digital outputs as pseudo-power supply pins works provided the current you need is considerably less than the digital outputs can handle. In this case, 3mA is more than ten-times less than the digital output’s 40mA limit, so we’re sweet. Even better, by placing the DHT22 sensor on the breadboard edge, it acts as a wall for the OLED panel to lean against, stopping the panel’s underside from shorting against the Arduino Nano.
170-POINT BREADBOARD
The whole project plugs into a tiny 170-point breadboard — they’re brilliant and perfect for the Arduino Nano. These breadboards have 17 rows of ten pins split down the long axis into two separate groups. They come in a range of colours with a sticky backing to bind them to another surface. Use the overlay diagram to guide your build.
POWER REQUIREMENTS
If you own an OLED smartphone or TV, you’ll know that OLED panels have brilliant viewing angles that leave LCD panels for dead. But there’s an added benefit here — the 128 x 64-pixel panel we’re using consumes no more than 40mA of current, total, with every pixel lit up. In normal operating, our whole Mini Weatherstation project draws no more than 40mA. All you need to do is plug in a MiniUSB cable between your PC and the Arduino Nano and up it comes.
GET THE SOURCE CODE
You’ll find the source code for this project at apcmag.com/magstuff. Download the zip file, unzip it and copy the contents of the libraries subfolder into the same of your Arduino IDE. Don’t have the IDE? Get version 1.6.9 from arduino.cc.
Load the MiniWeatherstation.ino source code into the Arduino IDE, plug in your Arduino Nano, flash the source code and you’re away. Look through the source code to learn how the SSD1306 OLED driver chip and DHT22 sensor work. Using the Adafruit_SSD1306 OLED and Adafruit_GFX libraries, commands to print text and draw graphics on the panel are easy to understand. It takes a bit more work, but we’ve even programmed the APC logo on the app’s splash screen.
MAKE SOMETHING!
The Internet of Things craze is making electronics cool again and Arduino makes it easier than ever to build your own IoT devices and projects. Digital tech has plenty of answers for today’s design problems, but there’s plenty of scope for bringing back old-school electronics skills to make things smaller, simpler and easier.
So what are you waiting for? Get out there and building something!