0

I am trying to read data from a load cell, and execute certain functions on the arduino (e.g. reset scale), all via bluetooth module HC-07. However, when I connect the bluetooth to the arduino with the sensor(Load cell, via HX711), Serial.read() does not work anymore. Not even when I connect it via USB COMport. It works via the USB COMport if I unplug the HC05 tx and rx. It works when the HX711 is not connected, and only HC05 is.

But I want to do everything wirelessly. Can SoftwareSerial help?

My connections,

The Load Cell is connected to an Amplifier- HX711, which is connected to the Arduino as:

Arduino pin 2 -> HX711 CLK

3 -> DOUT

5V -> VCC

GND -> GND

From Arduino to HC-05: (I know this is wrong because rx is 5V, but it works when HX711 is not attached)

Arduino Gnd -> Gnd

3.3 V -> Vcc

tx -> rx

rx -> tx

#include "HX711.h"
#define DOUT  3
#define CLK  2

HX711 scale(DOUT, CLK);

float calibration_factor = -2113;
float output;

void setup() {
  Serial.begin(9600);
  scale.set_scale();
  scale.tare();  //Reset the scale to 0

  long zero_factor = scale.read_average(); //Get a baseline reading
}

void loop() {

  scale.set_scale(calibration_factor); //Adjust to this calibration factor

  Serial.print("Reading: ");
  output=scale.get_units(10), 2;      //USES digitalRead and digitalWrite
  Serial.print(output);

//*********the following part does not work*********

  if(Serial.available())               
  {
    char temp = Serial.read();
    if(temp == '+' || temp == 'a')
      calibration_factor += 10;
    else if(temp == '-' || temp == 'z')
      calibration_factor -= 10;
    else if(temp == ' ')
      scale.tare();
  }
}

Please Help.

  • Which Arduino board? – Craig Jul 10 '18 at 22:08
  • @Craig I am using an Uno – Derangedmuon Jul 11 '18 at 6:24
  • When communicating via USB serial, unplug the HC-05 from the hardware serial, as two devices talking at the same line will get you in trouble. Can you check, if the program runs correctly, when using only USB serial and the HX711? – chrisl Jul 11 '18 at 23:05
  • The issue is resolved using Software Serial. Apparently rx,tx and pin 2,3 don't go well together. I will post a detailed update soon. – Derangedmuon Jul 12 '18 at 23:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.