Display Temperature And Humidity Data With HTS221 - Hutscape

Hutscape TutorialsChecklistsToolsCalculators Code Videos Donate Display temperature and humidity data with HTS221 Updated on 3 September 2021 dev board Arduino Nano 33 BLE Sense firmware Arduino chip HTS221 sensor temperature sensor humidity 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

Ensure the following dependancies are downloaded and available:
  • Arduino MBed OS Nano Boards
  • Temperature and Humidity sensor HTS221
Try these simpler or similar examples:
  1. Blinky with Arduino Nano 33 BLE sense
  1. Arduino Nano 33 BLE Sense

Code

Download code nano33-ble-sense-temperature-humidity.ino
#include <Arduino_HTS221.h> void setup() { Serial.begin(9600); while (!Serial) {} if (!HTS.begin()) { Serial.println("Failed to initialize humidity temperature sensor!"); while (1) {} } } void loop() { float temperature = HTS.readTemperature(); float humidity = HTS.readHumidity(); Serial.print("Temperature = "); Serial.print(temperature); Serial.println("°C"); Serial.print("Humidity = "); Serial.print(humidity); Serial.println("%"); Serial.println(); delay(1000); }

Makefile

BOARD?=arduino:mbed:nano33ble PORT?=/dev/cu.usbmodem14* BUILD=build .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) --output-dir $(BUILD) ./ flash: arduino-cli upload --fqbn $(BOARD) --port $(PORT) --input-dir $(BUILD) clean: rm -r build

Serial console

Serial output from the firmware.

Display temperature and humidity data with HTS221 serial console

Description

Display temperature and humidity values with sensor HTS221 on Arduino Nano 33 BLE Sense board.

Install the dependancy:

arduino-cli lib install Arduino_HTS221

References

  1. Arduino Nano 33 BLE Sense
  2. Getting started with the Arduino NANO 33 BLE Sense
  3. Read temperature and humidity with HTS221

Tag » Arduino Nano 33 Ble Sense Temperature Example