En este post voy a explicar cómo podemos fabricarnos con una placa ARDUINO un sencillo barómetro cuyos datos serán grabados para su estudio posterior.
Un barómetro es un instrumento que sirve para medir la presión atmosférica. La presión atmosférica es una de las variables más importantes que los meteorólogos utilizan para analizar el estado del tiempo atmosférico y su posible evolución futura.
Básicamente la presión atmosférica es la medida del peso total del aire contenido en una columna de atmosfera cuya base sería un cuadrado de 1 metro de lado y cuya altura llegaría hasta donde la atmósfera dejara ya de existir. Como los físicos miden las fuerzas en Newtons, la medida de la presión se representa en Newtons por metro cuadrado, es decir la fuerza (peso) que ejerce la atmósfera sobre una superficie de 1 metro cuadrado.
La presión media ejercida por la atmósfera sobre la superficie del mar es de 101325 Pa (valor que representa 101325 N/m2 – 101325 Newtons por metro cuadrado- ) , que son , redondeando, 1013 hPa (hecto pascales) o lo que es lo miso 1013 mb (milibares). La presión ejercida por la atmósfera en una zona cualquiera de la Tierra variará con el tiempo alrededor de valores que pueden oscilarán entre 870 mb y 1083 mb. El estudio de estas variaciones nos informa del estado y evolución del tiempo atmosférico.
Los elementos que vamos a necesitar para fabricar nuestro barómetro son:
1 Placa ARDUINO UNO con su cable de programación
1 Shield Data Logger para ARDUINO UNO
1 Sensor de presión BMP180
1 Power Bank
1 Recargador de teléfono móvil de 5 V
En mi caso he utilizado un Power Bank de 10000 mAh con placa solar. El power bank tiene como objetivo garantizar la medida continua de la presión en caso de que haya un corte no muy largo de corriente donde estemos haciendo las medidas. La imagen siguiente (figura 1) presenta el Shield Data Logger insertado ya en la placa ARDUINO UNO
Figura 1. Shield Data Logger insertado en la placa ARDUINO UNO
El sensor BMP180 debe conectarse a la placa ARDUINO siguiendo el esquema de la figura adjunta (figura 2). La alimentación de este sensor es de 3.3 V y sus tomas CL y DA deben conectarse respectivamente a las entradas analógicas A5 y A4 de la placa ARDUINO
Figura 2. Conexiones del sensor de presión BMP180 a la placa ARDUINO
El aspecto final de nuestro barómetro puede tener la forma de la figura adjunta (figura 3) donde el Power Bank y el Barómetro ARDUINO se han colocado sobre una placa de metacrilato. La salida de 5V del Power Bank debe conectarse a la placa ARDUINO mediante el cable de programación de éste y posteriormente el recargador de 5V alimentará al POWER BANK. Debéis aseguraros de que el Power Bank que compréis proporcione corriente mientras esté cargando.
Figura 3. Aspecto final del barómetro ARDUINO sobre una placa de metacrilato
Para programar nuestra placa ARDUINO necesitaremos instalar en nuestro ordenador el software gratuito IDE de ARDUINO, que nos permitirá programar fácilmente la placa ARDUINO . Al final de este post encontraréis el código necesario para hacer funcionar el barómetro.
El código ARDUINO desarrollado utiliza las librerías siguientes
#include <Time.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
#include <SD.h>
#include <SFE_BMP180.h>
#include <Wire.h>
por lo que deberéis aseguraros de tenerlas instaladas en la lista de librerías de vuestro IDE de ARDUINO ( la única librerías que viene por defecto en IDE suele ser Wire.h , por tanto el resto de ellas bastará buscarlas en la red y bajarlas a vuestro ordenador).
Como el DATA LOGGER tiene un reloj incluido lo primero que tenéis que hacer es cargar vuestro ARDUINO con las mismas instrucciones que el código que se adjunta al final de este post pero eliminado los dos barras que aparecen delante de las líneas siguientes.
// setTime(17,52,0,11,11,2016);
// RTC.set(now());
Esa acción pondrá en hora el Shield Data Logger. Tras esta primera carga deberéis de nuevo recargar el código pero ya con dichas líneas encabezadas con las dos barras.
El programa adjunto crea en la tarjeta SD ,cada vez que se enchufa la placa ARDUINO, un fichero cuyo nombre es Data_1.txt y donde se anotarán todas las variables manejadas. Básicamente como se ve en la figura adjunta (figura 4) archivamos cada minuto:
HORA-MINUTO-SEGUNDO-DIA-MES-AÑO
Presión en décimas de mb
Temperatura en décimas de ºC que el sensor BMP180 también mide
Figura 4. Datos guardados por el Barómetro ARDUINO
CODIGO ARDUINO DEL BAROMETRO
#include <Time.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
#include <SD.h>
#include <SFE_BMP180.h>
#include <Wire.h>
// You will need to create an SFE_BMP180 object, here called “pressure”:
SFE_BMP180 pressure;
File Archivo;
void setup()
{
Serial.begin(9600);
setSyncProvider(RTC.get); // Vamos a usar el RTC
// —————————————-
//parece que se puede hacer solo una vez
//setTime(17,52,0,11,11,2016);
//RTC.set(now());
// —————————————–
if (timeStatus() != timeSet)
Serial.println(“Unable to sync with the RTC”);
else
Serial.println(“RTC has set the system time”);
pinMode(10, OUTPUT);
if (!SD.begin(10))
{
//Serial.println(“Se ha producido un fallo al iniciar la comunicacion”);
return;
}
Serial.println(“Se ha iniciado la comunicacion correctamente”);
//Se borra inicialmente el documento sobre el que se va a leer y escribir.
SD.remove(“data_1.txt”);
Serial.println(“REBOOT”);
// Initialize the sensor (it is important to get calibration values stored on the device).
if (pressure.begin())
Serial.println(“BMP180 init success”);
else
{
// Oops, something went wrong, this is usually a connection problem,
// see the comments at the top of this sketch for the proper connections.
Serial.println(“BMP180 init fail\n\n”);
while(1); // Pause forever.
}
}
void loop()
{
char status;
double T,P,p0,a;
String data1;
status = pressure.startTemperature();
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
status = pressure.getTemperature(T);
if (status != 0)
{
status = pressure.startPressure(3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);
status = pressure.getPressure(P,T);
if (status != 0)
{
// Print out the measurement:
data1=String(hour())+” “+String(minute())+ ” “+String(second())+” “+String(day())+ ” “+String (month())+” “+String(year());
data1=data1+” “+String(int (T*10))+” “+String(int (P*10));
Serial.println(data1);
Archivo=SD.open(“data_1.txt”,FILE_WRITE);
Archivo.println (data1);
Archivo.close();
}
else Serial.println(“error retrieving pressure measurement\n”);
}
else Serial.println(“error starting pressure measurement\n”);
}
else Serial.println(“error retrieving temperature measurement\n”);
}
else Serial.println(“error starting temperature measurement\n”);
delay(60000); // Pause
}
Your article gave me a lot of inspiration, I hope you can explain your point of view in more detail, because I have some doubts, thank you.
Your article gave me a lot of inspiration, I hope you can explain your point of view in more detail, because I have some doubts, thank you.
промокод в казино cat
https://rosyuvelirexpo.ru
Cat Casino – ваш надежный спутник в мире азартных развлечений и острых ощущений. Завораживающие игровые автоматы, увлекательные турниры, щедрые бонусы – все это ждет вас на официальном сайте казино. Подготовьтесь к невероятному азартному путешествию и отправляйтесь к победам вместе с Cat Casino!Безопасность и конфиденциальность каждого игрока – приоритет Cat Casino. Казино использует передовые технологии шифрования данных, чтобы обеспечить защиту всех транзакций и личной информации. Вы можете быть уверены в том, что ваш опыт в Cat Casino будет абсолютно безопасным и надежным.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good. https://accounts.binance.com/zh-CN/register-person?ref=T7KCZASX
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article. https://www.binance.com/es/register?ref=V2H9AFPY
Very nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!
I may need your help. I tried many ways but couldn’t solve it, but after reading your article, I think you have a way to help me. I’m looking forward for your reply. Thanks.
I may need your help. I tried many ways but couldn’t solve it, but after reading your article, I think you have a way to help me. I’m looking forward for your reply. Thanks.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://www.binance.com/en/register?ref=53551167
I may need your help. I’ve been doing research on gate io recently, and I’ve tried a lot of different things. Later, I read your article, and I think your way of writing has given me some innovative ideas, thank you very much.
Thanks for sharing. I read many of your blog posts, cool, your blog is very good. https://accounts.binance.com/sv/register-person?ref=B4EPR6J0
Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://accounts.binance.com/kz/register-person?ref=V2H9AFPY
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me? https://accounts.binance.com/sv/register?ref=IJFGOAID
Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me. https://www.binance.com/uk-UA/register?ref=V2H9AFPY
I am sorting out relevant information about gate io recently, and I saw your article, and your creative ideas are of great help to me. However, I have doubts about some creative issues, can you answer them for me? I will continue to pay attention to your reply. Thanks.