stefan63
Published © CC BY-NC

Weight-Based Coffee Grander with Blynk App

Make your stupid coffee grinder smart with this IoT and weight-based coffee grinder modification.

IntermediateWork in progress997
Weight-Based Coffee Grander with Blynk App

Things used in this project

Story

Read more

Schematics

Arduino scetch

Use with Arduino IDE more info and latest version @ https://www.stockholmviews.com/wp/weight-based-coffee-grinder-with-blynk-app

Code

Code snippet #2

Plain text
//#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "HX711.h"
BlynkTimer timer;
int relayPin = D5;  // Change to suit your board.

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = D2; // Change to suit your board.
const int LOADCELL_SCK_PIN = D1; // Change to suit your board.

HX711 scale;
//Blynk project auth.
char auth[] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YOUR-SSID";
char pass[] = "YOURPASS";

BLYNK_WRITE(V0) { scale.tare(); // Strain sensor tare
}
BLYNK_WRITE(V2){
  if (param.asInt()) {
    digitalWrite(relayPin, HIGH);  // Relay ON.
  } else {
    digitalWrite(relayPin, LOW);   // Relay OFF.
  }
}
BLYNK_WRITE(V3) {
  Blynk.virtualWrite(V2, 0);
  digitalWrite (relayPin, LOW);   // Grinder interupt (Emergecy stop), Relay OFF.
}
int slider;
BLYNK_WRITE(V11)
{
slider = param.asInt(); // Assigning incoming value from pin V11 (Slider value) to a global variable.
}

void setup() {

  Serial.begin(57600);
  Blynk.begin(auth, ssid, pass, "192.168.254.110", 8080);
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale(1040.f);
  timer.setInterval(500L, HX711data);  // .5 sek delay to unstress the server and stabalize readout on numeric widget @ V1.
  timer.setInterval(60L, HX711relay);  // 60ms delay ono to keep fast stop grinder response and not overshoot grinding to much.
  digitalWrite(relayPin, LOW); // To make sure grinder doesn't start running during boot.
  pinMode(relayPin, OUTPUT);
  BLYNK_CONNECTED();
  Blynk.syncAll();
}
void HX711data()
{
  Blynk.virtualWrite(V1, scale.get_units(20));  // sending calibrated strain sensor value to Blynk value widget.
}
void HX711relay()
{
  if (scale.get_units(20) >= (slider-0)) {
  Blynk.virtualWrite(V2, 0);
  digitalWrite(relayPin, LOW); //Relay OFF change the (slider-0.0) number in seconds with one decimal to compensate if grinder overshoot "Grinder calibration".
}
}
void loop()
{
  Blynk.run();
  timer.run(); 
}

Credits

stefan63

stefan63

0 projects • 0 followers

Comments