Laura
Published

MetaKeg - App Controller Beer Kegerator

Build a Smart Home Tap (for beer and more) so you only drink if you have the password!

Full instructions provided1,222
MetaKeg - App Controller Beer Kegerator

Things used in this project

Hardware components

solenoid valve
×1
flowmeter
×1
MetaWear
MetaWear
×1

Story

Read more

Code

file_9527.txt

Plain text
[self.device connectWithHandler:^(NSError *error) {
    // Start counting flowmeter ticks
    MBLGPIOPin *pulseCounter = self.device.gpio.pins[PULSE_COUNTER_PIN];
    pulseCounter.changeType = MBLPinChangeTypeAny;
    [pulseCounter configureType:MBLPinConfigurationNopull];
    [pulseCounter.changeEvent startNotificationsWithHandler:^(id obj, NSError *error) {
        self.tickLabel.text = [NSString stringWithFormat:@"%d", ++self.counts];
    }];
 
    // Turn on the flow
    MBLGPIOPin *solenoid = self.device.gpio.pins[SOLENOID_PIN];
    [solenoid setToDigitalValue:YES];
 
    // Take a temperature reading
    self.device.temperature.source = MBLTemperatureSourceThermistor;
    self.device.temperature.units = MBLTemperatureUnitCelsius;
    self.device.temperature.thermistorReadPin = 0;
    self.device.temperature.thermistorEnablePin = 1;
    [self.device.temperature readTemperatureWithHandler:^(NSDecimalNumber *number, NSError *error) {
        self.tempLabel.text = [NSString stringWithFormat:@"%f", number.floatValue];
    }];
 
    // For some feedback flash an LED
    [self.device.led flashLEDColor:[UIColor greenColor] withIntensity:0.5];
}];

code.txt

Plain text
[self.device connectWithHandler:^(NSError *error) {

    // Start counting flowmeter ticks

    MBLGPIOPin *pulseCounter = self.device.gpio.pins[PULSE_COUNTER_PIN];

    pulseCounter.changeType = MBLPinChangeTypeAny;

    [pulseCounter configureType:MBLPinConfigurationNopull];

    [pulseCounter.changeEvent startNotificationsWithHandler:^(id obj, NSError *error) {

        self.tickLabel.text = [NSString stringWithFormat:@"%d", ++self.counts];

    }];



    // Turn on the flow

    MBLGPIOPin *solenoid = self.device.gpio.pins[SOLENOID_PIN];

    [solenoid setToDigitalValue:YES];



    // Take a temperature reading

    self.device.temperature.source = MBLTemperatureSourceThermistor;

    self.device.temperature.units = MBLTemperatureUnitCelsius;

    self.device.temperature.thermistorReadPin = 0;

    self.device.temperature.thermistorEnablePin = 1;

    [self.device.temperature readTemperatureWithHandler:^(NSDecimalNumber *number, NSError *error) {

        self.tempLabel.text = [NSString stringWithFormat:@"%f", number.floatValue];

    }];



    // For some feedback flash an LED

    [self.device.led flashLEDColor:[UIColor greenColor] withIntensity:0.5];

}];

Github

https://github.com/Kegbot/kegbot-server

Github

https://github.com/RestKit/RestKit

Github

https://github.com/mbientlab-projects/MetaKeg

Credits

Laura

Laura

18 projects • 46 followers
www.mbientlab.com

Comments