User Tools

Site Tools


user:asowers:lair_brew

Welcome

Gather round and pour a cup o'joe, we're about to begin.

Getting WIRED isn't just for computers anymore

Caffeine is without a doubt my brew of choice for many reasons. Coffee wakes you up, is great for after dinner dessert, perfect for chatting with friends, and even working on this project!

We as computer people like to automate frequented processes and for good reason, it's simplifies things!

Ever wake up and wish your coffee was waiting for you upon exiting the shower? Probably not, but you'll be wondering how you ever lived without it once it's setup!

Selecting your beans takes experience

Required Materials:

  1. Raspberry Pi Computer
  2. Asterisk Setup
  3. Solid State Relay
  4. Power Strip
  5. SIP Client
  6. Coffee Machine(preferably a dumb one as more expensive ones have an on/off switch which nixes the automation)
  7. Coffee(for both development and actualization)

Fine Ground Details

For the sake of sanity, the program I've written makes use of an extremely detailed library that makes Pi GPIO programing comparable to an Arduino-like setup.

If you're interested the library can be found here: https://github.com/WiringPi/WiringPi/tree/master/wiringPi

So here's Lair_Brew version 0.2 :

/*
Lair_Brew ~ Caffeine ~
Version 0.2
*/
 
#include <wiringPi.h>
#include <stdio.h>
 
void loopback(void)
{
    char ch;
    ch = getchar();
    while( ch != '\n' ) ch = getchar();
}
 
int main (void)
{
    int pin = 7;
    char ch;
    int exit_flag = 0;
    printf("welcome to Lair Brew\n");
 
  if (wiringPiSetup() == -1) return(1);
 
    pinMode(pin, OUTPUT);
    printf("Brew on\n");
    digitalWrite(pin, 1);
 
 while( exit_flag  == 0 ) {
    printf("Wish to exit? (Y)\n");
    scanf(" %c", &ch );
    ch = toupper( ch );
 
 if((ch == 'Y')){
    printf("\nBrew Off\n");
    digitalWrite(pin, 0);
    delay(250);
    printf("\nEnjoy Your Coffee, Sir!\n");
  }
  else {
    printf("\nType (y) to exit.\n");
    loopback();
  }
   if( ch == 'Y' ) exit_flag = 1;
  }
 
  return 0;
}

Compile and make sure to include the library:

root@incrediblepbx:~# gcc -o Lair_Brew Lair_Brew.c -L/usr/local/lib -lwiringPi

And here's a CLI output:

root@incrediblepbx:~# ./Lair_Brew
welcome to Lair Brew
Brew on
Wish to exit? (Y)
y

Brew Off

Enjoy Your Coffee, Sir!

Time to dial a brew(work in process)

Earlier this semester we began tinkering with asterisk as sip phone server. At one point we discovered that asterisk is capable of interfacing with the system by way of the extensions.conf file.

In /etc/asterisk/extensions.conf

I've adding the following extension:

exten => 607,1,Answer
exten => 607,2,Wait(1)
exten => 607,3,System(/tmp/Lair_brew_auto)
exten => 607,4,Hangup()

Asterisk answers the call, waits one second, executes Lair_Brew located in /tmp/Lair_Brew , and hangs up.

This level of automation allows dialing a coffee permitted that the machine is loaded/ready and the systems are online.

user/asowers/lair_brew.txt · Last modified: 2012/10/21 18:38 by asowers