Jerry Zhang
Published © GPL3+

Cooler Status Monitor

Keep your drinks nearby and cool on hot summer days!

IntermediateFull instructions provided5 hours1,083
Cooler Status Monitor

Things used in this project

Hardware components

Omega2 Plus
Onion Corporation Omega2 Plus
×1
Onion Corporation Onion Arduino Dock 2
×1
Buzzer
Buzzer
×1
Photo resistor
Photo resistor
×1
LED (generic)
LED (generic)
I used a white one, but anything works.
×1
Temperature Sensor
Temperature Sensor
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
You need a lot of these
×1
Resistor 330 ohm
Resistor 330 ohm
You need this to connect the photoelectric sensor (aka photo resistor). A 220 ohm one also will do the job.
×1
Resistor 1k ohm
Resistor 1k ohm
You need a resistor to connect the LED, I used a 1K
×1

Software apps and online services

Losant Platform
Losant Platform

Story

Read more

Schematics

Wiring Diagram

Because the Omega 2+ Arduino Dock 2 was not in Fritzing, I used a generic Arduino for the wiring (and put a picture of the dock on top), but on the actual dock all the wires go to the same place.

Code

Cooler Status Monitor Code (modified from Omega's Smart Plant Sample Code)

Python
To use it, download the zip and follow along with the instructions from Onion's project guide. The code is written in Python
No preview (download only).

Arduino Code

Arduino
This code takes all the inputs and will make the buzzer sound when one of 3 conditions are met.
/*
 * Jerry Zhang's 2017 Omega-thon Project
 * Cooler Status Monitor
 * 
 * Some code samples from Sparkfun's SIK Guide
 */
float MAXTEMP = 90; // Set maximum temperature (in Fahrenheit) before the buzzer goes off
int COOLER_OPEN_LIGHT_LEVEL = 100; // Set light level when cooler is open, between 0 and 255

// Calibrating the light sensor
int lightLevel;
int calibratedlightLevel;
int maxThreshold = 0;
int minThreshold = 1023;


// Analog Pins
const int temperaturePin = 0;
const int photoresistorPin = 1;

// Digital Pins
const int buzzerPin = 9;
const int tiltSensorPin = 7;
const int ledPin = 12; // LED for testing purposes

void setup() {
  pinMode(buzzerPin, OUTPUT);
  pinMode(tiltSensorPin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // Temp sensor
  float voltage = getVoltage(temperaturePin); // getVoltage function written below
  float degreesF = (voltage - 0.5) * 100.0 * (9.0/5.0) + 32.0;

  bool tilt = digitalRead(tiltSensorPin); // The tilt sensor acts like a button: if it's tilted the value is true, otherwise it's false

  lightLevel = analogRead(photoresistorPin); // Read voltage on sensorPin
  calibratedlightLevel = map(lightLevel, 0, 1023, 0, 255); // scale to 0-255 range. Map is a built in arduino function

  if (degreesF > MAXTEMP || tilt || lightLevel > COOLER_OPEN_LIGHT_LEVEL) { // if it's too hot or the cooler is being tilted (it's being rolled away), then the buzzer goes off
    digitalWrite(ledPin, LOW);
    tone(buzzerPin, 523, 1000); // the tone function takes the pin, the frequency of the note, and how long (in ms) the note should go for.
  } else {
    digitalWrite(ledPin, HIGH);
  }

  

  delay(1000);
}

float getVoltage(int pin) {
  return (analogRead(pin) * 0.004882814);
  
  // This equation converts the 0 to 1023 value that analogRead()
  // returns, into a 0.0 to 5.0 value that is the true voltage
  // being read at that pin.
}

Credits

Jerry Zhang

Jerry Zhang

11 projects • 15 followers

Comments