Usually, the signal from a Load Cell enters into a 24-bit Serial ADC. The Library function collects the data, processes it, and then saves it in a variable. What is the declaration of this variable? You can easily save that value in the SD Card.
You may follow this link for basic data read/write operation with SD Card.
Below is the code of the loadcell (without inputting it into the sd card) in case you might need it
#include "HX711.h" #define calibration_factor 209.0 //This value is obtained using the SparkFun_HX711_Calibration sketch #define DOUT 30 #define CLK 52
HX711 scale(DOUT, CLK);
void setup() {
Serial.begin(9600);
Serial.println("HX711 scale demo");
scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
Serial.println("Readings:");
}
void loop() {
Serial.print("Reading: ");
Serial.print(scale.get_units(), 1); //scale.get_units() returns a float
Serial.print(" g"); //You can change this to kg but you'll need to refactor the calibration_factor
Serial.println();
}
The thing is that when i test the load cell on its own i do get a reading, however when i included it together with the coding of the SD card it keeps on reading only '0'
could it be because i'm using SCK pin for both arduino and loadcell?
1. If you are using Arduino MEGA, the following is the recommended connection between the MEGA and SD Card. (Please recheck yourself the connection; 50, 51, 52 make the SPI Port.)
2. You must include SPI.h Library in your code, which is not there in your codes.
jra12222:
could it be because i'm using SCK pin for both arduino and loadcell?
Very likely fatal. I understand the sensor is not an SPI device, and therefgore should not be allowed on the SPI bus. The SCK pin does not define it as an SPI device. I imagine there is a swag of alternative pins.....
Thanks everyone! it all worked great! thanks a lot,
May I ask another question? I was under the impression that you had to connect both SCK pins of the load cell and the sd card to a respective SCK pin. However from what you told me, and from what I tried this was not the case.
Does this mean that any port can be turned into a Serial clock? does it need to be digital or can it be analogue as well?
Finally, how do I know when to use an analogue pin and when to use a digital pin?
excuse me for all the stupid questions, im just trying to learn a bit about arduino.