It's ­čÉŹCircuitPython Monday­čÉŹ at Adafruit! Use the code ADATY to get 20% off CircuitPython and 15% off items storewide!
0

Adafruit HTU21D-F Temperature & Humidity Sensor with Adafrui
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit HTU21D-F Temperature & Humidity Sensor with Adafrui

by tshivam07 on Thu Oct 21, 2021 7:53 am

Hi ,
I am trying to interface HTU21D-F Temperature & Humidity Sensor with adafruit feather M0 Express using Adafruit HTU21DF Library but i am unable to get it working. The sensor works well with arduino uno using the same library. Can you tell what changes i need to do in order to get it working with feather m0 express.

Thanks,
shivam

tshivam07
 
Posts: 2
Joined: Thu Oct 21, 2021 7:45 am

Re: Adafruit HTU21D-F Temperature & Humidity Sensor with Ada

by franklin97355 on Thu Oct 21, 2021 12:45 pm

Just what are you trying to do with your code ( and can you post your code) ? If there are no hardware-specific statements it should work.

franklin97355
 
Posts: 22326
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Adafruit HTU21D-F Temperature & Humidity Sensor with Ada

by tshivam07 on Fri Oct 22, 2021 4:08 am

Hi please see the code below. I don't get any errors when i am uploading the code to FeatherM0 Express board. But i don't get the results on the serial monitor i.e. when i am connecting the sensor to Arduino Uno, i am getting the results in form of temperature and humidity readings in proper format whereas when i am connecting the sensor to feather m0 express board, the serial monitor remains blank.
Please see the code below that i am using.

Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include "Adafruit_HTU21DF.h"

// Connect Vin to 3-5VDC
// Connect GND to ground
// Connect SCL to I2C clock pin (A5 on UNO)
// Connect SDA to I2C data pin (A4 on UNO)

Adafruit_HTU21DF htu = Adafruit_HTU21DF();

void setup() {
  Serial.begin(9600);
  Serial.println("HTU21D-F test");

  if (!htu.begin()) {
    Serial.println("Couldn't find sensor!");
    while (1);
  }
}

void loop() {
    float temp = htu.readTemperature();
    float rel_hum = htu.readHumidity();
    Serial.print("Temp: "); Serial.print(temp); Serial.print(" C");
    Serial.print("\t\t");
    Serial.print("Humidity: "); Serial.print(rel_hum); Serial.println(" \%");
    delay(500);
}

tshivam07
 
Posts: 2
Joined: Thu Oct 21, 2021 7:45 am

Please be positive and constructive with your questions and comments.