¿Cómo hacer una balanza digital con Arduino?

Por: wadmin 27/01/2022 32 Comentarios Proyectos de electrónica,

BALANZA DIGITAL CON ARDUINO

 

 

 

 

Hoy en día existe una gran variedad de balanzas digitales comerciales, que son económicas y muy precisas para su valor. Entonces, ¿Qué sentido tiene realizar una balanza digital con Arduino? Bueno aquí te dejamos unas cuantas razones:

 

 

1. Como proyecto de escuela o universidad.
2. Para mejorar tus habilidades de programación.
3. Para realizar la balanza con las medidas y precisión que quieras.
4. Para comprender cómo funciona un sensor de peso y una galga extensiométrica.
5. Para agregar componentes que desees, luces, pantallas, botones y lo que se te ocurra.
6. Para poder conectarlo a otros dispositivos y hacer tu propio sistema implementando IoT.

 

Estas y muchas otras razones son motivo suficiente para que hagas tu propia balanza digital, lo que le quieras agregar a futuro queda a tu imaginación.

 

 

 

 

 

 

MATERIALES:

 

 

Implementos para la maqueta (Madera, plástico, etc.)
Sensor de peso 1kg/5kg/10Kg/20kg
Tornillos (a conveniencia)
Arduino Nano/Uno/Mega
Cables para conexiones
LCD 16x02 con I2C
Placa perforada
Switch ON/OFF
Módulo HX711
Batería 9V

 

 

 

 

Modelo 3D de la base ----> Descarga aquí

 

 

 

 

Para comenzar a realizar este proyecto es importante tener claro cómo funciona el dispositivo principal, nos referimos al sensor de peso:

 

 

 

Sensor de peso de 5Kg

 

 

 

En el interior de este sensor de peso podemos encontrar una galga extensiométrica, se trata de un sensor que varía su resistencia al aplicar una fuerza sobre él, esto lo hace ser un sensor pasivo. Mediante las variaciones de resistencia podemos medir la variación de voltaje que produce con el siguiente circuito:

 

 

 

Puente de Wheatstone

 

 

 

Este es un puente de Wheatstone utilizado para medir valores de resistencias mediante un equilibrio. Sin embargo, el análisis de un puente de Wheatstone queda fuera del alcance de este proyecto.

 

 

 

 

Lo siguiente sería conectar el sensor de peso a nuestro módulo HX711, un convertidor ADC que facilitará la comunicación y la medición de valores con nuestro microcontrolador.

 

 

 

 

 

 

Ahora debemos conectar nuestra LCD 16X02 con el módulo i2C al Arduino, (utilizaremos el módulo i2C para facilitar las conexiones, esto nos ahorrará mucho tiempo y espacio en nuestro Arduino). Estas son las conexiones:

 

 

 

 

 

 

Al terminar estas conexiones, podemos empezar a preparar el IDE de ARDUINO para cargar el programa. Para esto debemos instalar las siguientes librerías: 

 

 

Liquid_Crystal_I2C ---->  Descarga aquí
Queuetue_HX711_Library ----> Descarga aquí

 

 

 

 

Para instalar la librería de Liquid_Crystal_I2C debemos seguir estos pasos:

 

 

Paso 1:

“Abrir la ubicación del archivo” donde está instalado el IDE ARDUINO

 

 

 

 

 

 

Paso 2:

Abrir la carpeta “libraries” y eliminar la carpeta que dice “LiquidCrystal”, (porque esta librería interfiere con la de “LiquidCrystal_I2C-Master”), así que es necesario eliminar o remover esta carpeta, para poder colocar aquí la nueva librería.

 

 

 

 

 

 

 

 

 

Al finalizar la instalación de las librerías “Liquid_Crystal_I2C” y “Queuetue_HX711_Library” ya tenemos todo listo para cargar el programa a nuestro Arduino.

 

 

Código para Arduino ----> Descarga aquí

 

 

CÓDIGO:

 

 


#include <Wire.h> 
#include <Q2HX711.h>     //Libreria para HX711, debe ser instalada   
#include <LiquidCrystal_I2C.h>  //Libreria para LCD con I2C, debe ser instalada
LiquidCrystal_I2C lcd(0x27,20,4); //Si tu LCD no funciona prueba con 0x3f en lugar de 0x27

const byte DT = 3;    //Pin de datos HX711
const byte CLK = 2;   // Reloj de HX711
int push_tara = 8;    // Boton para el proceso tara
int escala = 11;      //Boton para cambiar la escala
Q2HX711 hx711(DT, CLK); // instancia de la libreria de HX711

/***********VARIABLES DEL PROGRAMA******************/

