Hi everyone,
I'm using a Teensy 3.6 with a project involving load cell. I hooked up Teensy with HX711 load cell amplifier from Sparkfun.
Here is the webpage: https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide
My hardware setup is (the default setup suggested in the hookup guide):
Teensy HX711
3.3V-----------------VCC
GND-----------------GND
Pin 2-----------------CLK
Pin 3-----------------DAT
My code is:
My trouble is that everytime I upload this code into Teensy 3.6, the serial COM disappears. I have no problem when I use this Teensy for other projects. It seems this code or hardware setup confuses the Teensy. I have to follow the troubleshooting guide (disconnect Teensy, hold the reset button without plugging in the cable, connect Teensy and release the button) to get my Teensy be recognized again. At the first time, I thought the main core was dead and fortunately I found this procedure to reboot. I tried using different pins but didn't help. After every failed attempt, I have to reboot Teensy to get it work again.
I have used this HX711 and my load cell with arduino Nano and Teensy 3.2 (exactly same setup and code), and there is no problem. I don't understand why the serial port disappears after I upload this code. I attached two pictures showing before and after uploading.
Please help or provide insights! Thank you!
I'm using a Teensy 3.6 with a project involving load cell. I hooked up Teensy with HX711 load cell amplifier from Sparkfun.
Here is the webpage: https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide
My hardware setup is (the default setup suggested in the hookup guide):
Teensy HX711
3.3V-----------------VCC
GND-----------------GND
Pin 2-----------------CLK
Pin 3-----------------DAT
My code is:
Code:
#include "HX711.h"
#define DOUT 3
#define CLK 2
HX711 scale(DOUT, CLK);
float calibration_factor = -58970;
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: ");
Serial.print(scale.get_units(), 3);
Serial.print(" lbs"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
Serial.print(" calibration_factor: ");
Serial.print(calibration_factor);
Serial.println();
if(Serial.available())
{
char temp = Serial.read();
if(temp == '+' || temp == 'a')
calibration_factor += 100;
else if(temp == '-' || temp == 'z')
calibration_factor -= 10;
}
}
My trouble is that everytime I upload this code into Teensy 3.6, the serial COM disappears. I have no problem when I use this Teensy for other projects. It seems this code or hardware setup confuses the Teensy. I have to follow the troubleshooting guide (disconnect Teensy, hold the reset button without plugging in the cable, connect Teensy and release the button) to get my Teensy be recognized again. At the first time, I thought the main core was dead and fortunately I found this procedure to reboot. I tried using different pins but didn't help. After every failed attempt, I have to reboot Teensy to get it work again.
I have used this HX711 and my load cell with arduino Nano and Teensy 3.2 (exactly same setup and code), and there is no problem. I don't understand why the serial port disappears after I upload this code. I attached two pictures showing before and after uploading.
Please help or provide insights! Thank you!