This project contains a firmware and an Ionic app to control one or more relays from an Android device.
If you need to control a lamp, open your garage or control your sprinkler valve to water your lawn, this project offers a way to do that from your phone with an easy to use app provided.
Few years back I got hooked in the world of hybrid apps and specifically the Ionic Framework.
It took me a while to ramp up and be able to do something interesting with it. Understanding the concepts involved in asynchronous JavaScript/Typescript apps (web or anything else) was a bit different to what I was used to, let alone dealing with promises and observables in Angular.
Anyway, I decided to create this firmware and an Ionic app that goes along. And what better time to share it with everyone than now that the new Particle Mesh devices are out!
The appWhile it deserves a write up on its own, in the meantime know that it's built with Angular, HTML and CSS. All those things get combined beautifully in Ionic.
The app can run on your Android device (phone or tablet) and it looks like this:
To control your relays, swipe your finger left on top of the relay you want to control to expose the buttons menu, and hit the on, off or pulse buttons.
Hitting the pulse button will turn on the relay for a number of milliseconds. This can be changed in the firmware.
AnimationsThe app contains a couple of animations made with Lottie.
What is Lottie? From their page:
Lottie is an iOS, Android, and React Native library that renders After Effects animations in real time, allowing apps to use animations as easily as they use static images.
Another definition:
Lottie is a mobile library for Web, and iOS that parses Adobe After Effects animations exported as json with Bodymovin and renders them natively on mobile!
Thanks to an Angular library called ng-lottie, we can use them on our Ionic apps.
And after many hours in Adobe After Effects, the results can be pretty cool.
Boards testedThese are the boards tested:
- a Particle Argon plus an Adafruit Power Relay FeatherWing
- a simple relay connected to a Particle Photon or Electron
- a 4 relays NCD board with a Particle Photon, Argon or Electron
- a Particle relay shield with a Photon or Argon
Theoretically, there is a large number of boards one can use with this project:
- any Particle Mesh device coupled with an Adafruit Power Relay FeatherWing may run this firmware
- a Particle relay shield with an Electron
- any 3v3 relay and a Photon, Bluz or even a RedBear Duo
- NCD boards with 1 or up to 24 relays!
STEP 1: Assemble your relay board. Depending on the one you choose you may have some soldering to do.
STEP 2: Customise the firmware. You can grab the myRelays.ino firmware from the git repo or import it in Particle Build with this link.
If you are using an NCD relay board, please configure the firmware to have the following lines like this:
#define USE_NCD_BOARD
// #define USE_PARTICLE_RELAY_SHIELD
// #define USE_SINGLE_RELAY
In the case of a Particle relay shield:
//#define USE_NCD_BOARD
#define USE_PARTICLE_RELAY_SHIELD
//#define USE_SINGLE_RELAY
Or if you are using a simple relay connected to any digital output of your Particle device, they should look like this:
//#define USE_NCD_BOARD
// #define USE_PARTICLE_RELAY_SHIELD
#define USE_SINGLE_RELAY
You can connect the simple relay to the digital output specified by this line in the firmware:
#define MY_RELAY D0
Tip: You can configure D7 in that line above to play with the on-board led!
Note: remember that the relay you connect to your device must be a 3.3 volts input relay. A 5 volts relay may not work at all.
STEP 3: Flash the firmware on your device.
STEP 4: Install the app on your Android device. While I get it through the Google Play process of publishing an app, you can enjoy it right away from this link on My Google Drive.
https://drive.google.com/open?id=1gDtPCCMrsC1XqkncBsZ6TSnjZ-_HVhx-
Or this one:
https://drive.google.com/open?id=1PzttxUgnq6oM-B_5HgqcN997liEv6tLa
I have tested this apk on a Nexus 5 and a Pixel 2.
Note: there is some sort of magic with these apk files that I'm trying to figure out. Leave me a note below if you run intro trouble while installing it.
UPDATE: the app is live now and you can find it here:
https://play.google.com/store/apps/details?id=io.gusgonnet&rdid=io.gusgonnet
STEP 5: configure your Particle Access Token and Device ID in the app Settings:
STEP 6: Hit the Done button at the bottom and go back to the Relays screen. Your relays status should refresh automatically!
Final notesSince the app stores the Particle Access Token on the Android device in order to communicate with the Particle Cloud and your Particle device, it is recommended that this app is only used on Android devices you own.
Need help?If you require professional help with your projects, don't hesitate to write me a line about your needs at gusgonnet@gmail.com. Thank you!
Check the rest of my projects here!
Comments