gwc2225
Published

Scheduled Key Reminder

A project that reminds you at specific times when you forget your keys.

BeginnerShowcase (no instructions)12
Scheduled Key Reminder

Things used in this project

Hardware components

2 Sets Digital Load Cell Weight Sensor + HX711 ADC Module Weighing Sensor
×1
Photon
Particle Photon
×1
Machine Screw, M4
Machine Screw, M4
×1

Software apps and online services

Slack
Slack

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
10 Pc. Jumper Wire Kit, 5 cm Long
10 Pc. Jumper Wire Kit, 5 cm Long

Story

Read more

Schematics

Circuit drawing

Code

Code

Java
It uses the listed libraries, reads the weight and sends a message through a slack webhook
// This #include statement was automatically added by the Particle IDE.
#include <TimeAlarms.h>

// This #include statement was automatically added by the Particle IDE.
#include <HX711ADC.h>

// This #include statement was automatically added by the Particle IDE.
// Include Particle Device OS APIs
#include "Particle.h"
// Let Device OS manage the connection to the Particle Cloud
SYSTEM_MODE(AUTOMATIC);
#define LOADCELL_DOUT_PIN  6
#define LOADCELL_SCK_PIN  1


HX711ADC scale(D2, D3);

float calibration_factor = 1980; // this calibration factor is adjusted according to my load cell
float units;
float ounces;

void setup() {
  Time.zone(-4);
  //setTime(8, 29, 0, 1, 1, 11);
  Serial.begin(9600);
  Alarm.delay(0);
  // create the alarms 
  Alarm.alarmRepeat(6,30,0, MorningAlarm);  // 7:30am every day
  Alarm.alarmRepeat(13,15,10,EveningAlarm); 
  Alarm.timerRepeat(10, Repeats);   
  Particle.function("message", cloud);

  scale.begin(D2, D3);
  scale.set_scale(calibration_factor);
  scale.tare(); //Reset the scale to 0

  long zero_factor = scale.read_average(); //Get a baseline reading
  Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
  Serial.println(zero_factor);
}

void loop() {
    Alarm.delay(100);
    
 //Adjust to this calibration factor

  
}

void Repeats(){
    scale.set_scale(calibration_factor);
    int l = scale.get_units();
    if(l < 1){
        cloud("Put your key back");
    }
}

void MorningAlarm(){
  Serial.println("Alarm: - turn lights off"); 
  scale.set_scale(calibration_factor);
  int l = scale.get_units();
  if(l < 2){
      cloud("Put your key back");
  }
  //cloud("alarm");
  //Particle.publish("message");
}

void EveningAlarm(){
  Serial.println("Alarm: - turn lights on");  
  scale.set_scale(calibration_factor);
  int l = scale.get_units();
  if(l < 2){
      cloud("Put your key back");
  }
}


int cloud(String param){
 Particle.publish("message", param, PRIVATE);
 return 0;
}

TimeAlarms

By Paul Stoffregen, allows a timer to be set for seconds

Hx711 Library

By eliteio, allows the weight sensor to be calibrated and measure the weight

Credits

gwc2225
1 project • 0 followers
Contact
Thanks to Paul Stoffregen and eliteio.

Comments

Please log in or sign up to comment.