BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Hx711 nodmcu super chart blynk 2.0

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();




}

That’s probably because of your void loop.
You are re-calibrating your scale dozens, if not hundreds of times per second, and trying to take readings from the scale at the same frequency.

You should be calibrating your scale once, then taking readings by calling a timed function.

I don’t really understand the question. Writing data to virtual pins is exactly the same in Blynk IoT as it was in Legacy.
My guess is that you haven’t specified sensible minimum and maximum values for your datastream(s), which is done in the Template section of the web dashboard.

Pete.

Thanks a lot!!! removed the calibration added a line - and it all worked!!! and all online!

Blynk.run();
  timer.run(); // Initiates BlynkTimer

   weight = scale.get_units(5);

  Blynk.virtualWrite(V1, weight);



  Serial.print("Weight: ");
  Serial.print(weight);
  Serial.println(" KG");
  Serial.println();

Noooooooooo!

Please take that offline now, you should never ever put a Blynk.virtualWrite in your void loop.

Read this…

https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

Pete.


  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,sensor);
}
void sensor()
{
         weight = scale.get_units(5); 
  Blynk.virtualWrite(V1, weight);  // sending sensor value to Blynk app
}

}

void loop()
{
  Blynk.run();
  timer.run(); 

  Serial.print("Weight: ");
  Serial.print(weight);
  Serial.println(" KG");
  Serial.println();




}

I’m not sure…maybe so???

Your void loop should contain JUST this…

Everything else should be in a function called with a timer.

Pete.

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,sensor);
}
void sensor()
{
         weight = scale.get_units(5); 

        Blynk.virtualWrite(V1, weight);  

Serial.print("Weight: ");
  Serial.print(weight);
  Serial.println(" KG");
  Serial.println();
}

}

void loop()
{
  Blynk.run();
  timer.run()

}

That’s the correct structure.

Pete.