Lesson 4: Sensors

Once you know how to connect to the Internet, it is time to learn how to use a sensor. For this lesson, we will use the Si7021 temperature/humidity sensor. This is not the same sensor I use in my crawl space. It is slightly different and a little easier to use. Below is code that shows how to print humidity values to the serial monitor.
 1 | #include "Adafruit_Si7021.h"
 2 | Adafruit_Si7021 sensor = Adafruit_Si7021();
 3 | 
 4 | void setup() {
 5 |   Serial.begin(115200);
 6 |   sensor.begin();
 7 | }
 8 | 
 9 | void loop() {
10 |   float h  = sensor.readHumidity();
11 | 
12 |   Serial.print("Humidity: ");
13 |   Serial.println(h);
14 | 
15 |   delay(3000);
16 | }

Modify this program to print temperature data to the serial monitor as well. You will need to use the following command:
  float t = sensor.readTemperature();

One you are able to print both humidity and temperature values to the serial monitor, use the code you developed in lessons 2 & 3 to log these values to your Google spreadsheet.
Comments