Codigo ARduino

Author: 3d8b3f312d

04 November 2024

Views: 20

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>

#define BMP_SCK (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS (10)
#include "DHT.h"

#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
Adafruit_BMP280 bmp;

void setup() {
Serial.begin(9600);
unsigned status;
status = bmp.begin();
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
Adafruit_BMP280::FILTER_X16, /* Filtering. */
Adafruit_BMP280::STANDBY_MS_500);
dht.begin();
pinMode(A0, INPUT);
}

void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
float hic = dht.computeHeatIndex(t, h, false);
String llueve;
if(analogRead(A0)==0){
llueve = "No";
}else{
llueve = "Si";
}
float presion = bmp.readPressure();
float presionhpa = presion/100;
float altitudm = bmp.readAltitude(1017.2);
float altitudft = altitudm*3.281;
int prob = 0;
prob = map(presionhpa,998,1008,100,0);
if(presionhpa>1008){
prob = 0;
}else{
if(presionhpa<998){
prob=100;
}
}
String mensaje = String(t)+";"+String(hic)+";"+String(h)+";"+String(presion)+";"+String(presionhpa)+";"+llueve+";"+String(prob)+";"+String(altitudm)+";"+String(altitudft)+";";
Serial.println(mensaje);
delay(500);
}


Edit Code:

Please enter an edit code

Edit codes must be at least 20 characters

Share