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

Wemos Esp32 Wroom + Hx711 + Loadcell

I’ve been breaking my head for 4 days and I can’t do it. It connects and stops … on Wifi and BLE it doesn’t even connect … crazy thing.
The project is super simple.
Read a load cell in real time … take measurements … via Bluetooth constantly.
Wemos Esp32 Werom with Hx711
If anyone is interested in consulting, call me here to set the fees.

These two statements seem to contradict each other.

If the device needs to be connected via Bluetooth constantly, where does WiFi come in to the equation?

Pete.

So, in fact I tried to make the connection via BLE which is the one I prefer. But as it didn’t work, or stopped constantly, I switched to Wifi, but this one (wifi) didn’t work either. I’m lost

There’s actually quite a big difference, certainly from a debugging point of view, between the connection not working at all and the connection working but then dropping - which I think is what you’re saying about your Bluetooth connection.

I don’t use Bluetooth with Blynk, as (1) it doesn’t fit-in to my use-case and (2) as far as I’m concerned the functionality isn’t reliable enough.
I for one would like to see Bluetooth dropped from the Blynk product, but it is possible that your disconnection issues are caused by bad coding.

As far as WiFi connectivity is concerned, this is extremely reliable when implemented correctly - assuming you have a good WiFi and internet setup.

Maybe if you shared the code that you’ve tried for both Bluetooth and WiFi connectivity, along with information about what you’re seeing in your serial monitor, then we’ll be able to help further.

Pete.

Okay.
I’ll upload the code and send the messages from the Monitor and the Code.
Thanks

Don’t forget to add triple backticks at the beginning and end of your code (and your serial output data) so that it displays correctly.
Triple backticks look like this:
```

Pete.

It does the serial reading. But, I can’t put it on BLYNK.
I would like to put it wifi, because as you told me it is much better

I gave you triple backticks to copy and paste, but you decided to use different characters that don’t work. Please edit your post, using the pencil icon at the bottom, and insert the correct characters.

Also, I’m interested in seeing the serial output immediately after the device connects to Bluetooth.

Pete.

#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "HX711.h"
#define BLYNK_PRINT Serial
#define DT_PIN 16
#define SCK_PIN 17
char val;
HX711 scale;
char auth[] = "er5HgampbYElxhe5GYRMROczXghY9t2I";
char ssid[] = "AP_Heros";
char pass[] = "03263683969";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  scale.begin(16, 17);
  scale.set_scale(40000);
  scale.tare();


}

void loop()
{
  Blynk.run(V5);
  delay(100);
}

Okay, it really would have been better if you’d have edited your previous post as I asked, rather leaving the unformatted code there.
As you haven’t done this I’ve deleted that previous post.

Also, when you’re posting serial monitor output it’s more helpful to copy and paste the content of the serial monitor (using CTRL-C) and paste it between triple backticks rather than posting screenshots.

The version of the code that you’ve posted no longer has the line Serial.println(scale.get_value(1),0); so it’s not taking any readings from your HX711.

Also, this line:

{
  Blynk.run(V5);

makes no sense.

Blynk requires the Blynk.run command to be in the void loop so that it executes each time the void loop is processed (which should be thousands of times per second with an ESP32.

If you wish to send data to pin V5 then this is done with the command Blynk.virtualWrite(V5, data) but this cannot be in the void loop!

Also, Blynk won’t tolerate delays in the void loop.

So, what you need to do is set-up a Blynk timer which will call a function on a regular basis (give some thought to how often the scale actually needs to be read and Blynk updated with the result. I’d guess that once per second would be more than sufficient).
The function should…

  • Read the weight of the scale and store the result in a variable.
  • Send the value of this variable to the serial monitor
  • Send the value of this variable to pin V5 in Blynk

If you read this document it explains how and why you need to use a timer…

There are some other issues with your code…

This line appears twice…

You are using variables to hold the pin numbers that will be used in the scale.begin command…

but then instead of saying…

scale.begin(DT_PIN , SCK_PIN );

you’re hard-coding the pin numbers…

This still works, but it makes the declaration of the DT_PIN and SCK_PIN redundant as well as confusing if you want to make changes in future.

Pete.

thank you very much for your attention. I will make all the changes. And then I warn you.

#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "HX711.h"
#define BLYNK_PRINT Serial
#define DT_PIN 16
#define SCK_PIN 17
char val;
HX711 scale;
char auth[] = "er5HgampbYElxhe5GYRMROczXghY9t2I";
char ssid[] = "gvthhg";
char pass[] = "147258369";

;

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  scale.begin(16, 17);
  scale.set_scale(40000);
  scale.tare();
  Serial.println(scale.get_value(1),0);

}

void loop()
{
  Blynk.run(V5);
  delay(100);
}

it connects now … but not read
the data

I’ve already explained to you why that is, and you’ve disregarded everything that I’ve said about the problems with your code.

Pete.

thanks for listening. But I actually tried to do everything that guided me. you know, I am a sport professional and I am starting in the IOT world. I’m a beginner. I’m sorry for not meeting your expectations, but I really sought out the community to try to improve and seek answers. Since here in the interior of Brazil do not have easy access to this information. Anyway, I’m still in my saga of the first project at Blynk. it will certainly not be the only one.

But the code you posted was the same as your original version.
If you’ve made changes then wouldn’t it make sense fort you to share them rather re-post your original code?
How can the community help if it’s members don’t know what your latest code looks like, and what results it generates?

Pete.