BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Coffee grinder with weight based grinding

#1

My latest Blynk project is a weight based smart grinder with the following features.
ESP8266 + HX711 and a strain sensor (I have used a cheap 500g “fleebay” digital scale).

The sketch contains calibration data for the strain sensor and a way to calibrate for possible overrun of the grinder (adjust turnoff offset if grinder overrun to make final weight to correspond to preset).

I run this on a personal server.

Blynk app features

  • Preset with “Slider widget” in grams.
  • Readout off preset and live weight “Labeled value”+ “Level V” to animate grinding progress.
  • Tare function to zero the scale “Styled button Virtual pin”.
  • Grind button “Styled button Virtual pin”.
  • Off button for emergency/regret situations “Styled button Virtual pin”.

Upcoming features

  • Stepper motor to change grain size, steps or step less with saveable presets (Slider widget again maybe vertical this time.
  • App settings for the over grind adjustment (On separate “Settings tab”).
  • Maybe OTA Update feature.
  • Maybe physical buttons and Oled display.

Sketch right now 25 Mar 2019 (All help/suggestion are welcome I’m not rely a coder :shushing_face:

	//#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[] = "b4c24e6436914425a93f2633c1668576";
	// Your WiFi credentials.
	// Set password to "" for open networks.
	char ssid[] = "Your SSID";
	char pass[] = "Your Passwd";

	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); // Change to your IP and Port.
	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-20)) {
	Blynk.virtualWrite(V2, 0);
	digitalWrite(relayPin, LOW); //Relay OFF (slider-10) to compensate if grinder overshoot "Grinder calibration".
	}
	}
	void loop()
	{
	Blynk.run();
	timer.run(); 
	}

The hardware and app
Using a green led on relay pin for testing. In real world project I will use a 5A WeMos D1 mini relay module or simmular.

2 Likes

#2

I like the project.

You should remove or hide your Blynk project id.

0 Likes

#3

He’s using a local server:

so not really an issue unless he publishes a way to access his public IP. It still makes me look twice when I see an auth code shared like that though! :dizzy_face:

Pete.

0 Likes

#4

You are both correct, in this case the project id is only for a local test server :wink:
What about the rest of the code, is it fairly structured and correct?

All advices will be taken and absorbed / Stefan

0 Likes

#5

Looks fine. It is a bit flat looking and harder to read without indentations.

I am a big fan of using files to organize the projects. It allows easy reuse of code.

I put all the blynk code in one tab, The HX11 code in one tab…

0 Likes

#6

Tnx will try to cleanup and edit my post.
I don’t like to spam this forum is it ok to post a link to my own website and The full coffee grinder project ?

https://www.stockholmviews.com/wp/weight-based-coffee-grinder-with-blynk-app

If I brake the rules just remove the link or inform me to do it :wink:

1 Like

#7

Since you are also including lots of project details and posts here in your own Projects made with Blynk Topic as well, then adding a link like that is just fine. It is when members just post 3rd party links that it losses that “part of the forum” feeling :slight_smile:

0 Likes

#8

@Greggan, Awesome project.

One thing I noticed when looking at your website. In the image below, you have a slight typo. On the relay you crossed the 5V and GND wires.

Also, the white text of the code makes it impossible to see against the white background.

Other then that, it looks great.

Happy BLYNKing!

0 Likes

#9

Every time I see this topic in the list of latest posts I think it’s a spam post advertising Grindr :face_with_raised_eyebrow:

I like what you’re doing here, and I guess it could have other uses as well if you need to dispense a certain amount of something (could also be liquid).

It seems you’re a fellow photographer and Nikon user as well :grinning:

I tried to look at your gallery, but it’s not displaying very well on Chrome. I did manage to get into some of the albums, which did display okay once I was in - nice!

Here’s some of mine if you’re interested…
https://www.peteknightphotography.com/

Pete.

1 Like

#10

Tnx for highlighting the x-wiring, it is now sorted out.
The project will go on for a while but I slowly getting there :grinning:

Kind regards/Stefan

0 Likes

#11

Pete you are above my level on photography for sure.
Thank you for highlighting the Gallery issue.
Gallery issue solved it was a bloddy plugin that wasn’t maintained properly :frowning:
Now it works My photo gallery if anyone cares.

1 Like