Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serial monitor freezes on arduino uno when data or clock from HX711 is connected to the arduino digital data pin #243

Open
NiallMeade opened this issue Aug 5, 2022 · 0 comments

Comments

@NiallMeade
Copy link

Whenever I wire my components as shown and run the following code nothing is printed in the serial monitor but as soon as I remove any wires connected to the data pin ( digital pin 4) the arduino will begin printing and eventually starts printing the weight as 0. Even if I connect the clock wire to the data pin the serial monitor will freeze.

`
#include "HX711.h"

static const uint8_t DATA = 4;
static const uint8_t CLK = 3;

HX711 scale(DATA, CLK);

float calibration_factor = -14; // this calibration factor is adjusted according to my load cell
float units;
float ounces;

void setup() {
Serial.begin(9600);
Serial.println("HX711 calibration sketch");
Serial.println("Remove all weight from scale");
Serial.println("After readings begin, place known weight on scale");
Serial.println("Press + or a to increase calibration factor");
Serial.println("Press - or z to decrease calibration factor");

scale.set_scale();
scale.tare(); //Reset the scale to 0

long zero_factor = scale.read_average(); //Get a baseline reading
Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
Serial.println(zero_factor);
}

void loop() {

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

Serial.print("Reading: ");
units = scale.get_units(), 10;
if (units < 0)
{
units = 0.00;
}
ounces = units * 0.035274;
Serial.print(units);
Serial.print(" grams");
Serial.print(" calibration_factor: ");
Serial.print(calibration_factor);
Serial.println();

if(Serial.available())
{
char temp = Serial.read();
if(temp == '+' || temp == 'a')
calibration_factor += 1;
else if(temp == '-' || temp == 'z')
calibration_factor -= 1;
}
}`
wiring
serialmonitor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant