The Embedded Arduino (smart Appliances)
by sspence in Circuits > Arduino
33653 Views, 84 Favorites, 0 Comments
The Embedded Arduino (smart Appliances)
From the minds at http://arduinotronics.blogspot.com/
Free Arduino Kit Contest! Comment (constructively) and we will enter you in our "Win a free DIY Arduino Kit" Contest!
One of the fun things to do with an Arduino is to make your appliances smarter. From better instrumentation, to giving the appliance the ability to make decisions based on sensor input, to centralized or remote monitoring (Smartphones, etc.) and data logging, your fridge, microwave, stove, HVAC, home alarm system, etc., is ready to be Arduino-ized.
Anyone can buy an Arduino board ($30-$60 or so) and stack shields on it, but sometimes building the Arduino and the project on a single board is preferable. We will show you how to prototype a complete project on a solderless breadboard, and then move it to a protoboard for posterity.
We will be using a 840 tie point solderless breadboard, and a matching protoboard. This way all the tie points are labeled the same, and the physical layout is the same, making the transitional painless.
A list of parts can be found at Parts List
Breadboarding
Building the Arduino
We are using Yellow wire for + connections, and black for - connections. Typically you would use red for +, but we were out of red.
Parts Needed:
Qty (1) Atmel 328/328P with Bootloader installed
Qty (2) 22pF capacitors (non-polarized)
Qty (1) 10k ohm resistor
Qty (1) 16 MHz crystal
Qty (1) reset switch
Update:
Qty (1) 10 uH inductor
Qty (1) 100nF capacitor (non-polarized)
See Arduino Parts
Begin by placing the Atmel 328 on the breadboard. Pinouts and schematic provided below.
Now add the components:
10k Resistor - Pin 1 + Rail
22pF Capacitor - Pin 9 to - Rail
22pF Capacitor - Pin 10 to - Rail
Crystal - Pin 9 to Pin 10
Reset Switch - Pin 1 to - Rail (check orientation with ohmmeter)
Update: See updated schematic for pin 20 (AVCC) connection.
100nF Capacitor - Pin 22 to Pin 20
10uH Inductor - Pin 7 to Pin 20
Finish by connecting Pin 7 to + Rail, and Pins 8 & 22 to - Rail.
Building the Power Supply
MB102 MB-102 Breadboard Power Supply Module 3.3V/5V For Arduino Board
In this step, we will be building a 7805 based voltage regulator. You could also add a 3.3v regulator as well. We may add this function later.
You will need:
Qty (1) 7805 5v Voltage Regulator
Qty (2) 10uf Electrolytic Capacitors
Qty (1) 7-12vdc power pack (wallwart)
Qty (1) 2 position terminal strip or a alternative power connector. You could connect the wires from the wallwart directly to the breadboard.
Add the components:
On the 7805, Pin 1 is on the left, with the label facing you and the pins pointed down.
On the capacitor, - has a stripe down the side, the other leg is +.
7805 5v Regulator; Pin 1 to Power in, 7-12vdc
7805 5v Regulator; Pin 2 to - Rail
7805 5v Regulator; Pin 3 to + Rail
10 uf capacitor; + to + Rail, - to - Rail
10 uf capacitor; + to Regulator Pin 1, - to - Rail
Power in Terminal strip; + to Regulator Pin 1, - to - Rail
Communicating With the Arduino
To upload sketches and communicate with the Arduino from the PC, we need an interface. We use a FTDI interface, which comes in cable or module forms.
The main advantage of the module is the RX/TX lights, though some cables may include this.
The particular interface we have is a blue Mini USB FTDI interface, similar to the Official Arduino Revised Mini USB Adapter. We need to Connect FTDI RTS (DTR on other models) to Pin 1 of the Atmel 328 through a 100nF (.1uF) capacitor. This will enable the auto reset on sketch uploads. We also need to connect FTDI TX to TX (I know, sounds odd, but it is what it is) on the Atmel 328 Pin 2, FTDI RX to RX on the Atmel 328 Pin 3, and FTDI GND to Atmel GND. We will not connect 3.3v or 5v as we use a separate power supply.
To talk to our DIY Arduino, we pick Duemilanove 328 as the board.
Burning a Bootloader
The Atmel 328-PU and the Atmel 328P-PU are slightly different. The 328P-PU, found on the official Arduino boards, is a low power consumption version, and has a different chip signature than the 328-PU. We got hold of the 328-PU's so we had to do some software fiddling to be able to upload the bootloader. Once the bootloader is installed, they work the same.
Now that you have your DIY Arduino built, connect it to a Duemilanove as follows. This method will not work with the newer Arduino UNO, but there are methods for that as well, which we have not been able to test yet. Depending on which method/bootloader you burn, that will determine what board you specify in the future when uploading sketches.
Connections:
Duemilanove -> DIY Arduino
Pin 10 -> Pin1
Pin 11 -> Pin 17
Pin 12 -> Pin 18
Pin 13 -> Pin 19
Gnd -> Gnd
We will not connect power, as we already have power on the DIY Arduino.
Adding the Project
The project we will be adding to this board is a Temperature & Humidity Sensor. We will be using the DHT-11 Module, and displaying the output on a LCD. I connected S (signal) to pin 4 (Arduino digital pin 2), - to Gnd, and + to 5vdc.
Component:
DHT-11
- to - Rail
+ to + Rail
S to Pin 4 (Arduino D2)
I downloaded the library and uploaded my modified sketch per the instructions at http://arduinotronics.blogspot.com/2013/01/temperature-and-humidity-redux.html
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
// Fahrenheit conversion added by Steve Spence, http://arduinotronics.blogspot.com
#include "DHT.h"
#define DHTPIN 2 // what pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Connect pin + (middle) of the sensor to +5V
// Connect pin S (on the right) of the sensor to whatever your DHTPIN is
// Connect pin - (on the left) of the sensor to GROUND
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println("DHTxx test!");
dht.begin();
}
void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t*1.8+32);
Serial.println(" *F");
}
}
After uploading, you will be able to see the output in your serial monitor.
Adding a LCD
Rather than have a computer connected to read the serial output, I'm adding a LCD to display the Temperature and Humidity. This will require a few changes to the code, and of course more connections. Remove LCD when burning a bootloader.
Parts needed:
LCD Module for Arduino 20 x 4, White on Blue
Connect per the attached schematic, using the Arduino pin to Chip pin map provided.
Code changes are as follows:
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
// Fahrenheit conversion and LCD code added by Steve Spence, http://arduinotronics.blogspot.com
#include
// Connections:
// rs (LCD pin 4) to Arduino pin 7
// rw (LCD pin 5) to Arduino - Rail
// enable (LCD pin 6) to Arduino pin 8
// LCD pins d4, d5, d6, d7 to Arduino pins 9, 10, 11, 12
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
#include "DHT.h"
#define DHTPIN 2 // what pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Connect pin + (middle) of the sensor to +5V
// Connect pin S (on the right) of the sensor to whatever your DHTPIN is
// Connect pin - (on the left) of the sensor to GROUND
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println("DHTxx test!");
dht.begin();
}
void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t*1.8+32);
Serial.println(" *F");
// lcd code
lcd.begin(20,4); // columns, rows. use 16,2 for a 16x2 LCD; 20,4 for a 20x4 LCD.
lcd.clear(); // start with a blank screen
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print("Humidity"); // change this text to whatever you like. keep it clean.
lcd.setCursor(0,1); // set cursor to column 0, row 1
lcd.print(h);
lcd.print((" %\t");
lcd.setCursor(0,2); // set cursor to column 0, row 2
lcd.print("Temperature:");
lcd.setCursor(0,3); // set cursor to column 0, row 3
lcd.print(t*1.8+32);
lcd.print(" *F");
}
}
Requesting a Temperature
Since we now know what the temperature is, why don't we build a thermostat by adding a potentiometer to "Request" a particular temperature we want, and a set of relaysor SSR's to control heat and air conditioning to meet that request?
These additions are addressed in the following two articles:
http://arduinotronics.blogspot.com/2012/03/arduino-thermostat.html
http://arduinotronics.blogspot.com/2013/01/working-with-sainsmart-5v-relay-board.html
Moving to a Protoboard
Parts needed:
840 Point Bread Board PCB Phenolic 2 1/8×6 5/8 in (55×168 Mm)
All you need to do is move the connections and components over from the solderless breadboard to the protoboard, using the same hole labels, or build a second one following the first as a template. Have Fun!