Temprature measurement with SHT11 sensor

Status
Not open for further replies.
the shtxx protocol is like an i2c but it is not i2c...
you cannot use a standard i2c bus from any microcontroller
you must program yourself the protocol
there are lot of examples for pic or 8051 on the sensirion web site
 

Hi,
I went through the codes . But they didnt tell about how to get an 1MHz clock cycle..
and also they are using a bi directional pin to put the data OUT and IN..
But My device wont support that bidirectional pin.. How to do that..

Pls help me.. I'm struggling for this...


regards
chethan
 

interface sht11 sensor to zigbee CC2430EM

I tried to interface Sht11 sensor to zigbee development kit (smartRF04EB) with CC2430EM and tried to change the code from sensirion but it don't really work. I don't understand what's wrong with my code (I am new in this zigbee Dev.Kit). Any one help me please the right code to interface sht11 sensor to cc2430?

I really need this code!
Thanks before...

---------- Post added at 10:39 PM ---------- Previous post was at 10:13 PM ----------

Do you have coding for interface sht11 to zigbee cc2430 in c language?
I really need that code!

regard, amh16
 

Re: interface sht11 sensor to zigbee CC2430EM


Can't you find a bit bash code in i2c and change it to match the SHT11 protocol? That is how my company done it. There is plenty of bit bash C code example in the internet for i2c. I think this is the best way for you and it should be a learning experience and shouldn't take too long if you are proficient in embedded C.
 

Hi,
Even I'm also trying for the same..
I tried the BIT BANG method but the problem is CC2430 kit can provide only 3.3 v so I need to drive the SHt11 with less than 1MHz clock cycle. But my controller (cc4230) can provide 32MHz so how to convert it to 1MHz( it wont support I2C and SPI i have used for some other purpose ),.

regards
chethan
 

Have you ever used 'nop' or C defined loops before? Well if you use a combination of both you should be able to bring the clock frequency down to less than 1MHz. I'm sure some of the bit bang I2C code in the net uses this method. Anyway, I have used a 32MHz processor and bit bang I2C at 400 kHz. That uses nop and C defined loops. Like I said take a look at some examples of bit bang code to understand how to do it. There are plenty of examples in how to bit bang i2c. I believe you have ask the TI forum and they also suggest searching their forum or look at an example of bit bang i2c on a different processor via the net.
 

Hi,
I have asked the TI forum but I did not get proper response they just asked to use SPI but I cant use it.

Could you please share your code which you had written for the bit bang I2C at 400MHz .?

regards
chethan
 

You should be able write the code based on my suggestion and I'm not in habit of giving out any code as I indicated that the code is work carried out in a company. If I were you is attempt writing the code and any stumbling blocks, post your code to the forum and state the problem. By asking for code, is just showing pure laziness in my opinion.
 

Hi,
I thought If i get the code it would save my time so I asked the code. its not becoz of laziness .
Actually I'm working on stream processing, my work is to concentrate after I have sensor data stream therefore I didnt want to spend time on the interfacing ... still I have interfaced that .. I coundnt get better example code for that..

any help in this would be appreciable .

regards
chethan
 

Hello

I have a fully working code for SHT11 / SHT15 written in C ( for PIC Microchip ) .
It is able to report temperature in °C and also °F
Dew point is calculated , my code is ready to go.

I tested it with PIC 18F2620 and also 18F97J60 ( working well into ethernet stack )

Im willing to sell my source for 50 euros, if you're interrested to get it, please PM me.
 

Hi,
I need code for CC2430 only,..
I'm carrying out some research work on stream processing on sensor data .
so I need to interface this...

regards
chethan
 

Re: sht11 code


I wonder with the LCD displaying the measurement result

If you have bird circuit diagram (89c51, sht11, lcd)
 
Last edited:

Re: ssb_sensor.h

I attached C18 code for SHT11 sensor.

It has been working for over 5 years now.
 

Attachments

  • SHT11.zip
    3.3 KB · Views: 113

Re: ssb_sensor.h


Anyone know how to program sht11 in atmega8? I need some help in my project:?:
 

this may help ...
**broken link removed**

---------- Post added at 14:05 ---------- Previous post was at 14:04 ----------

this may also help ...

Code:
'//////////////////////////////////////////////////////////////
'///    FastAVR Basic Compiler for AVR by MICRODESIGN       ///
'///    SHT11/15 Temperature and Humidity measurement       ///
'///    14/12 bit                                           ///
'//////////////////////////////////////////////////////////////
$Device= 8515
$Stack = 32                	' stack size
$Clock = 7.3728
$Baud=115200
$ShiftOut Data=PORTD.2, Clk=PORTD.3, 1
$LeadChar=" ", Format(2,3)

$Def dDta=DDRD.2
$Def inDta=PIND.2
$Def Dta=PORTD.2
$Def Sck=PORTD.3

Declare Sub Init()
Declare Sub StartTX()
Declare Sub CommReset()
Declare Function WriteByte(db As Byte) As Byte
Declare Function ReadByte(ack As Byte) As Byte
Declare Function Measure(what As Byte) As Word

Dim tmp As Integer, ftmp As Float
Dim n As Byte
Dim Cta As Byte, Ctb As Integer

Const True=1, False=0
Const ACK=1, NAK=0

Const TmpSHT=&h03
Const HumSHT=&h05
Const ResSHT=&h1e
Const Rstat =&h07
Const Wstat =&h06

Const c1=-4, c2=0.0405, c3=-2.8E-06

Init()

Do
	tmp=Measure(TmpSHT)		' measure Temperature
	ftmp=tmp/100-40
	Print "Temp:"; ftmp
	
	tmp=Measure(HumSHT)		' measure Humidity
	ftmp=c1+tmp*c2+Sqr(tmp)*c3
	Print "Humy:"; ftmp
	Print
	Wait 1
Loop

'//////////////////////////////////////////////////////////////
Sub Init()
WaitMs 20
CommReset()
WriteByte(Wstat)		' write to Status
Set dDta
WriteByte(0)			' 14bit for T, 12 bit for RH
End Sub

'//////////////////////////////////////////////////////////////
Function Measure(what As Byte) As Word
Local tmp As Word

CommReset()
If WriteByte(what)=0 Then	' isue Cmd
	BitWait inDta, 0			' wait for data ready
	tmp=ReadByte(ACK)			' read first byte
	Shift(Left, 8, tmp)			' make it MSB
	tmp=tmp Or ReadByte(NAK)	' read second byte and combine
	'n=ReadByte(NAK)			' no CRC for now
Else
	Print "No sensor!"
	tmp=0
End If
Return tmp
End Function

'//////////////////////////////////////////////////////////////
Sub StartTX()
Set dDta
Set Sck
Reset Dta
Reset Sck
Set Sck
Set Dta
Reset Sck
End Sub

'//////////////////////////////////////////////////////////////
Sub CommReset()
Local i As Byte

Set Dta
For i=0 To 8
	Set Sck: Reset Sck
Next
StartTX()
End Sub

'//////////////////////////////////////////////////////////////
Function WriteByte(db As Byte) As Byte
Local mask As Byte

ShiftOut db				' send data
Reset dDta				' back to input
Set Sck:Reset Sck		' clock ACK
Return inDta			' return ACK (0=SHT present)
End Function

'//////////////////////////////////////////////////////////////
Function ReadByte(ack As Byte) As Byte
Local i As Byte, db As Byte

db=ShiftIn
Set dDta
Dta=Not ack
Set Sck
Reset Sck
Reset dDta
Return db
End Function
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…