I'm using a BME 280 with a NANO 33 IOT and getting very high temp readings

I've built a simple temperature, humidity and pressure system using the IOT cloud with a NANO 33 IOT and a BME 280 sensor.

Humidity and pressure are fine, but the temp is way off. The temp measured with a verified source is 44 F but the BME is showing 52 F. The sensor is in a box that has holes drilled in the sides to allow air flow.

Here's the code, but I don't think that is the problem.

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/2ac4fad8-69de-4493-ba6d-0a999f48651c 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  int bar;
  int humidity;
  int tempF;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <math.h>
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme;
unsigned status;

  float bar1;
  float humidity1;
  float tempF1;

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 
  Serial.println("BME280 Test");
  unsigned status;
  status=bme.begin(0x76);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection,false);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(4);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here

    tempF1=(1.8 * bme.readTemperature() + 32);
    tempF=round(tempF1);
    bar1=(bme.readPressure() /100.0F);
    bar=round(bar1);
    humidity1=(bme.readHumidity());
    humidity=round(humidity1);
   
//printValues();

 
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" °F");
    

    Serial.print("Pressure = ");

    Serial.print(bme.readPressure());
    Serial.println(" hPa");
    

    Serial.print("Approx. Altitude = ");
    Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme.readHumidity());
    Serial.println(" %");
    
    Serial.print("TempF: ");
    Serial.println(tempF);
    Serial.print("Humidity: ");
    Serial.println(humidity);
    Serial.print("Pressure: ");
    Serial.println(bar);
    Serial.println();
    delay(5000);
 
}


/*
  Since TempF is READ_WRITE variable, onTempFChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onTempFChange()  {
  // Add your code here to act upon TempF change
}

/*
  Since Humidity is READ_WRITE variable, onHumidityChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHumidityChange()  {
  // Add your code here to act upon Humidity change
}

/*
  Since Bar is READ_WRITE variable, onBarChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onBarChange()  {
  // Add your code here to act upon Bar change
}

void printValues() {
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" *C");

    Serial.print("Pressure = ");

    Serial.print(bme.readPressure() / 100.0F);
    Serial.println(" hPa");

    Serial.print("Approx. Altitude = ");
    Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme.readHumidity());
    Serial.println(" %");

    Serial.println();
    delay(5000);
}

Thanks in advance for your help.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.