How to control hx711 sensor and connect arduino to blynk app in the same code

Hi, im currently using Arduino_Serial_USB to connect my arduino to blynk app, and im using another code on arduino to read a hx711 thats reading a weight cell, i want to know if there is a possibility of read hx711 in the same code that im using to connect my arduino to blynk app, and than send the data that goes to serial monitor arduino to some widget box.

Code on Arduino to control hx711:


// HX711 circuit wiring
const int celula_carga_DOUT_PIN = 7;
const int celula_carga_SCK_PIN = 6;

HX711 scale;

void setup() {
  Serial.begin(9600);
  scale.begin(celula_carga_DOUT_PIN ,celula_carga_SCK_PIN);
  scale.tare();
}

void loop() {
  scale.set_scale(-45000);

  if (scale.is_ready()) {

    Serial.print(scale.get_units(), 1);
    Serial.println();
  }
  delay(1000);
 
}

Code Arduino_Serial_USB:



// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#include <BlynkSimpleStream.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";


void setup()
{
  // Debug console
  DebugSerial.begin(9600);

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);
}

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

@iasi please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

Thank you Pete :wink:

There are lots of existing HX711 Blynk projects if you search. It’s probably easier to convert one of those to BlynkSimpleStream, but if you’d prefer to use your sketches then read this…

Pete.

1 Like