/*La variable masa_calibracion debe ser cambiada por el valor en gramos de la masa de calibracion
*si tu masa de calibracion pesa 254 gramos deberias cambiar el valor de masa_calibracion=254;
*es importante que estes seguro de la masa real del objeto, para que la balanza sea mas precisa 
 */
float masa_calibracion = 400.0; // Cambiar por el valor en gramos de la masa conocida de calibracion
//////////////////////////////////////////////////////////

long x1 = 0L;
long x0 = 0L;
float n_promedio = 10.0; // Aumentar este valor si se desea mas precision en la balanza
float tara = 0;
bool estado_tara = false;
bool estado_escala = false;
int modo = 0;
float oz_conversion = 0.035274; //Conversion para onzas, se pueden agregar mas conversiones
//////////////////////////////////////////////////////////

 

void setup() {
  Serial.begin(9600);                 // Inicia el puerto serial a 9600 baudios
  PCICR |= (1 << PCIE0);              //Escaneo PCMSK0                                                 
  PCMSK0 |= (1 << PCINT0);            //pin D8 como trigger para la interrupcion
  PCMSK0 |= (1 << PCINT3);            //pin D10 como trigger para la interrupcion.   
  pinmodo(push_tara, INPUT_PULLUP);
  pinmodo(escala, INPUT_PULLUP);

  lcd.init();                         //Inicializa el LCD 16X02
  lcd.backlight();                    //Activa la luz de fondo
  
  delay(1000);                 

  
  // Proceso TARA
  for (int ii=0;ii<int(n_promedio);ii++){
    delay(10);
    x0+=hx711.read();
  }
  
  x0/=long(n_promedio);
  Serial.println("Agregar masa");
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(" Agregar masa ");
  lcd.setCursor(0,1);
  lcd.print(" de calibracion      ");
 
  
  // Comienza el proceso de calibracion con la masa que se establecio en masa_calibracion
  int ii = 1;
  while(true){
    if (hx711.read()<x0+10000)
    {
      //No hace nada si no detecta masa
    } 
    else 
    {
      ii++;
      delay(2000);
      for (int jj=0;jj<int(n_promedio);jj++){
        x1+=hx711.read();
      }
      x1/=long(n_promedio);
      break;
    }
  }
  Serial.println("Calibration Completada");
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("  Calibracion  ");
  lcd.setCursor(0,1);
  lcd.print("    Completada    ");
}


void loop() {
  // promedio lectura
  long lectura = 0;
  for (int jj=0;jj<int(n_promedio);jj++)
  {
    lectura+=hx711.read();
  }
  lectura/=long(n_promedio);

  
  
  // cálculo de masa basado en calibración y ajuste lineal
  float ratio_1 = (float) (lectura-x0);
  float ratio_2 = (float) (x1-x0);
  float ratio = ratio_1/ratio_2;
  float masa = masa_calibracion*ratio;

  if(estado_tara)
  {
    tara = masa;
    estado_tara = false;
    Serial.print("ESPERE");
    Serial.print(".");
    lcd.setCursor(0,0);
    lcd.print("      ESPERE      ");
    lcd.setCursor(0,1);
    lcd.print("      .         ");    
    delay(300);
    Serial.print(".");
    lcd.setCursor(0,0);
    lcd.print("      ESPERE      ");
    lcd.setCursor(0,1);
    lcd.print("      ..        "); 
    delay(300);
    Serial.println(".");
    lcd.setCursor(0,0);
    lcd.print("      ESPERE      ");
    lcd.setCursor(0,1);
    lcd.print("      ...       "); 
    delay(300);   
  }
  if(estado_escala)
  {
    modo = modo + 1;
    estado_escala = false;
    if(modo > 2)
    {
      modo = 0;
    }
  }
  
  if(modo == 0)
  {
    Serial.print(masa - tara);
    Serial.println(" gramos");
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("     MASA     ");
    lcd.setCursor(0,1);
    lcd.print(masa - tara);
    lcd.print(" gramos"); 
  }
  else if(modo == 1)
  {
    Serial.print(masa - tara);
    Serial.println(" mililitros");
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("     MASA     ");
    lcd.setCursor(0,1);
    lcd.print(masa - tara);
    lcd.print(" mililitros");
  }
  else
  {
    Serial.print((masa - tara)*oz_conversion);
    Serial.println(" onzas");
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("     MASA     ");
    lcd.setCursor(0,1);
    lcd.print((masa - tara)*oz_conversion);
    lcd.print(" onzas");
  }
  
}//void loop


//INTERRUPCIONES
ISR(PCINT0_vect)
{
  if (!(PINB & B00000001))
  {
    estado_tara = true;           //BOTON TARA
  }
  
  if (!(PINB & B00001000))
  {
    estado_escala = true;         //BOTON DE ESCALA
  }
}

 

 

 

 

Una vez cargado el código a tu Arduino, puedes conectar los últimos componentes al proyecto, de esta forma:

 

 

 

 

 

 

