element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Open Arduino
  • Challenges & Projects
  • Project14
  • Open Arduino
  • More
  • Cancel
Open Arduino
Blog I See in my Magic Ball...Someone is at the Front Door!
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Open Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: makethingstoday
  • Date Created: 14 May 2018 4:11 AM Date Created
  • Views 985 views
  • Likes 5 likes
  • Comments 0 comments
  • arduino_tutorials
  • ardexpert
  • openarduinoch
Related
Recommended

I See in my Magic Ball...Someone is at the Front Door!

makethingstoday
makethingstoday
14 May 2018
image

Open Arduino

Enter Your Project for a chance to win a grand prize for the most innovative use of Arduino or a $200 shopping cart! The Birthday Special: Arduino Projects for Arduino Day!

Back to The Project14 homepage image

Project14 Home
Monthly Themes
Monthly Theme Poll

 

Do you have a home automation system, and would like a simple and unobtrusive way for it to communicate with you?  Would you like that communication to also be an attractive part of your decor?  Have we got a project for you!

 

This project will show you how to build a wifi-connected decoration for your home which is also part of your IoT smart home.  What is detailed here is just one example - how yours looks is limited only by your creativity!

image

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

https://www.youtube.com/watch?v=nAlJKaAYjTw

 

 

What does this thing do?

Normally, when your smart home system does not have any messages for you, the ball just glows different colours.  The colour fades from red to blue to green to red (and all the colours in between) and so on.  It also sends your system regular updates on the ambient temperature and humidity, the light levels, and whether it has detected any movement.

 

When certain events occur, things change (assuming you have configured these functions...we will show you how here).  If your system sends an "alarm" alert, the ball slowly flashes red (fading from black to red and back to black again).  If your phone gets an alert, it will flash blue, and a doorbell will cause it to flash green.

 

If that is not enough to keep you interested, you can switch the ball to manual mode and choose a colour and brightness level.

 

And don't worry about it keeping you up at night either!  When evening comes it turns itself off so you will not go nuts from the glowing lights (you can place multiple magic balls throughout the house).

 

How does this thing work, magic?

Almost!  It uses code written in the Arduino IDE and running on the wifi-capable ESP8266 board.

 

What do I need to build the "Magic Ball":

An ESP8266 Development Board (ie NodeMCU)

image

An RGB LED:

image

A DHT 11 (or DHT22) temperature and Humidity module:

image

A light sensor (light sensitive resistor):

image

A PIR Infra Red motion sensor (D-Sun model used here):

image

Some resistors:

2 100 OHM resistors

1 150 OHM resistors

1 10 KiloOHM resistor (10,000 ohm)

 

Some female jumper wires to connect things up:

image

 

Some heat shrink tubing.

 

Micro USB cable and wall adapter to power the board.

 

A soldering iron and solder.

If you do not want to do any soldering, you can use a small breadboard instead.  Just make sure you have room in your enclosure

 

Something nice to put it all in!  For our example I used a ball and box I found at my local dollar store.  You can really use anything which is the right size and which looks nice lit up (even 3D printed objects!).

 

How do I make it?

Let's start by getting the LED ready.  For this step you will need:

4 pieces of header wire.  i used a red one, green one, blue one, and white (or black) one to make it easier to keep track of which wires lights up which colour.

The 3 resistors.

The RGB LED.

Some heat shrink tubing.

Soldering iron and solder.

 

The RGB LED has 4 leads coming out of it.  The longest one is the common (ground or negative) pin.  If you look at them with the second pin being the long (common) then they will each be:  red, common, green, blue

 

You want to cut short pieces of header wire with a female connector on one end - about 8 cm or so each.  Strip the ends to get them ready to solder.

 

Solder the white wire directly to the common (long) lead.

 

Solder one lead of the 150 ohm resistor to the red lead, and the other end to the red jumper wire.  Do the same for the other 2 colours, but use the 100 OHM resistors for these.

 

Protect you connections with the heat shrink tubing (or electrical tape).  When you are done it should look something like this:

image

 

Next, let's get the light-sensitive resistor ready.

For this you will need:

The photo-resistor

3 Header wires (different colours) - I will use grey, brown, and orange here.

The 10K OHm resistor.

Soldering iron and solder.

Heat shrink tubing.

 

Prep the header wires just like you did for the RGB LED.

 

Solder one end of the grey wire to one lead of both the photoreistor, and the 10k resistor.  Solder each of the other wires to the remaining leads of the photoresistor and resistor.

Here is a simple diagram:

image

In this case the brown is for 3.3V, the grey is the analog output, and the orange is ground.

 

When you are done it should look something like this:

image

 

Now we can hook everything up!

The RGB LED will connect like this:

The white (or black) wire should be connected to a ground (GND) pin on the ESP8266.

The red wire connects to pin D5.

Green connects to pin D6.

Blue connects to pin D8

 

For the photo-resistor:

the grey wire connects to pin A0

The orange wire to another GND pin.

The brown wire connects to a 3V pin (this is 3.3volts).

 

For the DHT11:

+ goes to a 3V pin.

- goes to a GND pin.

out goes to pin D1.

 

Finally, for the PIR:

VCC goes to the VU pin.

GND goes to another GND pin.

out goes to pin D0.

 

You should arrange the sensors in your enclosure so that:

  • The DHT11 and the photo-resistor are on the outside, preferably out the back where it will not be seen.
  • The motion sensor is pointing towards the area you want to track.
  • the RGB LED will light up whatever feature you decided on.

 

Here is how it looks in my example:

imageimage

 

And here is the same hardware in a lamp I found in a thrift store - I gutted the light and put my own stuff in it:

image

 

Next, let's put the firmware on the ESP8266:

If you do not have the Arduino IDE installed with the ESP8266 extensions, follow the instructions here:

Arduino IDE install:

https://www.arduino.cc/en/Main/Software

 

ESP8266 setup for Arduino IDE:

Quick Start Guide to Arduino IDE With NodeMCU ESP8266

 

Once you have that set up, download my firmware here:

https://drive.google.com/open?id=1XFdaD3NfR2Q98Fs1UvdHhbKxA8tI3WAm

 

Load this file in your Arduino IDE and edit the following:

  1. Lines 10 and 11 are where you enter your Wifi name and password.
  2. Lines 13 and 14 have your MQTT user and password
  3. Lines 16 to 26 contain the MQTT topics which need to be adjusted for each ball you hook up (mbr stood for master bedroom...)
  4. Line 37 is where the IP address lives for your MQTT server
  5. You also need to edit line 186.  The "MBedroom" is a unique ID for each ball.  Change this to whatever you want to call it.

 

Make sure you set the correct com port and board in Arduino IDE, and Upload the file to the board.

 

Tada!  If all went well you should have a glowing ball which is slowly changing colour.

 

If you want to add the extra functionality, here are the files I used for OpenHAB2:

https://drive.google.com/open?id=1RlXocLMxUtZlgUaTXwlU2q4FVd5ca9Az

https://drive.google.com/open?id=12XkoreE90kwLGSRHHMnpUdvqSaWALI7p

https://drive.google.com/open?id=1rM06EdycxI6rPsqVtV3t3qOR3-z0azbU

 

Setting up OpenHAB2 is beyond the scope of this blog post, but stay tuned to my channel and there will be a howto coming:

https://www.youtube.com/c/MakeThingsToday

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube