Introduction: Dual Voltage Generic Data Logger Arduino
I have been struggling with building a 'generic' 'minimalist' data logger Arduino for quite some time. When I say 'generic' I don't want to build it for a particular sensor, rather want to use a variety of them - alone or in combination. And when I say 'minimalist' I don't want to use too many components and ICs.
SD card which is at the core of the project comes as a bit of a challenge here, because at 5V most SD/MicroSD cards will fry after some time. SD breakout boards from reputed manufacturers are equipped with adequate logic level shifting (5V to 3.3V), but cheaper ones gathered some bad reputations in this respect. I have thought of two solutions - (1) using logic level shifter IC, or (2) powering my ATmega at 3.3V. By experimenting I have discovered that 3.3V powered ATmega outputs 3.3V when a pin is set to HIGH (quite reasonably, where will it get 5V?). But then again, there are some sensors which require 5V; at 3.3V they don't quite wake up. So, I built a dual voltage power circuit for Arduino (please see my previous Instructable here). This Arduino project is built on top of that power circuit.
I have made some unusual adjustments in this project which I am going explain in later sections.
Step 1: Bill of Materials
1) ATmega328P microcontroller - 1
2) Male and Female headers clipped into different sized
3) Connecting wires
4) PC jumper - 1
5) Dual-voltage power circuit already built on strip board (from my previous Instructable)
Step 2: Design
Here goes the design of connections on the strip board. For your convenience I have color-coded the strips and wires, and defined them on the legend. Also attached is a strip board friendly schematics, again in different colors. Don't let yourself get intimidated by the apparent clumsiness or complexity of the design, please bear with me - I am going to break it down into functional segments in later sections.
Step 3: Power Rail
In this segment I have created two sets of power rails on either ends of the strip board, mimicking a project board. Each rail has 5V, 3.3V and ground lines.
Step 4: Microcontroller
This segment shows placement and powering of a bare-bone ATmega328 microcontroller. I am 'minimalist' in this project, so I am not using crystal-capacitor or resonator as an external clock source. That means I am clocking the chip at 8MHz using its internal clock, and using an appropriate bootloader.
Step 5: Ports - Exposing Pins
1. ISP port: ATmega pins 16, 17 & 18 (digital pin 11, 12 & 13) in combination with pin 0 (Reset) will be used to download sketches using a proper Arduino. Digital pins 11, 12 & 13 will be connected to Arduino's 11, 12 & 13 respectively, and the RESET will be connected to Arduino's digital pin 10. Since I am using a 8MHz ATmega configuration, I don't need a capacitor at the RESET pin (I don't know why, but I do use this often). This port allows me to program my board without removing the IC.
2. At the top left, I have exposed two analog pins (A4 & A5), and a 5V power. I can use this port for attaching LM35 temperature sensor, DHT11 Humidity & temperature sensor, or 18BS20 digital temperature sensor. In fact I can attach anything which needs only one data pin and 5V power. One analog pin will be designated as GND, a 'software ground' if you like. To achieve 'software ground' I will write the following code in the sketch-
pinMode(sensorGnd, OUTPUT); //must be OUTPUT, not INPUT
digitalWrite(sensorGnd, LOW) //ready to sink return current, <25mA
3. At the top right side is an 8 pin header for attaching a MicroSD breakout board. This breakout board does not have any additional circuit, it just exposed the 8 pins of the MicroSD card through 8 breadboard friendly pins (see photograph). Since ATmega is powered at 3.3V, SD card will get only this much voltage at any time, and I assume, I don't need a logic level shifter.
4. A 4 pin port at the upper-middle and another at the lower-right will be used to connect LCD character display. These two ports are compatible with my earlier design - LCD character display breakout (please see this Instructable for details). To use LCD display using these ports I will include the following lines of code-
static const int RS=14, EN=15, DB4=5, DB5=6, DB6=7, DB7=8;
LiquidCrystal lcd(RS, EN, DB4, DB5, DB6, DB7);
6. Next to RESET pin Tx/Rx pins exposed for connecting to serial in/out.
Step 6: Putting Things to Work
And here I get this board with dual voltage power supply, on-board programming ability, flexible multi-sensor connectivity, MicroSD card slot, TTL and other things I wanted.