-
Tu Carrito de Compras está vacío!
Garcias por tu conocimiento
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:
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.
Para comenzar a realizar este proyecto es importante tener claro cómo funciona el dispositivo principal, nos referimos al sensor de peso:
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:
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:
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.
#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.
@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
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.
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 & help different users like its helped me. Good job.
Ahaa, its good discussion about this article at this place at this blog, I have read all that, so now me also commenting here.
A ccouple of years ago, Stirrch rran an edit-a-thon at the Smithsonian to develop Wikipedia write-ups for females in scientific research.
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.
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
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!
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!
Fine way of describing, and fastidious paragraph to obtain information regarding my presentation topic, which i am going to convey in school.
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!
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.
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.
I am sure this article has touched all the internet viewers, its really really nice piece of writing on building up new weblog.
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
I aam sufe thiis piecce oof writig haas touched alll the internet visitors, itts reaally realky goo post onn buiding upp neew blog.
Greetings! Very helpful advice in this particular article! It is the little changes that make the most significant changes. Thanks for sharing!
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.
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.
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.
This is a topic that's close to my heart... Take care! Exactly where are your contact details though?
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.
I am sure this post has touched all the internet viewers, its really really pleasant piece of writing on building up new web site.
Asking questions are genuinely pleasant thing if you are not understanding anything completely, however this paragraph provides nice understanding even.
Hi, I check your blogs like every week. Your writing style is witty, keep up the good work!
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.
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.
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
There is definately a great deal to learn about this topic. I love all of the points you've made.
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.
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.
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