Introduction: Miniature Smart House
This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com).
I'm with the Make Course at the University of South Florida. My project is the Smart House in which an app on an iPhone controls the various parts of the miniature house through Bluetooth. The video explains my project in more detail. The lamp can turn on and off, the radio can play a tune, and the door can open and close.
Hope you enjoy this tutorial!
Step 1: Gather Materials!
1. Arduino Uno
2. Arduino Micro (convenient for its small size to fit on a breadboard, but could use any Arduino)
3. Bluefruit LE Module
4. Micro servo
6. 220 Ohm resistor
7. Speaker (I used a 0.25 Watt, 8 Ohm speaker but you could use a higher wattage for higher volume)
Step 2: Modeling and 3D Printing
First you should envision what you want your house to look like. I chose the small size of my house for presentation purposes in the class, but you could create a full size doll house!
I created the models for the lamp, radio, door, and table in Autodesk Inventor. I then 3D printed these on a Makerbot Replicator.
If you are familiar with 3D modeling software feel free to model the various parts of your house! If you would like to learn, I would suggest downloading Inventor, which is free for students at this link. If you just want to go straight to 3D printing you could find parts for your house at thingiverse.com or grabcad.com.
Step 3: Wire the Circuit
In the Fritzing schematic you can see how to wire circuit on a breadboard.
For the BLE controller, adafruit describes how to connect it to the Arduino Uno here.
In this circuit I am powering the Micro using the Uno. This is done by connecting the 5V pin on the Micro to the 5V line from the Uno and connecting the GND pin on the Micro to the GND line from the Uno.
Pin 3, 4, and 5 on the Uno are the output pins that the Adafruit app controls. On the app, pin 3 controls the LED, pin 4 controls the speaker, and pin 5 controls the door. Setting these pins will activate the interrupts in the code (see next step). Use a 220 ohm between pin 3 and the LED to limit the current flowing through the LED. Pin 11 on the Micro is the output pin to control the door. Pin 12 on the Micro is the output pin to control the speaker.
Step 4: Program the Arduino
First program the Arduino Uno with the StandardFirmata example sketch provided by Adafruit.
I have attached the files I created for this project. Make sure to add the House.h, House.cpp, and pitches.h as tabs in the Main_Code sketch. The sketch should be uploaded to the Arduino Micro.
I created the library house, which consists of House.h and House.cpp.
The header file creates the class by defining the constructor, the functions to be used in the Main_Code.ino file, and the variables used in the House.cpp file.
The CPP file defines what each function does when it is called in the Main_Code.ino file. First in this file you will see the arrays melody and note durations, these are used by the playtune() function. I copied this function from garagelab.com, the definitions for the notes are in pitches.h. The constructor assigns the pins for the device and sets the output pin as an output and the input pin as an input. The openDoor() and closeDoor() functions control the servo attached to the door. The playTune() and silent() control the speaker output.
In the Main_Code.ino, first I defined the pins for the door, buzzer and interrupts. The interrupts are based on a change in voltage on the input pins. This voltage is changed when you change the pin output in the Adafruit app. The door function keeps track of the previous status of the door input pin voltage so if the door was previously closed, changing the voltage will open the door and vice versa. The buzzer also keeps track of the buzzer input pin voltage so if the buzzer was previously off, the tune will play and if the buzzer was previously playing, the buzzer will be silenced. Note: The playTune() function is called when the prevBuzzer flag is set to 1 and it is checked in the main loop. It needs to be in the main loop so the delays in playTune() will be in effect. Delays do not run in an interrupt. The Serial.println() statements are included for debugging purposes.
Step 5: Customize
You could add a ceiling fan, a thermostat, or a security camera. Make it your own, be creative!
If you have any questions, please leave comments!
We have a be nice policy.
Please be positive and constructive.