Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Arduino
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
20-projet-ce-2020
Arduino
Commits
e376d742
Commit
e376d742
authored
4 years ago
by
Augustin Jaujay
Browse files
Options
Downloads
Patches
Plain Diff
Upgrade vers x sondes
parent
9164dc08
Branches
master
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Mesure/Mesure.ino
+28
-30
28 additions, 30 deletions
Mesure/Mesure.ino
with
28 additions
and
30 deletions
Mesure/Mesure.ino
+
28
−
30
View file @
e376d742
/*
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'i
nstruction
pour
initiali
ser la connexion à une sonde
:
Créer autant d'objets "scaleX" qu'il y a de sondes
.
I
nstruction
s to
initiali
ze 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
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment