🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

tinygo.perri.to/hx711

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinygo.perri.to/hx711

v0.1.2
Go
Version published
Created
Source

hx711 LoadCell helpers for tinygo

This is a set of helpers to use a Load cell through a hx711 using tinygo, even though according to most device docs and C codes available indicate this should work in any version of these devices, I only tried it in one.

Special thanks to:

  • this repository who made the C++ version I based this code on.
  • this repository who made the original calibration i based this on.

Usage

package main

import (
	"tinygo.perri.to/hx711"
	"machine"
)

// Instantiate a device, this should be thread safe but don't push it
// 100 is a good smoothing factor, it is the number of reads that will be made in raw per Read call
// and averaged.
dev := hx711.New(machine.D4, machine.D5, hx711.Gain128, 100, 400) // in millis, is a good time to wait for the device

// the device is ready to use but i recommend calibrating:
// Once the device has been instantiated (that is a blocking call)
// Put a known weight and make a call to
dev.Calibrate(100.10) // weight in grams

// if you do this with multiple weights multiple times it should be more accurate.

// Finally get a read
weight := dev.Read()
fmt.Printf("whatever is on the scale is %d milligrams", weight)

The results are in centigrams, I assume this is true for all models, I only own one hx711 with a 1kg load cell.

FAQs

Package last updated on 15 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts