• Aucun résultat trouvé

[PDF] Tutoriel HX711 Arduino en pdf [Eng] | Cours Arduino

N/A
N/A
Protected

Academic year: 2021

Partager "[PDF] Tutoriel HX711 Arduino en pdf [Eng] | Cours Arduino"

Copied!
7
0
0

Texte intégral

(1)

HX711 Load Cell Amplifier Interface with

Arduino

(2)
(3)

Load Cell connections to HX711 and Arduino

(4)

Programming Arduino UNO to Measure Weight in Kgs

Calibration Sketch

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 /* * circuits4you.com * 2016 November 25

* Load Cell HX711 Module Interface with Arduino to measure weight in Kgs Arduino pin 2 -> HX711 CLK 3 -> DOUT 5V -> VCC GND -> GND

Most any pin on the Arduino Uno will be compatible with DOUT/CLK.

The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine. */

#include "HX711.h" //You must have this library in your arduino library folder #define DOUT 3 #define CLK 2 HX711 scale(DOUT, CLK);

//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands float calibration_factor = -96650; //-106600 worked for my 40Kg max scale setup

//============================================================================================= // SETUP //============================================================================================= void setup() { Serial.begin(9600); Serial.println("HX711 Calibration");

Serial.println("Remove all weight from scale");

Serial.println("After readings begin, place known weight on scale");

Serial.println("Press a,s,d,f to increase calibration factor by 10,100,1000,10000 respectively"); Serial.println("Press z,x,c,v to decrease calibration factor by 10,100,1000,10000 respectively");

(5)

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

Serial.println("Press t for tare"); 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); } //============================================================================================= // LOOP //============================================================================================= void loop() {

scale.set_scale(calibration_factor); //Adjust to this calibration factor

Serial.print("Reading: "); Serial.print(scale.get_units(), 3);

Serial.print(" kg"); //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 += 10; else if(temp == '-' || temp == 'z') calibration_factor -= 10; else if(temp == 's') calibration_factor += 100; else if(temp == 'x') calibration_factor -= 100; else if(temp == 'd') calibration_factor += 1000; else if(temp == 'c') calibration_factor -= 1000; else if(temp == 'f') calibration_factor += 10000; else if(temp == 'v')

(6)

77 78 79 80 81 82 calibration_factor -= 10000; else if(temp == 't')

scale.tare(); //Reset the scale to zero }

}

//=============================================================================================

1 scale.set_scale();

Final Code for Weight Measurement

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 /* * circuits4you.com * 2016 November 25

* Load Cell HX711 Module Interface with Arduino to measure weight in Kgs Arduino pin 2 -> HX711 CLK 3 -> DOUT 5V -> VCC GND -> GND

Most any pin on the Arduino Uno will be compatible with DOUT/CLK.

The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine. */

#include "HX711.h" //You must have this library in your arduino library folder #define DOUT 3 #define CLK 2 HX711 scale(DOUT, CLK);

//Change this calibration factor as per your load cell once it is found you many need to vary it in thousands float calibration_factor = -96650; //-106600 worked for my 40Kg max scale setup

(7)

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 //============================================================================================= // SETUP //============================================================================================= void setup() { Serial.begin(9600); Serial.println("Press T to tare");

scale.set_scale(-96650); //Calibration Factor obtained from first sketch scale.tare(); //Reset the scale to 0

} //============================================================================================= // LOOP //============================================================================================= void loop() { Serial.print("Weight: ");

Serial.print(scale.get_units(), 3); //Up to 3 decimal points

Serial.println(" kg"); //Change this to kg and re-adjust the calibration factor if you follow lbs

if(Serial.available()) {

char temp = Serial.read(); if(temp == 't' || temp == 'T')

scale.tare(); //Reset the scale to zero }

}

Références

Documents relatifs

Pour arriver à leur décision, les juges jouissent donc d’une certaine liberté dans l’exercice de ce pouvoir. Toutefois, rien ne garantit que leur décision sera la meilleure.

92 ( قحلملا 1 ) ةيلولأا هتروص يف ةيداشرلإا تاجاحلا نايبتسا داعبلأا تاـــــــــــــــــــــجاــــــحلا يناعأ لا هذه نم ةلكشملا اهنم يناعأ ةجردب ةطيسب اهنم

ﲪ ﺪﻴﻬﺸﻟﺍ ﺔﻌﻣﺎﺟ ـ ﺔﻴﺳﺎﻴﺴﻟﺍ ﻡﻮﻠﻌﻟﺍﻭ ﻕﻮﻘﳊﺍ ﺔﻴﻠﻛ ﻱﺩﺍﻮﻟﺍ ـ ﺮﻀﳋ ﺔ ﺔﺤﻔﺻ 171 ﻢـﻗر ﻲﺳﺎﺳﻻا نﻮﻧﺎﻘﻟا ﺎﻬﻴﻠﻋ ﺺﻧ ﺎﻣ ﺐﺴﺣ ﻲﺴﻧﻮﺘﻟا عﺮﺸﳌا ﺎﻫﺪﻤﺘﻋا ﱵﻟا ﺔﻣﺎﻌﻟا ةﺪﻋﺎﻘﻟا 38 ﺔﻨـﺴﻟ

Environ 700 dinars poids et divisions datés, dont certains fragmentaires, ont été publiés et un peu plus de 100 dirhams poids (7 dans la collection de la BNU).. Il semble que

Telle est la démarche que nous avons entreprise dans cet ouvrage : lire les textes conjointement avec une expérimentation de la pratique Feldenkrais, afin d’initier la

Pour n’en citer que quelques-unes des plus récentes tant les manifestations scientifiques sont nombreuses sur le thème des identités : « Identité/Identités, la

Nous procéderons dans un premier temps à une rapide description de chacune de ces villes, plus précisément des fragments urbains qui intègrent ces deux modes de relation du corps aux

Combattre l’ambiguïté Un mécanisme de propagation-extinction est utilisé sur les identités des initiateurs de bordures afin de ne garder qu’une segmentation pour tout les