/*
* ==========================================================
* Artekit demo sketch for the AK-SI7021 Humidity/Temperature
* sensor breakout board.
*
* Copyright (c) 2014 Artekit Italy
* http://www.artekit.eu
*
* Product page:
* http://www.artekit.eu/products/sensors/ak-si7021/
*
* Connect the pins in the following way:
*
* Arduino UNO AK-SI7021
* ==================================
* AN5 SCL
* AN4 SDA
* 3.3V VCC
* GND GND
*
* You may need a level converter for the I2C lines, since
* the Arduino moves these lines from 0V to 5V, and the
* AK-SI7021 works only with 3.3V
*
* ==========================================================
*/
#include <Wire.h>
#include <Artekit_SI7021.h>
Artekit_SI7021 si7021;
static void sensorRead()
{
float temperature;
float humidity;
/* Read relative humidity and temperature */
humidity = si7021.ReadHumidity();
/* By setting true in the next function, we read the
* temperature from the previous RH measurement.
* Otherwise it will perform a new temperature measurement.
*/
temperature = si7021.ReadTemperature(true);
Serial.print("RH: ");
Serial.print(humidity);
Serial.print("%\tTemperature: ");
Serial.println(temperature);
}
void setup()
{
/* Start I2C */
Wire.begin();
/* Start serial */
Serial.begin(9600);
}
void loop()
{
static int counter = 0;
static bool heater = false;
/* Read sensor data each second */
sensorRead();
/* Turn on and off the heater every 30 seconds,
* just to see the change in the temperature readings.
*/
if (heater == false)
{
counter++;
if (counter == 30)
{
Serial.println("Heater ON");
si7021.EnableHeater();
heater = true;
}
} else {
counter--;
if (counter == 0)
{
Serial.println("Heater OFF");
si7021.DisableHeater();
heater = false;
}
}
delay(1000);
}
Marcadores: estação meteorológica, icstation, sensor arduino, sensor de humidade, sensor de temperatura, sensor de temperatura e humidade, si7021