Para finalizar solo tienes que poner a prueba la balanza, cuando la enciendas veras que en el LCD te aparecen unas letras que dicen “Agregar masa de calibración”

 

 

 

 

 

 

Cuando aparezca esto en pantalla, debes colocar sobre la balanza una masa de la cual conozca su peso en gramos. El valor de esta masa conocida lo debes anotar también en el código de programación, específicamente en esta parte:

 

 

 

/***********VARIABLES DEL PROGRAMA******************/

/*La variable masa_calibracion debe ser cambiada por el valor en gramos de la masa de calibracion
*si tu masa de calibracion pesa 254 gramos deberias cambiar el valor de masa_calibracion=254;
*es importante que estes seguro de la masa real del objeto, para que la balanza sea mas precisa 
 */

float masa_calibracion = 400.0; // Cambiar por el valor en gramos de la masa conocida de calibracion
//////////////////////////////////////////////////////////

 

 

 

 

Al agregar la masa de calibración el programa realizará una calibración lineal.

 

 

 

 

 

 

Al finalizar la calibración, el programa mostrará en pantalla “Calibración completada” y a partir de este momento ya puedes pesar la cantidad de objetos que quieras, siempre y cuando no excedan el valor que establece tu sensor de peso. Nosotros utilizamos uno de 5kg, así que podremos medir masas como máximo de 5kg.

 

 

 

 

 

 

 

VÍDEOS RELACIONADOS:

 

 

@laelectronicagt #Balanza #Bascula #Digital #Arduino ♬ Pascal Letoublon - Friendships(Remix) - 杨邪

 

 

@laelectronicagt Este es el avance de nuestra #balanza #digital con #Arduino ♬ Spongebob Tomfoolery - Dante9k Remix - David Snell

 

 

@laelectronicagt

 

♬ FUTURE HOUSE - Sergey Wednesday

 

 

@laelectronicagt #electronica #maker #diy #arduino #ingenieria #electronics ♬ Monkeys Spinning Monkeys - Kevin MacLeod & Kevin The Monkey

 

32 Comentarios

VICTOR HEBERT:
28/04/2022, 04:50:56 PM
Responder

Garcias por tu conocimiento

Kimberly Dixon:
03/12/2025, 08:41:29 AM, playastronaut.cc
Responder

I will right away take hold of your rss as I can not to find your e-mail subscription hyperlink or e-newsletter service. Do you have any? Please permit me recognise so that I may just subscribe. Thanks.

Andrew Chambers:
06/12/2025, 11:02:48 AM, zolomeds.shop/zoloft-cost.html
Responder

What's Taking place i'm new to this, I stumbled upon this I've discovered It positively useful and it has helped me out loads. I'm hoping to contribute &amp; help different users like its helped me. Good job.

Carol Cruz:
Responder

Ahaa, its good discussion about this article at this place at this blog, I have read all that, so now me also commenting here.

Robert Dean:
Responder

A ccouple of years ago, Stirrch rran an edit-a-thon at the Smithsonian to develop Wikipedia write-ups for females in scientific research.

Sarah Anderson:
30/01/2026, 01:16:44 PM, medshop24h.top/zoloft
Responder

I enjoy what you guys tend to be up too. This kind of clever work and coverage! Keep up the great works guys I've added you guys to our blogroll.

Daisy Thomas:
30/01/2026, 08:37:34 PM, propeciaa.sbs/dutasteride.html
Responder

I wanted to thank you for this very good read!! I absolutely enjoyed every bit of it. I've got you saved as a favorite to check out new things you

Kenneth Estrada:
01/02/2026, 10:29:11 PM, kamagras.shop
Responder

Hola! I've been following your website for some time now and finally got the courage to go ahead and give you a shout out from Lubbock Tx! Just wanted to tell you keep up the great job!

Karl Price:
04/02/2026, 10:53:54 AM, metamedline.shop
Responder

Wow! This blog looks exactly like my old one! It's on a completely different topic but it has pretty much the same page layout and design. Outstanding choice of colors!

Mark Curry:
05/02/2026, 02:15:34 PM, gastromedix.shop/dexlansoprazole.html
Responder

Fine way of describing, and fastidious paragraph to obtain information regarding my presentation topic, which i am going to convey in school.

Dwarka call girls:
11/02/2026, 05:18:30 AM, in.ojolit.com/call-girls/delhi/dwarka
Responder

I would love the opportunity to contribute to your blog as a writer. Your content is both insightful and engaging, and I’m confident I could bring fresh, thoughtfully crafted articles that resonate with your audience. If you’re open to collaboration, I’d be glad to provide high-quality posts in exchange for a link back to my website. Please feel free to contact me by email if this interests you. I look forward to connecting with you!

