Skip to main content
Tweeted twitter.com/StackArduino/status/906281506338996230
deleted 78 characters in body
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 18

CurrentlyI'm currently learning I2C and having some issues displaying the correct temperature in the serial screenmonitor.

I am using an Arduino Uno and an SI7021 temperature sensor: SI7021 from Sparkfun,Sparkfun; here's the datasheet I'm looking at: https://cdn.sparkfun.com/datasheets/Sensors/Weather/Si7021.pdfthe datasheet I'm looking at.

The datasheet says that its device address is: 0x40 0x40 and the temperature register is: 0xF3 0xF3 (maybe I am looking at this wrong?). However when I print the result to the screen it reads -1 degrees F.

Here's my code:

// SparkFun Si7021 Humidity and Temperature Sensor
#include <SparkFun_Si7021_Breakout_Library.h>
#include <Wire.h>

//Weather sensor slave address
int WeatherAddress = 0x40;

#define Temperature_Register_DATA 0xF3

//initialize humidity and temperature variables
float humidity = 0;
float tempf = 0;

//create a sensor from the Weather library
Weather temp_rh_sensor;

void setup() {
    Serial.begin(9600);
    //create wire object
    Wire.begin();  
    //begin weather sensor
    temp_rh_sensor.begin();
}

void loop() {
    
    //begin transmission to weather sensor
    Wire.beginTransmission(WeatherAddress);
    
    //ask particular register for data (temperature register)
    Wire.write(Temperature_Register_DATA);
    
    Wire.endTransmission();
    
    //request the transmitted single byte from the register
    Wire.requestFrom(Temperature_Register_DATA, 1);
    
    if(Wire.available() <= 1) {
     tempf = Wire.read(); 
    }
    
    Serial.print("Temp: ");
    Serial.print(tempf);
    Serial.println("F, ");
    delay(1000);
}

Currently learning I2C and having some issues displaying the correct temperature in the serial screen.

I am using an Arduino Uno and temperature sensor: SI7021 from Sparkfun, here's the datasheet I'm looking at: https://cdn.sparkfun.com/datasheets/Sensors/Weather/Si7021.pdf

The datasheet says that its device address is: 0x40 and temperature register is: 0xF3 (maybe I am looking at this wrong?) However when I print the result to the screen it reads -1 degrees F.

Here's my code:

// SparkFun Si7021 Humidity and Temperature Sensor
#include <SparkFun_Si7021_Breakout_Library.h>
#include <Wire.h>

//Weather sensor slave address
int WeatherAddress = 0x40;

#define Temperature_Register_DATA 0xF3

//initialize humidity and temperature variables
float humidity = 0;
float tempf = 0;

//create a sensor from the Weather library
Weather temp_rh_sensor;

void setup() {
    Serial.begin(9600);
    //create wire object
    Wire.begin();  
    //begin weather sensor
    temp_rh_sensor.begin();
}

void loop() {
    
    //begin transmission to weather sensor
    Wire.beginTransmission(WeatherAddress);
    
    //ask particular register for data (temperature register)
    Wire.write(Temperature_Register_DATA);
    
    Wire.endTransmission();
    
    //request the transmitted single byte from the register
    Wire.requestFrom(Temperature_Register_DATA, 1);
    
    if(Wire.available() <= 1){
     tempf = Wire.read(); 
    }
    
    Serial.print("Temp: ");
    Serial.print(tempf);
    Serial.println("F, ");
    delay(1000);
}

I'm currently learning I2C and having some issues displaying the correct temperature in the serial monitor.

I am using an Arduino Uno and an SI7021 temperature sensor from Sparkfun; here's the datasheet I'm looking at.

The datasheet says that its device address is 0x40 and the temperature register is 0xF3 (maybe I am looking at this wrong?). However when I print the result to the screen it reads -1 degrees F.

Here's my code:

// SparkFun Si7021 Humidity and Temperature Sensor
#include <SparkFun_Si7021_Breakout_Library.h>
#include <Wire.h>

//Weather sensor slave address
int WeatherAddress = 0x40;

#define Temperature_Register_DATA 0xF3

//initialize humidity and temperature variables
float humidity = 0;
float tempf = 0;

//create a sensor from the Weather library
Weather temp_rh_sensor;

void setup() {
  Serial.begin(9600);
  //create wire object
  Wire.begin();
  //begin weather sensor
  temp_rh_sensor.begin();
}

void loop() {
  //begin transmission to weather sensor
  Wire.beginTransmission(WeatherAddress);
  //ask particular register for data (temperature register)
  Wire.write(Temperature_Register_DATA);
  Wire.endTransmission();
  //request the transmitted single byte from the register
  Wire.requestFrom(Temperature_Register_DATA, 1);
  if(Wire.available() <= 1) {
    tempf = Wire.read();
  }
  Serial.print("Temp: ");
  Serial.print(tempf);
  Serial.println("F, ");
  delay(1000);
}
Source Link

I2C Temperature Sensor Communication Issue

Currently learning I2C and having some issues displaying the correct temperature in the serial screen.

I am using an Arduino Uno and temperature sensor: SI7021 from Sparkfun, here's the datasheet I'm looking at: https://cdn.sparkfun.com/datasheets/Sensors/Weather/Si7021.pdf

The datasheet says that its device address is: 0x40 and temperature register is: 0xF3 (maybe I am looking at this wrong?) However when I print the result to the screen it reads -1 degrees F.

Here's my code:

// SparkFun Si7021 Humidity and Temperature Sensor
#include <SparkFun_Si7021_Breakout_Library.h>
#include <Wire.h>

//Weather sensor slave address
int WeatherAddress = 0x40;

#define Temperature_Register_DATA 0xF3

//initialize humidity and temperature variables
float humidity = 0;
float tempf = 0;

//create a sensor from the Weather library
Weather temp_rh_sensor;

void setup() {
    Serial.begin(9600);
    //create wire object
    Wire.begin();  
    //begin weather sensor
    temp_rh_sensor.begin();
}

void loop() {
    
    //begin transmission to weather sensor
    Wire.beginTransmission(WeatherAddress);
    
    //ask particular register for data (temperature register)
    Wire.write(Temperature_Register_DATA);
    
    Wire.endTransmission();
    
    //request the transmitted single byte from the register
    Wire.requestFrom(Temperature_Register_DATA, 1);
    
    if(Wire.available() <= 1){
     tempf = Wire.read(); 
    }
    
    Serial.print("Temp: ");
    Serial.print(tempf);
    Serial.println("F, ");
    delay(1000);
}