4 years my blynk worked at 100%!! but it’s time for 2.0 and I’m at a dead end… I’m an amateur and have not practiced for months, I don’t always understand all the nuances - but my small project worked for 4 years, and now I have a problem - there is no graph reading from my nodmcu and communication with the device disappears after 2 minutes… Correct my mistake, I don’t know how to specify a variable on V1, all examples are only on blynk 1.0
This example shows how value can be pushed from Arduino to
the Blynk App.
NOTE:
BlynkTimer provides SimpleTimer functionality:
http://playground.arduino.cc/Code/SimpleTimer
App project setup:
Value Display widget attached to Virtual Pin V5
*************************************************************/
// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID "TM"
#define BLYNK_DEVICE_NAME "g"
#define BLYNK_AUTH_TOKEN "tMdsqwYJcVVT"
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#include "HX711.h"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Gary";
char pass[] = "12345678";
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V1, millis() / 1000);
}
const int LOADCELL_DOUT_PIN = D3;
const int LOADCELL_SCK_PIN = D4;
HX711 scale;
float weight;
float calibration_factor = 3.85; // for me this vlaue works just perfect 419640
void setup()
{
// Debug console
Serial.begin(115200);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
// scale.tare(); //Reset the scale to 0
long zero_factor = scale.read_average(); //Get a baseline reading
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
scale.set_scale(calibration_factor); //Adjust to this calibration factor
weight = scale.get_units(5);
Serial.print("Weight: ");
Serial.print(weight);
Serial.println(" KG");
Serial.println();
}