Fraise  2.1
FRAmework for Interfacing Software and Electronics

load cell amplifier module More...

load cell amplifier module

Example :

config.h :

#ifndef _CONFIG_H_
#define _CONFIG_H_
// hx711 config:
#define HX711_SCK_PIN K1 // hx711 serial clock on K1 pin
#define HX711_DATA_PIN K2 // hx711 seria data on K2 pin
#endif // _CONFIG_H_

main.c :

/*********************************************************************
* hx711 example for Versa1.0
*********************************************************************/
#define BOARD Versa1
#include <fruit.h>
#include <hx711.h>
//----------- Setup ----------------
void setup(void) {
hx711Init(0); // init hx711 module, gainA=128
}
// ---------- Main loop ------------
void loop() {
fraiseService();// listen to Fraise events
hx711Service(); // hx711 service routine
}
// ---------- Receiving ------------
void fraiseReceive() // receive raw bytes
{
int i;
unsigned char c=fraiseGetChar(); // get first byte
if(c == 50) { // if first byte is 50
c=fraiseGetChar(); // read channel byte
printf("C 50 %d %ld\n", c, hx711Read(c)); // return selected channel current value
}
}

Initialization

void hx711Init (unsigned char gainA)
 Init the module in setup() More...
 

Main loop functions

void hx711Service ()
 Module service routine, to be called by the main loop().
 

Utilities

long hx711Read (unsigned char channel)
 Read last measure of a channel. More...
 

Function Documentation

◆ hx711Init()

void hx711Init ( unsigned char  gainA)

Init the module in setup()

Parameters
gainAchannel A gain selection : 0=128 1=64

◆ hx711Read()

long hx711Read ( unsigned char  channel)

Read last measure of a channel.

Parameters
channelchannel selection : 0=A 1=B
Returns
current measure
hx711.h
hx711Service
void hx711Service()
Module service routine, to be called by the main loop().
loop
void loop()
User defined forever loop.
fruitInit
void fruitInit(void)
Init fruit module at setup().
hx711Init
void hx711Init(unsigned char gainA)
Init the module in setup()
fruit.h
fraiseService
void fraiseService(void)
Fraise device service routine.
hx711Read
long hx711Read(unsigned char channel)
Read last measure of a channel.
fraiseReceive
void fraiseReceive()
Raw message to this device.
setup
void setup()
User defined initialization.
fraiseGetChar
unsigned char fraiseGetChar()
Get next char from receive buffer.