IoT Magical Wand
Introduction
During our childhood days, we would have fantasized to perform magic using the wand in the hand of a magician. When the magician rotates the wand and says 'Abracadabra', magic happens! This IoT Magical Wand project is inspired by this and it is actually that dream come true. Using this IoT Magical Wand you can control your home appliances. You can turn them ON or OFF by rotating this magical wand or tilting it towards a particular direction. Then say 'Abracadabra' for the magic to happen!? Not really, you have to spell it. IFTTT, Arduino MKR1000, Node MCU, Arduino UNO, thinger.io, and relay module are all the magical elements required to perform this magic. What's more! You can use the same setup (the smart relay system particularly) and control your home Appliances using Amazon's Alexa. Should you say 'Abracadabra' to Alexa then? No, you have to say the magical words as follows: Alexa, trigger turn ON the light to turn ON the light bulb connected to the relay.
The Magic!
Below is the video describing from the materials required to the final outcome of the IoT Magical Wand project.
How did the magic happen?
IoT Magical Wand - The Arduino MKR1000 monitors the position of the magical wand. This is achieved through the accelerometer connected. The wand is activated by inverting it upside down and placing it in that position for a count of 5. To turn it OFF do the same again or continue for 5 more counts. Only if it passes this condition, the system will start to monitor the change in the position of the wand, other than the upside down position. I have configured three positions and this will make a respective IFTTT web request. For instance, if I tilt the wand towards left that will turn ON a particular relay. You can now tilt the wand to another side and turn ON another relay. If you again comeback and tilt towards left, the system will remember that it has sent a turn ON request and will now turn it OFF. So based on the position of the wand, Arduino MKR1000 will make a corresponding IFTTT web request which will, in turn, make a web request to thinger.io connected Node MCU. The Node MCU will then serially communicate this with Arduino UNO to turn ON/ OFF the respective relay. When there is a request made, the LEDs mounted inside the top head of the wand will blink in a rotating pattern to show that the magic has happened!
You can find instructions for connecting Node MCUs to thinger.io IoT Platform here - Steps for connecting Arduino MKR1000 with thinger.io for reading temperature data. These instructions are intended for Arduino MKR1000 but it is the similar process for Node MCUs as well. If you have any difficulties let me know in the comments section below.
Alexa - You can also replace the magical wand and use Alexa to make a web request to IFTTT. This will then trigger the Node MCU and turn ON/ OFF the respective relay.
List of Hardware and Software Required
Below is the list of hardware and software required to make your own IoT Magical Wand. Click on the names in order to be directed to the site where you can buy or access the resource.
Hardware
- Arduino MKR1000
- Node MCU
- Arduino UNO
- Four Channel Relay Module
- Accelerometer(ADXL335)
- LEDs
- Resistors
- Header pin and stripboard
- 3.7V LiPo Battery
- 2-pin JST connector
- Few Jumper wires and Solid core wires
- Amazon Echo Dot (Optional)
Software
Circuit Connection
Below is the circuit connection diagram between the Arduino MKR1000, accelerometer and LEDs placed inside the IoT Magical Wand.
Below is the circuit connection diagram between the Node MCU, Arduino UNO, and relay which will together be the Smart Relay System.
Code
The code for the various MCUs used in the IoT Magical Wand project is provided below. For GitHub repository page, click here.
Conclusion
I enjoyed making this project and hope will interest you the readers as well. If you happen to make a similar project do let me know in the comments section below. The challenges/ difficulties to quote here as I conclude this project are
- The IFTTT web requests not happening while using Node MCU. Arduino MKR1000 successfully triggers IFTTT but the request to Node MCU is not successful and you are returned with an 'Error: ETIMEDOUT' message. I never faced this issue when I used an Arduino MKR1000. Since I had only one Arduino MKR1000 at my disposal I had to use Node MCUs.
- Also, the Node MCUs did not stay connected in thinger.io as well. The connection was unstable. This is also not there in the case of Arduino MKR1000.
- Another challenge to say would be the LiPo battery connected to Arduino MKR1000. The charge LED in Arduino MKR1000 at times will not turn ON even if your battery is charging. This, as I read in some Arduino forums, seem to be the as-is charging mechanism of Arduino MKR1000.
- Also, you never know whether or not your Arduino MKR1000 is running the program while on battery since the power LED will not turn ON. So I used the built-in LED to indicate that the program is running by blinking it.