4-Way Alerter

by lmbagdade in Circuits > LEDs

169 Views, 1 Favorites, 0 Comments

4-Way Alerter

Screenshot 2023-01-30 19.01.57.png
Screenshot 2023-01-29 7.55.18 PM.png
Screenshot 2023-01-29 7.55.39 PM.png

Have you ever forgotten something you need to do daily? This project will notify you 3 ways to make sure you don't forget what you need to do anymore(I made this to remind my family that we need to feed our dog earlier than we have been)

Supplies

Screenshot 2023-01-30 13.18.09.png

These are the items needed for this oroject

  • Particle argon
  • Button
  • LED Lights(I use Adafruit)
  • Phillips hue smart lights
  • Phone(With pushcuts & the alexa app installed)
  • Electronic with the Zapier and IFTTT app/website
  • Optional: Dog bowl
  • Portable phone charger
  • Alexa

Tools

  • Soldering iron
  • Tape to attach lights to where you need

Changing Smart Lights With IFTTT

Screenshot 2023-01-29 5.23.51 PM.png
Screenshot 2023-01-30 13.17.53.png

IFTTT is a very useful app standing for IF This Than That. Essentially you can create a trigger and make an action happen when that trigger is triggered

You do NOT need to pay for an account to use this

Here are the steps to make your applets

  • Create/Log in to your account
  • Hit "Create" on the bottom bar
  • Add a trigger under the "If" section
  • Click the "Webhooks" trigger
  • Click "Recieve a web request"
  • Pick your Event Name
  • You will be creating 2 triggers, one should be named something along the lines of "Turn_Lights_Red" and the other should be named something like "Lights_Back"
  • Hit "Create trigger"
  • Add an action under the "Then That" section
  • Click the Phillips Hue section
  • Click "Change Color"
  • Connect account
  • Select which lights you want to change
  • Add the color codes(For the change to red use #FF0000 and for the other one change it to the color your lights are on usually)
  • Click "Create Action"
  • Repeat to make the other trigger

Next you need to make the webhook

  • Go to https://ifttt.com/maker_webhooks
  • Hit "Documentation"
  • Find/Copy your key(It's in the url or on the top of the screen)
  • Go to https://console.particle.io/integrations and log in if needed
  • Create an Integration(Webhook)
  • Make the event name the same name you put in IFTTT(You will be doing this twice, it doesn't matter what order you do it in
  • In the URL use the following structure changing everything in {} with your personal names/info
  • https://maker.ifttt.com/trigger/{Event_Name}/json/with/key/{Key}
  • Change the request type to "POST"
  • Save your webhook
  • Repeat these steps for the other event

Notifying Your Phone With Pushcuts

Screenshot 2023-01-29 4.25.59 PM.png
Screenshot 2023-01-30 13.18.45.png

Pushcuts is a useful app for iOS phones that can notify your phone when something happens. For our usage we will use time as our trigger. If you do not have an apple phone than you are not required to change anything for the code to still work, you will just be notified one less way

Once again you do NOT need to pay for an account to do this

Here are the steps to get notifications to your phone

  • Make sure notifications are enabled
  • Hit the plus button on the top right of the screen to create a new notification
  • Change the textbox from where it says "Something Happened" to whatever you want(I used "Don't forget to feed Apollo")
  • Delete all text in the textbox under that one
  • Hit Add in the top right
  • Add a Trigger
  • Make sure the trigger is set to "Time" and "Daily"
  • Set the time to the time you want to be notified
  • Hit "Done"(in the top right) twice to first finish the trigger, then finish the notification
  • Wait for your phone to be notified

Set Up Reminders With Alexa

IMG_8925.PNG
Pcl home auto Alexa 2

With your alexa, you will be able to be reminded in a 4th way as well as use your voice to say that you have been alerted


After opening your Alexa app you need to

  • Hit routine
  • Create a new routine
  • Name your routine
  • Select the input
  • Hit Date & Time
  • Set it to be every day at the time of your choosing
  • Select the action
  • Click "Alexa Says"
  • Set a reminder to be said every time you get alerted

Alexa will now say your message every time it is time to be reminded

Create the Webhook for Zapier

Screenshot 2023-02-13 12.04.24.png
Screenshot 2023-02-13 12.06.25.png

NOTICE: for the purposes of this project I am using the trial version, however if you want to use this for more than 2 weeks you need to pay for the full version of Zapier, if you do not want to pay skip to step 6


Allow Your Voice to End the Alert

Pcl home auto Alexa
Screenshot 2023-02-13 11.25.13.png

Zapier is going to be the website I use to take input from alexa and then post a webhook


This step is going to set up the Alexa/Zapier part and the next step is going to set up the webhook


Create your Zapier account

On the Alexa app

  • Go to Skills and Games
  • Install the Zapier skill

On the Zapier Website

  • Create a new Zap
  • For the Trigger use Amazon Alexa
  • Use "Trigger Phrase Spoken" for the event
  • Set up your trigger phrase such as "I have been alerted"
  • For the Action select "Webhooks by Zapier
  • Post the webhook
  • Use the URL you found in the last step as the URL for the webhook


To stop using Alexa say "Alexa open Zapier", "Trigger a Zap", then say your trigger phrase

Wiring the Breadboard

Screenshot 2023-01-29 7.56.51 PM.png
Screenshot 2023-01-30 13.18.35.png
Screenshot 2023-01-30 13.18.25.png

Grab your breadboard and attach the wires according to the diagram above or the bullet points below

  • Button
  • Place your button in some place on the breadboard
  • Attach one of the legs to the 3v3 pin
  • Attach the opposite leg to the D3 pin
  • Lights
  • Make sure you plug this part in while the argon is not connected to power
  • Solder a wire to each of the neopixel copper pads
  • Attach the neopixel GND pad to the Argon GND pin
  • Attach the neopixel Din pad to the Argon D2 pin
  • Attatch the neopixel 5v pad to the Argon VUSB pin


Changing the Code to Fit Your Needs

Screenshot 2023-01-30 13.14.25.png

Take the code in one of the ways found below and copy it into https://build.particle.io/build/new


  • Go to the "Libraries" Tab
  • Add the neopixel library

Line 4: Change the PIXEL_COUNT variable to the number of pixels on your neopixel strip

Line 5: Change the PIXEL_TYPE variable to the type of your neopixels if not WS2812B

Line 10: Change the preset variable to the number you want your argon to default to upon startup

  • This can be changed through the button so don't stress on this line too much

Line 13: Change the wait variable to the amount of delay you want in the light presets(smaller = faster; units = milliseconds)

  • Be careful as making the delay too big(>500) will make the code less effective

Line 19: Change the argument to the amount of time your time zone is before/after UTC (if your time is after UTC, make the number negative)(If you have this project up for long periods of time, be careful as you will need to change this code again to account for daylight savings time)

Line 23: Change the first number to the hour you want to the hour you want to be reminded(in 24 hour time) and the second number to the minute you want to be reminded

if(Time.hour() == "hour to be reminded" && Time.minute() == "minute to be reminded" && Time.second() == 0) {

Line 25: Add in the Parenthesis the name of the webhook you made to turn the smart lights red in quotes

Line 129: Add in the Parenthesis the name of the webhook you made to turn the smart lights back in quotes

Using Your New Notifier

Screenshot 2023-01-29 8.21.22 PM.png
Pcl home auto demonstration

Congrats on making your Notifier, here is how to use it

When the lights are on, hit the button to turn them off or use alexa(how to do this is shown in step 5)

When the lights are off, hit the button to change the preset

  • Preset 1: 1 red light going around
  • Preset 2: 1 random color light going around
  • Preset 3: 2 red lights going the opposite way
  • Preset 4: a loop of red, then blue, then green lights

You can see the presets in action through the video below

Have fun with your new notifier!!

*OPTIONAL* Adding Another Preset

If you ever want to add a preset to your notifier this will teach you the neopixel library if you want to add a preset

I will start by going through the first preset and going through functions you will need in order to make your own(this preset loops a red dot around the strip)

for(int i=0; i<strip.numPixels(); i++) {
strip.clear();
    strip.setPixelColor(i, 255, 0, 0);
    strip.show();
    delay(wait);
    checkButton();
    if(!feedingTime) {
        return;
    }
}


the variable "strip" is the variable defined in line 7 of the code

the library is imported and strip is defined in the following code snippet

#include <neopixel.h>


#define PIXEL_PIN D2
#define PIXEL_COUNT 21
#define PIXEL_TYPE WS2812B


Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);


for(int i=0; i<strip.numPixels(); i++)

In all of my presets I loop through the lights from the beginning to end, I recommend you do the same thing as it is a simple way to go through the lights(especially since we add a delay)

  • .numPixels()
  • Returns an integer stating the amount of pixels in the strip(the number defined in the PIXEL_COUNT variable)
strip.clear();
strip.setPixelColor(i, 255, 0, 0);
strip.show();
delay(wait);
  • .clear()
  • turns all the lights off
  • .setPixelColor(i, r, g, b)
  • sets the pixel defined by i to the hex code defined by r, g, and b
  • 0 <= i <.numPixels()
  • 0 <= r, g, b <= 255
  • .show()
  • shows the changes made by .clear() and .setPixelColor()
  • delay(time)
  • doesn't go to the next line of code until "time" milliseconds have passed since the execution of this function
  • while this is not a method imported from the neopixel library, this is a method I use in all my presets
  • Be careful on setting time too high as anything >500 will lower the user experience
checkButton();
if(!feedingTime) {
return;
}

This snippet of code is only in there to make the user experience better, but all presets should have it to not slow anything down


All extra presets should be in an additional if statement starting after line 104

  • the first if header should be the following
if(preset == 5) {}

for all additional presets change the 5 to 6, 7, 8, etc.


For every preset you add, change the code originally on line 119 to the amount of presets you have + 1

if(preset >= 5) {
preset = 1;
}

For example, if you add a preset the header would change to

if(preset >= 6)



Other important neopixel functions

  • .begin()
  • starts the use of the neopixel strip, is only required once per strip in the code
  • .setBrightness(brightness)
  • sets the brightness of the lights
  • .setColorDimmed(i, r, g, b, brightness)
  • combines the .setPixelColor() and the .setBrightness() methods