Software apps and online services

Hand tools and fabrication machines

Heavy Duty Tape

Story

BACKGROUND

The purpose of this project was intended to allow users to monitor the status of their cooler. This application is good for college students who do not want to have the contents of their cooler stolen at a party or parents who want to monitor the “adult cooler” at their backyard barbecue. Additionally, the cooler becomes festive. The idea is simple, whenever the cooler is opened, lights are turned on inside the cooler and a notification is sent to your personal device(s).

The system works by connecting two photons (pictured in Figure 1) together using particle.publish and particle.subscribe. The first photon is connected to the magnetic reed switch, which is placed on the seam of the cooler and lid. The second photon is connected to a waterproof LED strip light. When the lid of the cooler is opened, the loop is broken, the lights will turn on, and the first photon will send a notification to your device(s)via IFTTT.

Figure 1. The two photons mounted on back of cooler

COMPONENTS

A brief overview of the components is below.

Magnetic Reed Switch

The magnetic reed switch (Figure 2) is connected to the first photon, which reads signal status of the cooler lid (opened or closed). The first photon will then signal the second photon whenever the state of the switch is changed.

Figure 2. Magnetic reed switch

LED Strip Light

When the lid is opened, the second photon will receive the signal from the first photon indicating the state of the cooler lid. When it is opened, the second photon will output high, therefore turning on the lights (Figure 3).

Figure 3. LED light strip in cooler

SignalReceiving Methods

The devices that are receiving information from the first photon and the second photon are IFTTT, and Thingspeak. Thingspeak is used to monitor the time/frequency that the cooler is opened, when the lid is closed it will read a value of “0” and when the lid is opened it will read a value of“1”. Test results can be seen below in Figure 4.

Figure 4. Thingspeak test results

The IFTTT contains two applets, one for when the cooler is opened, and one when the cooler is closed. The notifications sent to your device(s) can be seen in Figure 5.

Figure 5. Notifications sent via IFTTT

BUILD

With both photons connected to the internet, both circuits need to be constructed (view schematics below). Place the magnetic reed switch on the seam of the cooler and lid, and place the light strip inside the cooler.

Next, create a Thingspeak account, create a new channel, give it an arbitrary name, and leave the rest of the settings to default. Once it is saved, acquire the API Key under the tab labeled “API Keys”. Copy the API Key, it is needed for the next step. Additionally, a webhook must be added through particle console. Once at the console, select “Integrations”, and create a new custom template. Copy the webhook code below and paste in to the custom template, and click “create webhook”.

Now, download the IFTTT app on your mobile device or on your computer. Create a new applet, search “Particle”, choose the “New Event Published” trigger, select and event name and its contents (ex: If “cooler_status” is “opened”), and select the device that reads the input signal of the magnetic reed switch (first photon in this project). Now create another applet with the same process, but change the event contents to the opposite of the first applet made. This process will allow the cooler to send notifications to your device(s).

Lastly, flash the code below to the two photons. The code will have to be varied slightly. For the first photon code, the event name(“cooler_status” for this project) must be changed to the event name defined by the user. Additionally, the API Key will need to be placed on the lines of code which publish to Thingspeak. For the second photon code, change the event name, and ensure place your device ID on the particle.subscribe code to enable the devices to communicate. Once the code is flashed, your cooler is ready to party.

Schematics

Photon One: Magnetic Reed Switch

Photon 2: LED Strip Light

Code

Photon 1: Magnetic Reed Switch

C/C++

intstate;// For the loop portion of the code, state is used, which only allows a "publish" when the cooler state changes intlid=0;// Thinkspeak data, 0=closed lid, 1=opened lidvoidsetup(){pinMode(D7,OUTPUT);pinMode(D0,INPUT);// D0 is reading the input from the reed switchdigitalWrite(D7,HIGH);// D7 is always outputting a high signal}voidloop(){if(digitalRead(D0)==HIGH){//D0 will read HIGH when the reed switch is disconnected due to the cooler lid being openedif(state!=0){Particle.publish("cooler_status","Opened");// Publish "Opened" is sent to "cooler_status", which is the channel that the other photon is listening to initiating the lights to turn ONstate=0;lid=1;//cooler lid defined as openedParticle.publish("thingSpeakWrite_","{ \"1\": \""+String(lid)+"\", \"k\": \"URJNA1RRANEH72J7\" }",60,PRIVATE);//value of "1" is sent to thinkspeak, idicating the lid is open}}elseif(digitalRead(D0)==LOW){//D0 will read LOW when the reed switch is connenected due to the cooler lid being closedif(state!=1){Particle.publish("cooler_status","Closed");//Publish "Closed" is sent to "cooler_status", which is the channel that the other photon is listening to initiating the lights to turn OFFstate=1;lid=0;//cooler lid defined as closed// delay(1000); was here but deleted for testingParticle.publish("thingSpeakWrite_","{ \"1\": \""+String(lid)+"\", \"k\": \"URJNA1RRANEH72J7\" }",60,PRIVATE);//value of "0" is sent to thinkspeak, idicating the lid is closed}}}

Photon 2: LED Strip Light

C/C++

intstate=0;voidsetup(){pinMode(D0,OUTPUT);digitalWrite(D0,LOW);Particle.subscribe("cooler_status",myHandler,"55004c000e51353532343635");}voidloop(){}voidmyHandler(constchar*event,constchar*data){if(strcmp(data,"Opened")){//Code recieves message from photon one, indicating that the lid is OPENED, and to turn the lights ONdigitalWrite(D0,HIGH);}elseif(strcmp(data,"Closed")){//Code recieves message from photon one, indicating that the lid is CLOSED, and to turn the lights OFFdigitalWrite(D0,LOW);}}