Adam Livingston:
13/02/2026, 08:01:19 PM, arthromedix.online
Responder

I will right away take hold of your rss as I can’t in finding your email subscription link or newsletter service. Do you have any? Please allow me understand so that I could subscribe. Thanks.

Joel Santos:
14/02/2026, 09:38:34 AM, minoximed.online
Responder

Hi, I do believe this is an excellent web site. I stumbledupon it ;) I may return once again since I book marked it. Money and freedom is the greatest way to change, may you be rich and continue to guide other people.

Christopher Smith:
08/04/2026, 10:52:42 AM, medshop24h.top/lamotrigine
Responder

I am sure this article has touched all the internet viewers, its really really nice piece of writing on building up new weblog.

Patricia Steele:
09/04/2026, 09:07:34 PM, gastromedix.shop/misoprostol.html
Responder

I needed to thank you for this excellent read!! I definitely loved every bit of it. I've got you book marked to look at new stuff you

Roger Meza:
11/04/2026, 08:57:18 AM, avanafil.online
Responder

I aam sufe thiis piecce oof writig haas touched alll the internet visitors, itts reaally realky goo post onn buiding upp neew blog.

Jose Andrews:
13/04/2026, 08:58:34 PM, edmedix.com
Responder

Greetings! Very helpful advice in this particular article! It is the little changes that make the most significant changes. Thanks for sharing!

Courtney Miller:
14/04/2026, 09:40:59 AM, tadaline.com
Responder

Ahaa, its fastidious dialogue about this piece of writing here at this webpage, I have read all that, so at this time me also commenting here.

Tammy Vasquez:
15/04/2026, 07:30:26 PM, edmedix.com/viagra.html
Responder

Hi, I do think this is a great web site. I stumbledupon it ;) I will return yet again since i have book marked it. Money and freedom is the greatest way to change, may you be rich and continue to guide others.

Jennifer Lee:
16/04/2026, 07:27:08 AM, edmedix.com/viagra-pills.html
Responder

I’ll immediately snatch your rss as I can not in finding your e-mail subscription hyperlink or e-newsletter service. Do you have any? Kindly permit me recognise in order that I may subscribe. Thanks.

Jonathan Ross:
16/04/2026, 05:49:03 PM, edmedix.com/sildenafil-citrate.html
Responder

This is a topic that's close to my heart... Take care! Exactly where are your contact details though?

Sean Mitchell:
16/04/2026, 10:43:36 PM, cilalisez.com
Responder

Ahaa, its nice discussion about this post here at this web site, I have read all that, so at this time me also commenting at this place.

Kristin Evans:
17/04/2026, 03:33:53 AM, edmedix.com/kamagra.html
Responder

I am sure this post has touched all the internet viewers, its really really pleasant piece of writing on building up new web site.

Samantha Cole:
17/04/2026, 08:00:15 AM, kamagras.shop/zudena
Responder

Asking questions are genuinely pleasant thing if you are not understanding anything completely, however this paragraph provides nice understanding even.

Troy Sanchez:
17/04/2026, 06:29:31 PM, cilalisez.com/cialis-generic.html
Responder

Hi, I check your blogs like every week. Your writing style is witty, keep up the good work!

Vanessa Robinson DVM:
18/04/2026, 03:15:21 AM, edmedix.com/viagra-for-men.html
Responder

You've made some really good points there. I checked on the net to find out more about the issue and found most people will go along with your views on this site.

Madeline Baker:
18/04/2026, 08:14:05 AM, cilalisez.com/tadalafil-20mg.html
Responder

What's up to all, how is all, I think every one is getting more from this website, and your views are nice in support of new users.

Madison Wright:
18/04/2026, 07:34:09 PM, edmedix.com/viagra-generic.html
Responder

I simply could not go away your site before suggesting that I really enjoyed the usual information a person supply in your visitors? Is gonna be again ceaselessly to check out new posts

Yolanda Harris:
19/04/2026, 06:11:35 AM, cilalisez.com/cialis-medication.html
Responder

There is definately a great deal to learn about this topic. I love all of the points you've made.

Justin Ross:
Responder

I'll right away grab your rss feed as I can not in finding your email subscription link or newsletter service. Do you have any? Please allow me realize so that I could subscribe. Thanks.

Richard White:
20/04/2026, 03:34:22 PM, cenforce.online
Responder

Hi, I do believe this is an excellent web site. I stumbledupon it ;) I am going to revisit yet again since I book-marked it. Money and freedom is the greatest way to change, may you be rich and continue to guide others.

Jeffrey Owens:
20/04/2026, 07:51:56 PM, vidalisted.shop
Responder

Howdy! Do you know if they make any plugins to protect against hackers? I'm kinda paranoid about losing everything I've worked hard on. Any tips? fake jerseys

Deja tu comentario