Giter Club home page Giter Club logo

hts221's People

Contributors

cparata avatar fpistm avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hts221's Issues

MKI141V2 Temperature Range

Dear ST Team,

First of all I hope you find yourselves healthy and well in this difficult times.

I was redirected to your Git by a helpful colleague of yours. Who pointed me to your direction to help me solve an Issue.

I am working on a project at the moment, a sort of data logger in which I am integrating an STNucleo030R8 together with the MKI141V2 Evalboard (with embedded HTS221).

I am using the Arduino IDE to program on the ST board, using the implemented Wire. h library from Arduino.

I wanted to know if you can help me get readings realistic to the European weathers (-20 to +40°C ), because at the moment I am limited to readings starting from 20°C with the attached program.
I have not Tested a maximum yet. Ideal would be if we could cover the “Industrial Operating Temperature Range” (-20°C – +85°C).

I have tried to Implement and test your DISCO_IOT_HTS221_DataLog_Terminal.ino example with no success. The serial monitor Prints out correctly "15:48:10.162 -> Hum[%]: 6553.50 | Temp[C]: 74.00" But as you can see, the values seem off.

In Summary. I Want to know if you can help me to get the desired temperature range using the following code.

`// Distributed with a free-will license.
// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
// HTS221
// This code is designed to work with the HTS221_I2CS I2C Mini Module available from ControlEverything.com.
// https://www.controleverything.com/content/Humidity?sku=HTS221_I2CS#tabs-0-product_tabset-2
/*

  • This example has a min threshold of 20°C.
  • OPERATING TEMPERATURE RANGES:
  • Commercial: 0 °C to 45 °C
  • Industrial: −20 °C to 85 °C
  • [ Automotive: −40 °C to 125 °C ]
  • Extended: −40 °C to 125 °C
  • Military: −55 °C to 125 °C
  • Guaranteed to operate over a temperature range from -40 °C to +120 °C (Automotive).
  • Need to calibrate for Industrial temperature range
  • see HTS221_driver.h, HTS221_driver.h, HTS221Sensor.h, HTS221Sensor.cpp, TempSensor.h, HumiditySensor.h
    */
    #include<Wire.h>

// HTS221 I2C address is 0x5F
#define Addr 0x5F

void setup()
{
// Initialise I2C communication as MASTER
Wire.begin();
// Initialise serial communication, set baud rate = 9600
Serial.begin(9600);

// Start I2C Transmission
Wire.beginTransmission(Addr);
// Select average configuration register
Wire.write(0x10);
// Temperature average samples = 256, Humidity average samples = 512
Wire.write(0x1B);
// Stop I2C Transmission
Wire.endTransmission();

// Start I2C Transmission
Wire.beginTransmission(Addr);
// Select control register13
Wire.write(0x20);
// Power ON, Continuous update, Data output rate = 1 Hz
Wire.write(0x85);
// Stop I2C Transmission
Wire.endTransmission();

Serial.println("\nSTEVAL-MKI141v2");

delay(300);
}

void loop()
{
unsigned int data[2];
unsigned int val[4];
unsigned int H0, H1, H2, H3, T0, T1, T2, T3, raw;

                                // Humidity calliberation values

for(int i = 0; i < 2; i++)
{
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send data register
Wire.write((48 + i));
// Stop I2C Transmission
Wire.endTransmission();

// Request 1 byte of data
Wire.requestFrom(Addr, 1);

// Read 1 byte of data
if(Wire.available() == 1)
{
  data[i] = Wire.read();
}

}

// Convert Humidity data
H0 = data[0] / 2;
H1 = data[1] / 2;

for(int i = 0; i < 2; i++)
{
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send data register
Wire.write((54 + i));
// Stop I2C Transmission
Wire.endTransmission();

// Request 1 byte of data
Wire.requestFrom(Addr,1);

// Read 1 byte of data
if(Wire.available() == 1)
{
  data[i] = Wire.read();
}

}
// Convert Humidity data
H2 = (data[1] * 256.0) + data[0];

for(int i = 0; i < 2; i++)
{
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send data register
Wire.write((58 + i));
// Stop I2C Transmission
Wire.endTransmission();

// Request 1 byte of data
Wire.requestFrom(Addr,1);

// Read 1 byte of data
if(Wire.available() == 1)
{
  data[i] = Wire.read();
}

}
// Convert Humidity data
H3 = (data[1] * 256.0) + data[0];

                              // Temperature callibration values

// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send data register
Wire.write(0x32);
// Stop I2C Transmission
Wire.endTransmission();

// Request 1 byte of data
Wire.requestFrom(Addr,1);

// Read 1 byte of data
if(Wire.available() == 1)
{
T0 = Wire.read();
}

// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send data register
Wire.write(0x33);
// Stop I2C Transmission
Wire.endTransmission();

// Request 1 byte of data
Wire.requestFrom(Addr,1);

// Read 1 byte of data
if(Wire.available() == 1)
{
T1 = Wire.read();
}

// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send data register
Wire.write(0x35);
// Stop I2C Transmission
Wire.endTransmission();

// Request 1 byte of data
Wire.requestFrom(Addr, 1);

// Read 1 byte of data
if(Wire.available() == 1)
{
raw = Wire.read();
}

raw = raw & 0x0F;

// Convert the temperature callib ration values to 10-bits
T0 = ((raw & 0x03) * 256) + T0;
T1 = ((raw & 0x0C) * 64) + T1;

for(int i = 0; i < 2; i++)
{
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send data register
Wire.write((60 + i));
// Stop I2C Transmission
Wire.endTransmission();

// Request 1 byte of data
Wire.requestFrom(Addr,1);

// Read 1 byte of data
if(Wire.available() == 1)
{
  data[i] = Wire.read();
}

}

// Convert the data
T2 = (data[1] * 256.0) + data[0];

for(int i = 0; i < 2; i++)
{
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send data register
Wire.write((62 + i));
// Stop I2C Transmission
Wire.endTransmission();

// Request 1 byte of data
Wire.requestFrom(Addr,1);

// Read 1 byte of data
if(Wire.available() == 1)
{
  data[i] = Wire.read();
}

}

// Convert the data
T3 = (data[1] * 256.0) + data[0];

// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send data register
Wire.write(0x28 | 0x80);
// Stop I2C Transmission
Wire.endTransmission();

// Request 4 bytes of data
Wire.requestFrom(Addr,4);

// Read 4 bytes of data
// humidity msb, humidity lsb, temp msb, temp lsb
if(Wire.available() == 4)
{
val[0] = Wire.read(); // humidity msb
val[1] = Wire.read(); // humidity lsb
val[2] = Wire.read(); // temperature msb
val[3] = Wire.read(); // temperature lsb

}

// Convert the data
float humidity = (val[1] * 256.0) + val[0];
humidity = ((1.0 * H1) - (1.0 * H0)) * (1.0 * humidity - 1.0 * H2) / (1.0 * H3 - 1.0 * H2) + (1.0 * H0);
int temp = (val[3] * 256) + val[2];
float cTemp = (((T1 - T0) / 8.0) * (temp - T2)) / (T3 - T2) + (T0 / 8.0);
float fTemp = (cTemp * 1.8 ) + 32;

if (cTemp <= 20 || cTemp > 100) {        // I set this to evade Gibberish
  Serial.println("Out of range...");

} else if (cTemp >= 20 ) {

// Output data to serial monitor
/* // Raw data
Serial.print(val[0]);
Serial.print(" \t");
Serial.print(val[1]);
Serial.print(" \t");
Serial.print(val[2]);
Serial.print(" \t");
Serial.println(val[3]);

Serial.print("Relative humidity : ");
Serial.print(humidity);
Serial.print(" % RH");
Serial.print(" | ");

Serial.print("Temperature in Celsius : ");
Serial.print(cTemp);
Serial.print(" C");
Serial.print(" | ");

Serial.print(val[2], BIN);
Serial.print(" | ");
Serial.print(val[3], BIN);
Serial.print(" | ");

Serial.print("temp total : ");
Serial.println(temp); // temperature msb + lsb
*/

// Converted data
//Serial.print("Relative humidity : ");
Serial.print(humidity);
//Serial.print(" % RH");
Serial.print("\t");

//Serial.print("Celsius");
Serial.print(cTemp);
//Serial.print(" C");
Serial.print("\t");

//Serial.print("Fahrenheit");
Serial.println(fTemp);
//Serial.println(" F");
}

delay(100);
}`

Please excuse the formatting, its the first time i leave a comment in a git.
I appreciate your time. Wish you a great week and health.

Kind Regards

Franz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.