-->
Page 1 of 6

JP eScale : an internet connected bathroom scale

PostPosted: Sun Jul 19, 2015 6:58 am
by freedom2000
Hi all,

Here is my latest realization : a eConnected bathroom scale.

[youtube=XOOPPMxXoks][/youtube]

It's using the cheap HX711 which is a load cell amplifier.

HX711_ESP8266.jpg


The load cell of the original scale is directly connected to HX711

load_cell.jpg


The ESP8266 board is reading this sensor, averaging the raw values and then outputs the weight to LCD and to thingspeak.com.

The Talkbackfuntionnality is used to control the board and perform :
- tare (zero offset)
- weight calibration
- memory of 5 persons

Here is the code to read the sensor :

Code: Select all/*
 HX711 raw reading
by http://freedom2000.free.fr
 */


// the setup function runs once when you press reset or power the board
unsigned long Weight = 0;
unsigned long AverageWeight = 0;
   int Clock = 5; //4 on board
   int Dout = 4; //5 on board
   
void setup()
{
  //intialize HX711
  pinMode(Clock, OUTPUT); // initialize digital pin 4 as an output.(clock)

  digitalWrite(Clock, HIGH); 
  delayMicroseconds(100);   //be sure to go into sleep mode if > 60µs
  digitalWrite(Clock, LOW);     //exit sleep mode*/

  pinMode(Dout, INPUT);  // initialize digital pin 5 as an input.(data Out)
     
  Serial.begin(115200); // initialize serial communication at 9600 bits per second:
  Serial.println("ready");
  delay(100);
}

// the loop function runs over and over again forever
void loop()
{
  // wait for the chip to become ready
 while (digitalRead(Dout) == HIGH);

 AverageWeight = 0;
  for (char j = 0; j<100; j++)
  {
     Weight =0;
    // pulse the clock pin 24 times to read the data
    for (char i = 0; i<24; i++)
    {
      digitalWrite(Clock, HIGH);
      delayMicroseconds(2);
      Weight = Weight <<1;
      if (digitalRead(Dout)==HIGH) Weight++;
      digitalWrite(Clock, LOW);
    }
    // set the channel and the gain factor (A 128) for the next reading using the clock pin (one pulse)
    digitalWrite(Clock, HIGH);
    Weight = Weight ^ 0x800000;
    digitalWrite(Clock, LOW);
    AverageWeight += Weight;
    delayMicroseconds(60);
  }
  AverageWeight = AverageWeight/100;
  Serial.println(AverageWeight);
  Serial.println("");
  delay(1000);
}



I only give the raw reading of the sensor, all the other stuff to connect to thingspeak has already been several times explained (and thanks for that !)

JP

Re: JP eScale : an internet connected bathroom scale

PostPosted: Sun Jul 19, 2015 7:00 am
by freedom2000
Sorry the video link was not working ...



JP

Re: JP eScale : an internet connected bathroom scale

PostPosted: Wed Jul 29, 2015 5:52 am
by churchill
Parfait, je voulais justement en faire une ! Thank you.
(edit) Juste une question, comment détectes-tu l'allumage de la balance ?
Just a question, how do you detect the start of scale ?

Re: JP eScale : an internet connected bathroom scale

PostPosted: Mon Aug 10, 2015 3:37 pm
by freedom2000
HI,

I don't detect the On/Off I simply use a switch that was already there in the "foot" of the scale to switch On/off the power supply (bat) of the scale.
As simple as that !

JP