So I have recently bought a 100 gram loadcell with a couple of HX711 boards. I wired everything up to an arduino nano with a NRF24L01 module to send the raw values to another nano. When I first wired everything up, it worked fine. Values fluctuated a bit like normal and when a force was applied, the value increased.
But when I updated some code (removed the calibration and radio part), It stopped working for some reason.
I have it set up to write the values it measures to the serial monitor. When I apply a force, the number increases until a certain point. When that point is reached, the number drops down to the negative of that number and then when more force is applied, the number increases again to that positive number only to drop to the negative again.
All the wiring is correct, I have not changed anything. I have checked every wire. I think it is something with the loadcell, but I am not sure. What could the problem be? If more information is needed, let me know!
Circuit diagram, datasheet for loadcell, and code would help
How is the nano powered?
How is the HX711 powered?
Is there anything else connected to the nano?
#include "HX711.h"
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;
HX711 scale;
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
Serial.begin(57600);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
int reading;
void loop() {
if (scale.is_ready()) {
while (true) {
reading = scale.read();
Serial.print(reading);
radio.write(&reading, sizeof(reading));
delay(100);
}
} else {
Serial.print("HX711 not responding or no loadcell connected");
}
delay(500);
}
The nano is powered by a 3.7 volt, 2000mAh lipo battery. It was completely charged and I tried it with the nano powered from an adapter as well: the same behaviour. The HX711 is powered via the 5v pin from the nano. Besides the HX711, there is an NRF24L01 connected wich communicates with another nano over radio. I have even disconnected the NRF to test just the loadcell. The Serial monitor shows the exact same behaviour. I know it is best to power the modules from a good 5v source and not from the 5v pin of the nano. In this case, the 5v pin of the nano does not even deliver 5v because of the 3.7 volt battery. But the strange thing is, is that it worked before...
It doesn't seem to contain a datasheet, but here is the description:
Weighing range: 0-100g Rated power: 0.6 ± 0.15 mv/v Nonlinearity: 0.03% F.S Hysteresis: 0.03% F.S Repeatability: 0.03% FS Creep: 0.03% FS/3min Zero Temp.effect:0.03%FS/10°C Temp.effect on range:0.03%FS/10°C Zero balance: ±0.1mv/v Input Impedance: 1090±10Ω Output Impedance: 1090±10Ω Insulation resistance: ≥2000 (100VDC) MΩ Recommended excitation voltage: 3 -10VDC Allowable Excitation Voltage: 3-18VDC Compensation temperature range: -10°C-+60°C Operating temperature range: -10°C-+40°C Safe Overload: 120% F.S Ultimate Overload: 150% F.S
I do not have a cirquit diagram, but I have wired the red wire of the loadcell to E+, the black wire to E-, the white wire to A- and the green wire to A+. the GND pin is connected to the groundpin of the arduino, the vcc is connected to 5v, the SCK is connected to d3, and DT to d2. The battery vcc is connected to Vin on the nano and ground to ground on the arduino.
It is outputting a negative value, that's normal. But that is not the cause of the problem. That is just a shift in numbers in software. The calibration happens when the other nano is powerd up. That nano receives the value and sees that value as the zero-offset.
That is quite strange because I don't know how it worked at all.
If you expect your set-up to work correctly all the time then you need to supply the correct voltages to all the components.
5V for the nano, 5V for the HX711. Until you do that you will just be chasing your tail trying to figure out what is wrong.
Would it be a good idea to add a boostconverter to the circuit? I have some laying around that can convert low voltages such as 2.7 to 3, 5, 9 or 12 volts.
My problem is by far the space inside the project. The arduino, battery, nrf-module, loadcell, hx711 and chargingboard (and step-up module) need to fit in a space just a bit smaller than the inside of a bicycle cardbox.
But as I said earlier, the circuit does exactly the same thing when connected to 5v from a reliable power source. How is that possible? That let's me think, the problem is not the voltage in this case..
I know how a calibration works. You put a known weight on the scale etc. But that should not be the problem here. However, I have just tried to use the basic example and that works like normal. I had changed the reading variable from long to int. It seems that fixed the problem for now.
The usb port. I have powered it with the usbport to an adapter capable of delivering 3 amps. But I have found this issue is software related. I changed the reading variable from long to int. That caused the weird limiting thing I described in my first post.