0% found this document useful (0 votes)
27 views7 pages

Sensor Es

The document describes code for using several sensors: a DHT11 humidity and temperature sensor, a soil moisture sensor, and a MAX6675 thermocouple temperature sensor. It includes code to read values from each sensor, display the values on an LCD screen or serial monitor, and use the soil moisture reading to control an LED.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views7 pages

Sensor Es

The document describes code for using several sensors: a DHT11 humidity and temperature sensor, a soil moisture sensor, and a MAX6675 thermocouple temperature sensor. It includes code to read values from each sensor, display the values on an LCD screen or serial monitor, and use the soil moisture reading to control an LED.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

“SENSOR DHT11”

#include <DHT11.h>

#define DHTPIN 2

#define DHT11

//Paso 3

DHT11 dht (DHTPIN,DHTTYPE);

void setup() {

//Paso 4

Serial.begin(9600);

Serial.println("DHTxx test!");

dht.begin();

void loop() {

delay(2000);

//Paso 5

float h = dht.readHumidity();

//Paso 6

float t = dht.readTemperature();

//Paso 7

float f = dht.readTemperature(true);

//Paso 8

if (isnan(h) || isnan(t) || isnan(f)) {

Serial.println("Failed to read from DHT sensor!");


return;

//Paso 9

float hif = dht.computeHeatIndex(f, h);

float hic = dht.computeHeatIndex(t, h, false);

//Paso 10

Serial.print("Humidity: ");

Serial.print(h);

Serial.print(" %\t");

Serial.print("Temperature: ");

Serial.print(t);

Serial.print(" *C ");

Serial.print(f);

Serial.print(" *F\t");

Serial.print("Heat index: ");

Serial.print(hic);

Serial.print(" *C ");

Serial.print(hif);

Serial.println(" *F");

}
SENSOR HUMEDAD

int SensorPin=A0;

void setup() {

Serial.begin(9600);

void loop() {

int humedad=analogRead(SensorPin);

Serial.println(humedad);

delay(1000);

if(humedad>=460){

digitalWrite(7,LOW);

else

digitalWrite(7,HIGH);

delay(1000);

#include <Wire.h>
SENSOR TERMOPAR

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 20, 4);

#include <SPI.h>

#define MAX6675_SO 2

#define MAX6675_CS 3

#define MAX6675_SCK 4

void setup()

lcd.init();

lcd.backlight();

lcd.setCursor(5,1);

lcd.print("Bienvenido");

delay(1500);

lcd.clear();

void loop()

float temperatura = leer_termopar();

lcd.setCursor(2, 1);

lcd.print("Termopar tipo K");

lcd.setCursor(7, 2);

lcd.print(temperatura, 2);

delay(300);

double leer_termopar()
{

uint16_t v;

pinMode(MAX6675_CS, OUTPUT);

pinMode(MAX6675_SO, INPUT);

pinMode(MAX6675_SCK, OUTPUT);

digitalWrite(MAX6675_CS, LOW);

delay(1);

// Read in 16 bits,

// 15 = 0 always

// 14..2 = 0.25 degree counts MSB First

// 2 = 1 if thermocouple is open circuit

// 1..0 = uninteresting status

v = shiftIn(MAX6675_SO, MAX6675_SCK, MSBFIRST);

v <<= 8;

v |= shiftIn(MAX6675_SO, MAX6675_SCK, MSBFIRST);

digitalWrite(MAX6675_CS, HIGH);

if (v & 0x4)

// Bit 2 indicates if the thermocouple is disconnected

return NAN;

// The lower three bits (0,1,2) are discarded status bits

v >>= 3;
// The remaining bits are the number of 0.25 degree (C) counts

return v * 0.25;

You might also like