Kevin Andrew HedspethMichael Harrington
Published

Smart Kegerator

The Smart Kegerator uses the Particle Photon to take volume measurements of your Kegerator and will notify you when it is getting low.

BeginnerFull instructions provided5 hours1,066
Smart Kegerator

Things used in this project

Hardware components

Danby Kegorator
Any Kegorator may be used.
×1
Photon
Particle Photon
One Photon was used to calculate the dispensed volume. The other Photon notifies the owner when the volume of the keg is low
×2
LED (generic)
LED (generic)
As well as the notification to the owner when the volume is low, an LED will light up on top of the Kegorator.
×1
Toggle Switch
The toggle switch is attached to the tap handle tracking the opening and closing of the tap. Any switch may be used.
×1
Breadboard (generic)
Breadboard (generic)
One breadboard is used to hold the two Photons and the LED as well as to connect the toggle switch to the Photon.
×1

Software apps and online services

www.particle.io

Story

Read more

Schematics

Tap Timer Photon Schematic.

Schematic of the Tap Timer Photon.

Notify Code Schematic

Schematic of Notify code Photon.

Code

Tap Timer

C/C++
This code is used to calculate the total volume dispensed and to publish the volume when low.
  /*
                               +-----+
 *                  +----------| USB |----------+
 *                  |          +-----+       *  |
 *                  | [ ] VIN           3V3 [ ] |
 *                  | [ ] GND           RST [ ] |
 *                  | [ ] TX           VBAT [ ] |
 *                  | [ ] RX  [S]   [R] GND [*] |
 *                  | [ ] WKP            D7 [ ] |
 *                  | [ ] DAC +-------+  D6 [ ] |    
 *                  | [*] A5  |   *   |  D5 [ ] |    
 *                  | [*] A4  |Photon |  D4 [ ] |<-------- Toggle switch Power
 *                  | [ ] A3  |       |  D3 [ ] |        |
 *                  | [ ] A2  +-------+  D2 [ ] |        \ 
 *                  | [ ] A1             D1 [ ] |        | 
 *                  | [ ] A0             D0 [*] |<-------- Toggle Switch Common
 *                  |                           |
 *                   \    []         [______]  /
 *                    \_______________________/
 *
 *
 */
 //declaration of variables
    int reading = D0;
    int power = D4;
    int tap;
    int long totaltime = 0;
    int long pourtime = 0;
    int FlowRate =(1.6);
    long int Volume = 0; 
  
 

void setup() {     
	Serial1.begin(230400); //enables usb serial debugging if plugged into PC.
    pinMode(power, OUTPUT);  //sets D4 pin to an analog voltage output
    pinMode(reading, INPUT);  // D0 is set to a voltagee input
    digitalWrite(power, HIGH); //Sets D4 analog value to high
  
    Particle.variable("tap", &tap, INT);    // Shows on particle app when tap is open(0)/closed(1)
    Particle.variable("Volume", &Volume, INT);					//Shows on particle app as total volume dispensed
    Particle.variable("Totaltime", &totaltime, INT);      //Shows on particle app the total time the tap has been opened
}

void loop() {
	
	tap = digitalRead(reading);  //enables you to watch this via the particle variable.
	pourtime = 0; //pourtime needs to be reset every loop.  this would cause your error to increase each loop without reset.
    pourtime = pulseIn(reading,LOW); //pulseIn function acts as a timer every time the D0 pin becomes low (i.e. tap is opened)
    // pourtime is recorded
 
	totaltime = pourtime + totaltime; //This equation takes previous loop's totaltime and adds in most recent pourtime
    Volume = ((FlowRate) * (totaltime*2))/1000000; //Calculates total volume dispensed by multipling totaltime and flow rate
    //totaltime is multiplied by 2 due to total time being recorded asw half the actual value
   //Volume is divided by 1000000 to account for pulseIn function measuring in microseconds
     
	if (pourtime > 0){  //When tap open D0 pin goes to 0
		
		Particle.publish("Pouring","The tap is open.",PUBLIC);    //Notifies user when tap is opened
	
	    if (Volume >= 5){  //If total volume dispenses is >= to 80% of keg volume
			Particle.publish("Volume","Low",PUBLIC); //event published to tell the other particle the volume is low
			//This volume can vary based on size of the keg and requires a simple reflashing of the particle
		}
		}
	}

Notify

C/C++
This code subscribes to the Volume variable. When volume is "Low" the LED turns off and an event is published to the cloud.
 /*
                                +-----+
 *                   +----------| USB |----------+
 *                   |          +-----+       *  |
 *                   | [ ] VIN           3V3 [ ] |
 *                   | [ ] GND           RST [ ] |
 *                   | [ ] TX           VBAT [ ] |
 *                   | [ ] RX  [S]   [R] GND [*] |<-------- LED GND
 *                   | [ ] WKP            D7 [ ] |        |
 *                   | [ ] DAC +-------+  D6 [ ] |        |
 *                   | [*] A5  |   *   |  D5 [ ] |         \
 *                   | [*] A4  |Photon |  D4 [ ] |          =(LED)
 *                   | [ ] A3  |       |  D3 [ ] |         /
 *                   | [ ] A2  +-------+  D2 [ ] |        | 
 *                   | [ ] A1             D1 [ ] |        | 
 *                   | [ ] A0             D0 [*] |<-------- LED Power
 *                   |                           |
 *                    \    []         [______]  /
 *                     \_______________________/
 *
 *
 */
int digitalValue;
int Volume;
int Low;
int power = D0;
void setup() {
    Particle.subscribe("Volume",myHandler,"200029000547353138383138");
     pinMode(power, OUTPUT);
 digitalWrite(power, HIGH);
}

void myHandler(const char *event, const char *data)
{  if (data){
     Particle.publish("VolumeLOW","The Keg is Low.",PUBLIC);
     digitalWrite(power,LOW);

}

}

Credits

Kevin Andrew Hedspeth

Kevin Andrew Hedspeth

1 project • 1 follower
Michael Harrington

Michael Harrington

1 project • 1 follower
Thanks to John R McAlpine.

Comments