A SmartLiving Experiment to warn you when your Smartphone is removed from the charger.
Using an Android Smartphone and battery power detector, we'll sense if the phone has been plugged or unplugged at the power supply. As a trigger we use an Arduino with a vibration motor to warn you.
The Building Plan
All Ingredients you need for this project can be found in the SmartLiving IoT starter kit for Arduino.
- Attach Grove shield on the Arduino Ethernet
- Connect the Grove vibration motor to the D8 Grove connector on the shield
- Connect the ethernet cable to your Arduino
- Connect the power supply to the mains and your Arduino board
- Connect the Arduino to your computer using the USB2Serial adapter and USB cable
Type in a caption
Create Your Device
Next, we create a device in the SmartLiving cloud which represent the Arduino.
SmartLiving provides you a freemium account for your hobby projects. You can sign up your account on http://beta.smartliving.io. After you have create your account :
- Log in in the SmartLiving Web App
- Click on the Devices icon in the Left menu
- Click on the “+” sign on the right side of the window to create a new device
- Enter a valid Device name. The device is now created
When you click on your device, on the right side of the screen, you will see yourDevice Id, Client Id and Client Key which you will need to enter these in your Arduino sketch.
Upload the Arduino sketch
Download the SmartPhone_unplugged_detector sketch in the experiments folder in the arduino-client on Github.
Download it here (https://github.com/allthingstalk/arduino-client).
- Replace the text between Quotes with your Device Id, ClientId and ClientKey
Test your Arduino setup
It’s time to test the first part of the experiment. Head over to the web app:
- Click on the ‘Alerter’ asset
- You should see a widget representing a toggle button. When you change the position of the toggle button, the vibration motor should turn ON and OFF
Download & Configure the Android SmartLiving Makers App
The SmartLiving Makers App turns your Smartphone into an IoT device. The App includes a service which sends and receives data from assets on your Android device to the SmartLiving Cloud, as with the Arduino.
The App allows you to configure assets which are physically present on your smartphone, as well as virtual assets which are software based. For this experiment we will just use the BatteryPower asset.
For more information about the SmartLiving Makers Mobile App and how to install check out the Android getting started guide.
Configure an automation rule between the Arduino and Android
The last part of this experiment we will create an automation rule which will trigger the vibration motor asset on the Arduino when the BatteryPower asset on the Android changes to false.
Test the experiment
It’s time to test the experiment. Unplug your Android device, the vibration motor will now start spinning. When you plug the power back to your Android it will stop spinning.
Did it work? Yes? Great! You just built your own IoT project!




Comments