Skip to content
Snippets Groups Projects
Commit e376d742 authored by Augustin Jaujay's avatar Augustin Jaujay
Browse files

Upgrade vers x sondes

parent 9164dc08
Branches master
No related tags found
No related merge requests found
/*
Example using the SparkFun HX711 breakout board with a scale
By: Nathan Seidle
SparkFun Electronics
Date: November 19th, 2014
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
This example demonstrates basic scale output. See the calibration sketch to get the calibration_factor for your
specific load cell setup.
This example code uses bogde's excellent library: https://github.com/bogde/HX711
bogde's library is released under a GNU GENERAL PUBLIC LICENSE
The HX711 does one thing well: read load cells. The breakout board is compatible with any wheat-stone bridge
based load cell which should allow a user to measure everything from a few grams to tens of tons.
Arduino pin 2 -> HX711 CLK
3 -> DAT
5V -> VCC
GND -> GND
The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.
*/
#include "HX711.h"
#define calibration_factor -7050.0 //This value is obtained using the SparkFun_HX711_Calibration sketch
HX711 probe1;
HX711 probe2;
HX711 probe3;
HX711 probe4;
HX711 probe5;
HX711 probe6;
int probes[] = {probe1, probe2, probe3, probe 4, probe5, probe6};
#define DOUT 3
#define CLK 2
// PARAMETERS TO SET DEPENDING ON YOUR CIRCUIT
HX711 scale1;
#define calibration_factor -7050.0 // Change it if you used the "Calibration" script
int nbProbes = 1; // Numbre of probes connected to the board
// Pins used by the probes
int DOUTs[] = {3, 0, 0, 0, 0, 0};
int CLKs[] = {2, 0, 0, 0, 0, 0};
void setup() {
Serial.begin(9600);
/*
Bloc d'instruction pour initialiser la connexion à une sonde :
Créer autant d'objets "scaleX" qu'il y a de sondes.
Instructions to initialize the probe objects :
Makes nbProbes probe objects working.
*/
scale1.begin(DOUT, CLK);
scale1.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale1.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
for (int i = 0; i < nbProbes; i++) {
probes[i].begin(DOUTs[i], CLKs[i]);
probes[i].set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
probes[i].tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0
}
}
void loop() {
// L'ordre de lecture est donné par l'application Cordova
// Reading order is given by Cordova (by the serial bus)
if (Serial.available() > 0) {
// Utilisation de la bibliothèque pour lire la valeur de la sonde scale1
Serial.print(scale1.get_units(), 1); //scale.get_units() returns a float
// Using the library to read the values of the probes
for (int i = 0; i < nbProbes; i++) {
Serial.println(probes[i].get_units(), 1); //scale.get_units() returns a float
}
// On vide le buffer avant de recevoir un nouvel ordre de lecture.
// Making the buffer empty befire receiving a new order from Cordova
while (Serial.available() > 0) {
Serial.read();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment