Daniel DiPilatoNicholas PfeifferJoshua Greene
Published

Brewtiful Bean Machine

If you can't go without your morning coffee, but your routine leaves you crunched for time, then the Brewtiful Bean Machine is for you.

IntermediateShowcase (no instructions)6 hours1,500
Brewtiful Bean Machine

Things used in this project

Hardware components

5V 2 channel relay module
A one channel relay will work just fine because a single channel is used in the project.
×1
Photon
Particle Photon
×2
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 221 ohm
Resistor 221 ohm
×1
Extension Cord
Any extension can be used here
×1
Coffee Pot
Any one button coffee maker will work
×1

Software apps and online services

Maker service
IFTTT Maker service
ThingSpeak API
ThingSpeak API

Story

Read more

Schematics

Relay Switch Circuit

This is an actual image of the circuit build that controls the relay to turn the coffee pot on or off.

Temperature Sensor Circuit

This is the circuit that controls the DHT11 sensor that logs the temperature data

Temperature Schematic

A schematic of how the temperature circuit is wired

Relay Schematic

A schematic of how the relay switch is wired

Thingspeak DHT11 Sensor Data

These four graphs show the data gathered when a trial run of the project was completed. This includes the process from start to finish

Code

Relay Switch Code

C/C++
This code is linked to the particle that controls when the relay switch turns off or on
// -----------------------------------------
// Function and Variable with Photoresistors
// -----------------------------------------
// In this example, we're going to register a Particle.variable() with the cloud so that we can read brightness levels from the photoresistor.
// We'll also register a Particle.function so that we can turn the LED on and off remotely.

// We're going to start by declaring which pins everything is plugged into.

int relay = D0; // This is where your LED is plugged in. The other side goes to a resistor connected to GND.
int led = D7;



// Next we go into the setup function.

    void setup() {
    
       


    pinMode(relay,OUTPUT);//  our to_relay pin is output (sending voltage to relay)
    pinMode(led,OUTPUT);
    
    digitalWrite(led,LOW);


    // We are also going to declare a Particle.function so that we can turn the LED on and off from the cloud.
    Particle.function("relayToggle",relayToggle);
    // This is saying that when we ask the cloud for the function "on", it will employ the function ledToggle() from this app.
 
        Particle.subscribe("thingSpeakWrite_All","led_ON","3f0041001747343338333633");
                            
}

// Finally, we will write out our ledToggle function, which is referenced by the Particle.function() called "led"
void led_ON(const char *eventName, const char *data)
   {
    digitalWrite(led, HIGH);
    delay(500);
   }
    
int relayToggle(String command) {


        if (command == "ON" || command == "on" || command == "On") {
            digitalWrite(relay, HIGH);
                return 1;
                    
    }
        else if (command == "OFF" || command == "off" || command == "Off") {
            digitalWrite(relay, LOW);
               
                
                return 0;
    }
        else {
            return -1; 
    
    
        }
}

Temperature Sensor Code

C/C++
This code controls the DHT11 sensor and tells the sensor when to log data to Thingspeak
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_DHT/Adafruit_DHT.h"

// -----------------------------------------
// solarmonitor
// Monitor light, temperature and Humidy at solar panel
// Particle Photon + Particle.io Webhook + ThingSpeak Integration
// April, 2016 - Pete Hoffswell - pete@hoffswell.com
// -----------------------------------------
#define DHTPIN 2
#define DHTTYPE DHT11 // DHT11 Module
#define publish_cycle 10000 // Only publish every 60 seconds
const String key = "YEB3V2FLNZH3Y8QW"; // Change this to your Thingspeak api write key
int led = D7;
int photoCell = A0;
int power = A5; // Photocell power.  An analog pin to gives a more steady voltage.
int light; // Light
double tempF; // Temperature F
double tempC; // Temperature C
double humidity; // Humidity
unsigned int lastPublish = 0;
DHT dht(DHTPIN, DHTTYPE);
void setup() {
    // Set Pin Modes
    pinMode(led,OUTPUT);
    pinMode(photoCell,INPUT);
    pinMode(power,OUTPUT);
    digitalWrite(power,HIGH); // Turn on power source for photoCell
    digitalWrite(led,LOW); 
    // Connect variables to particle cloud
    // This allows you to save data to particle.io, and run commands against it such as "particle variable Photon get light"
    Particle.variable("light", &light, INT);
    Particle.variable("tempF", &tempF, DOUBLE);
    Particle.variable("tempC", &tempC, DOUBLE);
    Particle.variable("humidity", &humidity, DOUBLE);
    dht.begin();
    Serial.begin(9600);
    delay(10000);
} //setup
void loop() {
  unsigned long now = millis();
  digitalWrite(led,HIGH); // Signal read sequence led
  // read sensors
  light = analogRead(photoCell);
  delay(100);  // is this needed?
  humidity = dht.getHumidity();
  tempC = dht.getTempCelcius();
  tempF = dht.getTempFarenheit();
  // DHT Read ok?
  if (isnan(humidity) || isnan(tempF) || isnan(tempC)) {
    Serial.println("");
    Serial.println("Failed to read from DHT sensor!");
    Serial.println("humidity=" + String(humidity) + " tempF=" + String(tempF) + " tempC=" + String(tempC));
    Serial.println("");
    return; // exit loop and try again
  }
  // Display to serial
  Serial.println();
  Serial.print("humidity=" + String(humidity) + " tempF=" + String(tempF) + " tempC=" + String(tempC) + " light=" + String(light));
  delay(200);
  // Publish to thinkspeak
  if ((now - lastPublish) > publish_cycle) {
    Particle.publish("thingSpeakWrite_All", "{\"1\": \"" + String(humidity) + "\"," +
       "\"2\": \"" + String(tempC) + "\"," +
       "\"3\": \"" + String(tempF) + "\"," +
       "\"4\": \"" + String(light) + "\"," +
       "\"k\": \"" + key + "\"}", 60, PRIVATE);
    lastPublish = now;
    Serial.println(" - Published!");
  } else {
      Serial.println();
  }
 digitalWrite(led,LOW);
  delay(2000); // Wait 2 seconds before next loop
}// loop

Integration

C/C++
This was the generic webhook that was used to link Mcbuckets to ThingSpeak
{
  "event": "thingSpeakWrite_",
    "url": "https://api.thingspeak.com/update",
    "requestType": "POST",
    "form": {
        "api_key": "{{k}}",
        "field1": "{{1}}",
        "field2": "{{2}}",
        "field3": "{{3}}",
        "field4": "{{4}}",
        "field5": "{{5}}",
        "field6": "{{6}}",
        "field7": "{{7}}",
        "field8": "{{8}}",
        "lat": "{{a}}",
        "long": "{{o}}",
        "elevation": "{{e}}",
        "status": "{{s}}"
    },
    "mydevices": true,
    "noDefaults": true
}

Credits

Daniel DiPilato

Daniel DiPilato

1 project • 0 followers
Junior Mechanical Engineering student at UNC Charlotte
Nicholas Pfeiffer

Nicholas Pfeiffer

1 project • 0 followers
Joshua Greene

Joshua Greene

1 project • 0 followers

Comments