Created
July 21, 2023 13:10
-
-
Save ypelletier/6314c3eaefa71451ab0f1c43bd3cfd4c to your computer and use it in GitHub Desktop.
Balance Raspberry Pi Pico / HX711
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Balance Raspberry Pi Pico / HX711 | |
Pour plus d'informations: | |
https://electroniqueamateur.blogspot.com/2023/07/peser-des-objets-avec-le-raspberry-pi.html | |
Ce script utilise le pilote hx711-pico-mpy par Daniel Robertson disponible ici: | |
https://github.com/endail/hx711-pico-mpy | |
''' | |
from machine import Pin | |
from hx711 import * | |
import time | |
# À modifier pour chaque cellule de charge: | |
zero = 49000 # soustraire cette valeur pour ajuster le zéro | |
conversion = 380.0 # diviser par cette valeur pour convertir en grammes | |
hx = hx711(Pin(14), Pin(15)) # clock broche GP14, data broche GP15 | |
hx.set_power(hx711.power.pwr_up) | |
hx.set_gain(hx711.gain.gain_128) # valeurs possibles 128, 64 ou 32. | |
while True: | |
hx711.wait_settle(hx711.rate.rate_80) # on attend qu'une mesure soit prête | |
valeur = hx.get_value() # on prend la mesure | |
valeur = (valeur - zero) / conversion # conversion en grammes | |
print('masse: ' , round(valeur), 'g') # affichage | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment