Sensor Si7021 with Arduino

Updated on 31 August 2021
dev board Arduino UNO
chip Si7021
This tutorial is more than 1 year old. If the steps below do not work, then please check the latest versions and the documentations of the individual tools used.

Before starting

Dependancies

Ensure the following dependancies are downloaded and available:

Code

Download code sensor-si7021-arduino.ino
#include "Adafruit_Si7021.h"

Adafruit_Si7021 sensor = Adafruit_Si7021();

void setup() {
  Serial.begin(9600);

  if (!sensor.begin()) {
    Serial.println("Did not find Si7021 sensor!");
    while (true) {}
  }

  delay(1000);
}

void loop() {
  Serial.print("\nHumidity:    ");
  Serial.print(sensor.readHumidity());
  Serial.println(" RH%");

  Serial.print("Temperature: ");
  Serial.print(sensor.readTemperature());
  Serial.println(" C");

  delay(1000);
}

Makefile

BOARD?=arduino:avr:uno
PORT?=/dev/cu.usbmodem14*

.PHONY: default lint all flash clean

default: lint all flash clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright *.ino

all:
	arduino-cli compile --fqbn $(BOARD) ./

flash:
	arduino-cli upload -p $(PORT) --fqbn $(BOARD) ./

clean:
	rm -f .*.hex
	rm -f .*.elf

Schematic

Wire up the hardware accordingly

Sensor Si7021 with Arduino schematic

Serial console

Serial output from the firmware.

Sensor Si7021 with Arduino serial console

Description

Display humidity and temperature values with sensor Si7021 and Arduino.

References