View previous topic :: View next topic |
Author |
Message |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
sensirion SHT15 module problem |
Posted: Mon Jun 23, 2014 8:28 am |
|
|
Hello everybody
I'm trying to get sensirion SHT15 temparature/humidity meter module to work but no success... I have tried everything ... nothing works ...
So please help me I'm getting crazy!
I'm using PIC 18F452 controller and I think my hardware is OK I have checked it many ways and I've looked those data and clock signals with my oscilloscope and I think they are OK ...
I first try to get temperature measurement to work but my LCD- display shows only allways lValue 5535 but if I force it to display other values it's OK
there is 10 kilo-ohm. pullup resistor to VCC In sensirion module so
output_float(DATA) should be data == high...
here's my code (important part of it, sorry some comments are in finnish
language ) :
Code: |
//**********************************************************************************************
// SHT1x Connection Reset Sequence
void sht1x_connection_reset(){
int i;
//output_high(DATA);
output_float(DATA);
delay_us(200);
output_low(SCK);
for (i=0; i<9; i++)
{
output_high(SCK);
delay_us(200);
output_low(SCK);
delay_us(200);
}
sht1x_xmission_start();
}
//*********************************************************************************************
// SHT1x Transmission Start Sequence
void sht1x_xmission_start(){
//output_high(DATA);
output_float(DATA);
delay_us(200);
output_low(SCK);
delay_us(200);
output_high(SCK);
delay_us(200);
output_low(DATA);
delay_us(200);
output_low(SCK);
delay_us(200);
output_high(SCK);
delay_us(200);
//output_high(DATA);
output_float(DATA);
delay_us(200);
output_low(SCK);
delay_us(200);
}
//*********************************************************************************************
void mittaa_temp(void) {
/*
// SHT1x address=000 is currently supported
// SHT1x command code
//adr command r/w
#define STATUS_REG_W 0x06 //000 0011 0
#define STATUS_REG_R 0x07 //000 0011 1
#define MEASURE_TEMP 0x03 //000 0001 1
#define MEASURE_HUMI 0x05 //000 0010 1
#define RESET 0x1E //000 1111 0
*/
unsigned int i,iMode;
///////// SITTEN measure temperature command:
//AINA ENNEN KOMENTOA TÄMÄ STARTTI!
sht1x_xmission_start();
iMode = 0B00000011;
for (i=128; i>0; i/=2){
//output_float(DATA); data pinni kelluu!!
if (i & iMode) output_high(DATA);
else output_low(DATA);
delay_us(2);
output_high(SCK);
delay_us(2);
output_low(SCK);
delay_us(2);
}
delay_ms(100);
//9. kellopulssi
output_high(SCK);
delay_us(2);
output_low(SCK);
delay_us(2);
delay_ms(500);
while(input(DATA)== TRUE)
delay_ms(1) ;
if(input(DATA)== FALSE){
i = 0;
while(i < 3){
output_high(pin_A5);
delay_ms (50);
output_low(pin_A5);
delay_ms (50);
i++;
}
}
/*
TÄHÄN ASTI KAIKEN PITÄISI OLLA OK ! temp data on nyt luettavissa
*/
}
//*********************************************************************************************
// SHT1x Address & Command Mode with address=000
void sht1x_command_mode(int iMode){
int i;
for (i=128; i>0; i/=2)
{
if (i & iMode){ //output_high(DATA);
output_float(DATA);
delay_us(200);
}
else output_low(DATA);
delay_us(200);
output_high(SCK);
delay_us(200);
output_low(SCK);
}
//output_float(DATA);
output_float(DATA);
//output_high(DATA); //sama asia !
delay_us(200);
output_high(SCK);
delay_us(200);
output_low(SCK);
// delay >11ms for 8-bit measurement
// delay >55ms for 12-bit measurement
// delay >210ms for 14-bit measurement
// before data read from SHT1x
delay_ms(250);
}
//*********************************************************************************************
// read data from SHT1x and store
long sht1x_read_data(){
int i;
long lTmp;
long lVal1=0;
long lVal2=0;
long lValue;
//output_float(DATA);
//delay_us(200);
// get MSB from SHT1x
for (i=0; i<8; i++)
{
lVal1<<=1;
output_high(SCK);
lTmp = input(DATA);
delay_us(200);
output_low(SCK);
delay_us(200);
if (lTmp) lVal1|=1;
}
// acknowledge routine
output_high(SCK);
output_low(DATA);
delay_us(200);
output_float(DATA);
delay_us(200);
output_low(SCK);
delay_us(200);
// get LSB from SHT1x
for (i=0; i<8; i++)
{
lVal2<<=1;
output_high(SCK);
lTmp = input(DATA);
delay_us(200);
output_low(SCK);
delay_us(200);
if (lTmp) lVal2|=1;
}
lValue = make16(lVal1,lVal2);
//OKlValue = 1234;
return(lValue);
}
//*********************************************************************************************
// SHT1x Soft Reset
// resets the interface, clears the status register to default values
// wait minimum 11ms before next command
void sht1x_soft_reset(){
{
sht1x_connection_reset();
sht1x_command_mode(RESET);
}
delay_ms(20);
}
//*********************************************************************************************
void main(void){
float fRh_lin;
float fRh_true;
float fTemp_true;
//float fDew_point;
long lValue_rh;
long lValue_temp;
//long temp,humidity;
delay_ms(200); //käynnistysviive
setup_adc_ports(NO_ANALOGS);
//init();
lcd_init();
clear_lcd();
delay_ms(100);
sht1x_soft_reset();
sht1x_connection_reset();
//output_float(DATA); //data pinni kelluu!!
//mittaa_temp();
//nyt data voidaan lukea kellottamalla !?
//lValue_temp = sht1x_read_data();
//?? sht1x_soft_reset();
while (TRUE){
// delay >11ms before next command
delay_ms(12);
//??sht1x_connection_reset();
// start transmission
sht1x_xmission_start();
// measure temperature
sht1x_command_mode(MEASURE_TEMP);
lValue_temp = sht1x_read_data();
///* ei merkitystä ?
//sht1x_soft_reset();
//sht1x_connection_reset();
// sht1x_soft_reset();
//*/
// delay >11ms before next command
delay_ms(12);
//mittaa_temp();
lValue_temp = sht1x_read_data();
goto ohi;
// temperature calculation
fTemp_true = (D1+(D2*lValue_temp));
// delay 11ms before next command
delay_ms(12);
// start transmission
sht1x_xmission_start();
// measure relative humidity
sht1x_command_mode(MEASURE_HUMI);
lValue_rh = sht1x_read_data();
// relative humidity calculation
fRh_lin = (C1+(C2*lValue_rh)+(C3*lValue_rh*lValue_rh));
fRh_true = (((fTemp_true-25)*(T1+(T2*lValue_rh)))+fRh_lin);
// dewpoint calculation
//fDew_point = sht1x_calc_dewpoint(fRh_true,fTemp_true);
//printf("\nTemperature: %3.6fC",fTemp_true);
//printf("\nRelative Humidity: %3.6f%%",fRh_true);
//printf("\nDew Point: %3.6fC",fDew_point);
//printf("\n");
//* OK
//lValue_temp = 123;
//lValue_rh = 456;
//temp = lValue_temp;
//humidity = lValue_rh;
ohi:
clear_lcd();
delay_ms(100);
show_temp(lValue_temp );
show_kosteus(lValue_rh);
//??sht1x_connection_reset();
//??sht1x_soft_reset();
delay_ms(1000);
//p:;goto p;
}
}
//***********************************************************************************************
|
hope someone help me to get things work ...
all the best
arto |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Mon Jun 23, 2014 3:09 pm |
|
|
Try using the 'search' feature of the forum. I'm pretty sure it's a topic that's been covered before and there may be code in the 'code library' as well.
Also trying Google as well !
jay |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Tue Jun 24, 2014 5:07 am |
|
|
I've just done a quick search on this forum, found loads of examples, some exactly what you need.
Also I'm not inclined to wade though pages of code.
If you want help it's best to post short, compilable code we can copy and paste to test.
At the same time, reduce the scope to the one issue causing a problem.
We don't need to see all the fluff.
Mike |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Jun 24, 2014 6:43 am |
|
|
and BTW: how about that bug free schematic with voltage info ? |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Tue Jun 24, 2014 10:07 am |
|
|
Ive used that sensor successfully with the driver found on the library here.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Tue Jun 24, 2014 10:35 am |
|
|
Gabriel wrote: | Ive used that sensor successfully with the driver found on the library here.
G. |
JEP
please send me those libraries
I tried this today:
http://www.ccsinfo.com/forum/viewtopic.php?t=17181&highlight=sht1x
but it do not work ... lvalue is allways 65535 all the bits are high ...
where I can find those good library drivers ?
friendly regards
-arto- |
|
|
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Tue Jun 24, 2014 10:48 am |
|
|
asmboy wrote: | and BTW: how about that bug free schematic with voltage info ? |
Hello asmboy
lot of thanks for your answer... maybe I'm not getting crazy because I can get so much advices from that good forum ... I'm very happy about it
BTW by the way here is my simple schematic diagram for that tests with PIC18F452... it works fine ... maybe ?
[img]
all the best
-arto- |
|
|
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Tue Jun 24, 2014 11:01 am |
|
|
asmboy wrote: | and BTW: how about that bug free schematic with voltage info ? |
sorry I don't know how to submit that image for you |
|
|
artohautala
Joined: 17 Nov 2011 Posts: 187
|
sensirion SHT15 module problem ... SOLVED |
Posted: Wed Jul 09, 2014 8:13 am |
|
|
finally I solved this problem...
I made driver that really works in practice...
if someone want to see my code pls don't hesitate to ask me more ...
very happy about it [SOLVED] |
|
|
|