dfrobot / dfrobot_sht3x Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
In the file "DFRobot_SHT3x.cpp", in the function "readData()", there is a _pWire->endTransmission()
after a _pWire->requestFrom()
.
That _pWire->endTransmission()
can be removed.
Explanation: Common-mistakes#2
Hello, I bought the product but could not understand how to install this library and use it with raspi & phyton ??
, first download the library to Raspberry Pi, then open the routines folder. To execute one routine, demox.py, type python demox.py on the command line. To execute the get_gyro_accel_temp_data.py routine, for example, you need to type:
I dont think this is a rich explanation, Where is routines folder ?
from DFRobot_SHT3X import *
SHT3X = DFRobot_SHT3x(iic_addr = 0x45,bus = 1)
above is from example but of course I cant import library because i could not install it. Plus, I dont know how wiring should be ...
Any support ?
Thanks
Dear,
in your lib your are using clockstreching register to read data but your are using polling method to read byte data so in this way the sck pin of the sht3w be low and in some case it can block the i2c bus because sck is in low state... Sometimes the sht3x never pullup the sck pin.
so maybe it can be better to use polling register to read in polling mode than use mixed method.
//clock streching
#define SHT3X_CMD_GETDATA_H_CLOCKENBLED (0x2C06)// Measurement:high repeatability
#define SHT3X_CMD_GETDATA_M_CLOCKENBLED (0x2C0D)// Measurement: medium repeatability
#define SHT3X_CMD_GETDATA_L_CLOCKENBLED (0x2C10)// Measurement: low repeatability
//polling
#define SHT3X_CMD_GETDATA_POLLING_H (0x2400) // measurement: polling, high repeatability
#define SHT3X_CMD_GETDATA_POLLING_M (0x240B) // measurement: polling, medium repeatability
#define SHT3X_CMD_GETDATA_POLLING_L (0x2416) // measurement: polling, low repeatability
//Actual method
DFRobot_SHT3x::sRHAndTemp_t DFRobot_SHT3x::readTemperatureAndHumidity(eRepeatability_t repeatability)
{
uint8_t rawData[6];
uint8_t rawTemperature[3];
uint8_t rawHumidity[3];
tempRH.ERR = 0;
switch (repeatability)
{
case eRepeatability_High:
writeCommand(SHT3X_CMD_GETDATA_H_CLOCKENBLED, 2);
break;
case eRepeatability_Medium:
writeCommand(SHT3X_CMD_GETDATA_M_CLOCKENBLED, 2);
break;
case eRepeatability_Low:
writeCommand(SHT3X_CMD_GETDATA_L_CLOCKENBLED, 2);
break;
}
delay(15); //wait polling method sck state not tested !!
readData(rawData, 6);
memcpy(rawTemperature, rawData, 3);
memcpy(rawHumidity, rawData + 3, 3);
if ((checkCrc(rawTemperature) != rawTemperature[2]) || (checkCrc(rawHumidity) != rawHumidity[2]))
{
tempRH.ERR = -1;
return tempRH;
}
tempRH.TemperatureC = convertTemperature(rawTemperature);
tempRH.TemperatureF = (9 / 5) * tempRH.TemperatureC + 32;
tempRH.Humidity = convertHumidity(rawHumidity);
return tempRH;
}
How can I install the driver for Bosch BME680 in Raspberry?
When compile in Visual Studio for ESP32 I get this note:
DFRobot_SHT3x.h:99: note offset of packed bit-field DFRobot_SHT3x reserved1 has changed in GCC 4.4
typedef struct {
esptool.py v3.0-dev
this part of code is something wrong in DFRobot_SHT3x.h
typedef struct {
uint8_t writeDataChecksumStatus : 1;
uint8_t commandStatus : 1;
uint8_t reserved0 : 2;
uint8_t systemResetDeteced : 1;
uint8_t reserved1 : 5;
uint8_t temperatureAlert : 1;
uint8_t humidityAlert : 1;
uint8_t reserved2 : 1;
uint8_t heaterStaus :1;
uint8_t reserved3 :1;
uint8_t alertPendingStatus :1;
}attribute ((packed)) sStatusRegister_t;
Compiling is OK but need to something change in library
Best regards
size_t size
is not used and should be removed imo.
void DFRobot_SHT3x::writeCommand(uint16_t cmd,size_t size)
{
uint8_t _pBuf[2];
_pBuf[0] = cmd >> 8;
_pBuf[1] = cmd & 0xFF;
delay(1);
write(_pBuf,2);
}
I am converting a program from using the Arduino library for SHT35 sensor to this one but i noticed that the F values are not correct.
From Arduino Lib
<
SHT:
RH : 74.69
T (c): 21.25
T (f): 70.25
SHT:
RH : 74.66
T (c): 21.26
T (f): 70.28
SHT:
RH : 74.65
T (c): 21.22
T (f): 70.20
SHT:
RH : 74.64
T (c): 21.21
From Single Measurement Sample using addr 44
<------------------Read adta in single measurement mode-----------------------
Ambient Temperature(°C/F):21.28 C/53.25 F Relative Humidity(%RH):74.57 %RH
Ambient Temperature(°C/F):21.28 C/53.28 F Relative Humidity(%RH):74.55 %RH
Ambient Temperature(°C/F):21.28 C/53.28 F Relative Humidity(%RH):74.52 %RH
Ambient Temperature(°C/F):21.29 C/53.29 F Relative Humidity(%RH):74.52 %RH
Ambient Temperature(°C/F):21.28 C/53.29 F Relative Humidity(%RH):74.49 %RH
Ambient Temperature(°C/F):21.29 C/53.31 F Relative Humidity(%RH):74.50 %RH
Ambient Temperature(°C/F):21.28 C/53.29 F Relative Humidity(%RH):74.50 %RH
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.