| Author |
Message |
gricesj
Joined: 10 Jan 2005 Posts: 6
|
10 Jan 2005 16:17 Re: Temprature measurement with SHT11 sensor |
|
|
|
Hello,
I am currently designing a microprocessor contolled parrot incubator. I am using the SHT15 sensor (the SHT11 is out of stock), the ATMEL ATMega8 micro-controller, and the LM016L (2x16) LCD display. The trouble is I have never had to programme before and have no clue on how to write the code for the micro-controller. Please Help!
I was hoping someone could provide me with the AVR code which would interface the SHT15 with the ATMega8, and then output it to the LCD. By looking at the picture of the LCD on the first link, the connections are identical to the LM016L LCD.
Any help offered would be VERY MUCH appreciated! I can't afford to buy a proper incuabtor, they are way too expensive!
Many thanks indeed,
Steve.
E-mail: captaingrice(at)blueyonder.co.uk.
|
|
| Back to top |
|
 |
mgajo
Joined: 15 May 2001 Posts: 347
|
14 Jan 2005 23:04 Re: Temprature measurement with SHT11 sensor |
|
|
|
Hi
Take a look at w_w.fastavr.com
they have code for avr and sht11, also Bascom AVR site.
Hope this will help, but sht11 is difficult sensor to start with
anyway wish you luck
|
|
| Back to top |
|
 |
gricesj
Joined: 10 Jan 2005 Posts: 6
|
17 Jan 2005 22:21 Re: Temprature measurement with SHT11 sensor |
|
|
|
Hi, thanks for the reply.
The trouble is, I have to do it in assembly code, using the AVR Studio 3.56. So far I have my 2x16 display outputting a user defined sentence, in my case, I've put in "Roll on Easter, 11 weeks to go"
My code so far is:
--------------------------
.include "m8def.inc"
.def temp =r16
.def disp =r17
.equ width =$00dd
;********************************************************
.equ LCD_O =portd ;Output to LCD
.equ LCD_I =pinb ;Input from LCD
.equ CTRL_O =portc ;Control output
.equ E =2 ;Active high enable
.equ DC =0 ;Data/Command
.equ BF =7 ;Busy Flag
.equ FS =$3f ;Function set
.equ DISP_ON =$0c ;Display on w/o blink or flash
.equ DISP_OFF =$08 ;Display, blink, cursor off
.equ DISP_CL =$01 ;Clear display
.equ DISP_EN =$06 ;Data entry mode
.equ LINE_1 =$80 ;DDRAM address for first line
.equ LINE_2 =$c0 ;DDRAM address for second line
.equ SH_LFT =$18 ;Left-shift display
.equ SH_RT =$1c ;Right-shift display
.equ HOME =$02 ;Return home
;********************************************************
reset: ldi temp, low(ramend)
out SPL, temp
ldi temp, high(ramend)
out SPH, temp
ser temp
out DDRB, temp
out DDRC, temp
out DDRD, temp
;rjmp pwm
rcall lcd_en
rcall del
rcall del
rcall del
rcall del
rcall del
ldi zl, low(Steve*2)
ldi zh, high(Steve*2)
loop2: lpm disp, z+
cpi disp, $ff
breq label
rcall wrt_d
rcall del
rjmp loop2
label: ldi disp, Line_2
rcall wrt_c
ldi zl, low(date*2)
ldi zh, high(date*2)
loop: lpm disp, z+
cpi disp, $ff
breq pwm
rcall wrt_d
rcall del
rjmp loop
;*********************************
pwm: ldi temp, $a1
out TCCR1A, temp
ldi temp, high(width)
out OCR1AH, temp
out OCR1BH, temp
ldi temp, low(width)
out OCR1AL, temp
out OCR1BL, temp
ldi temp, $01
out TCCR1B, temp
here: rjmp here
;********************************************************
;Set up lcd
LCD_EN: rcall del
rcall del
rcall del
rcall del
ldi disp, FS
rcall wrt_c
rcall wrt_c
rcall wrt_c
rcall wrt_c
rcall del
rcall del
ldi disp, DISP_ON
rcall wrt_c
ldi disp, DISP_EN
rcall wrt_c
ldi disp, DISP_CL
rcall wrt_c
rcall del
rcall del
ret
;********************************************************
;********************************************************
;Writes the command in the 'disp' register to the LCD.
wrt_c: rcall del
cbi CTRL_O, DC
sbi CTRL_O, E
out LCD_O, disp
cbi CTRL_O, E
ret
;********************************************************
;Writes data in the 'disp' register to the LCD.
wrt_d: rcall del
sbi CTRL_O, DC
sbi CTRL_O, E
out LCD_O, disp
cbi CTRL_O, E
ret
;********************************************************
;********************************************************
;64us delay using 8-bit timer
del: push temp
ldi temp, $df
out TCNT0, temp
ldi temp, $02
out TCCR0, temp
dloop: in temp, TIFR
andi temp, $01
cpi temp, $01
breq cflg
cpi temp, $08
brne dloop
cflg: ldi temp, $01
out TIFR, temp
clr temp
out TCCR0, temp
pop temp
ret
;********************************************************
Steve: .db "ROLL ON EASTER--",$ff,$ff
date: .db "11 WEEKS TO GO!!",$ff
------------------
The PWM is to control power resistors which I am using as a heater. The code you pointed me in the direction os great, but its in BASIC. I have to do it in assembly language. Can that code be converted to Assembly? If so, how?
Can you help me please? I don't have a clue! By the way, this code is not mine, it was given to me by someone - please dont think I can program :0).
Anyway, I hope you can help.
Many thanks,
Steve (captaingrice(at)blueyonder.co.uk)
|
|
| Back to top |
|
 |
SAR
Joined: 25 Sep 2002 Posts: 152 Helped: 4
|
18 Jan 2005 1:41 Re: Temprature measurement with SHT11 sensor |
|
|
|
Talk to Steve Hageman at: http://www.analoghome.com/projects/dewpointer.html
He will give you the code and you can adapt it to the AVR micro. His code is for the pic. His code using CCS C compiler.
|
|
| Back to top |
|
 |
jobla
Joined: 19 Jan 2005 Posts: 4
|
19 Jan 2005 11:22 Re: Temprature measurement with SHT11 sensor |
|
|
|
Hello,
i wrote code for the sht-11 using avr-gcc some time ago.
Perhaps it will help you. I put the code below, like it is.
That means the comments are in german and there are some
missing code-parts (helper-functions like delay) and some parts
not necessary (because it was intended to run two of these sensors on
different inputs).
If this is a problem, tell me, and i will translate it.
Furthermore i do not garantie error-freeness.
Greets,
J. B.
|
|
| Back to top |
|
 |
gricesj
Joined: 10 Jan 2005 Posts: 6
|
19 Jan 2005 15:14 Re: Temprature measurement with SHT11 sensor |
|
|
|
JB,
Many thanks, can I ask as Im not familiar with programming, is this Assembly language?
If you have the time to translate into English that would be great!
Thank you very much indeed for your help, I really appreciate it.
Steve.
|
|
| Back to top |
|
 |
jobla
Joined: 19 Jan 2005 Posts: 4
|
20 Jan 2005 12:58 Re: Temprature measurement with SHT11 sensor |
|
|
|
Hi Steve,
i added some comments and translated the existing ones to english. The programming-language is C. Good Luck
Johann
|
|
| Back to top |
|
 |
jobla
Joined: 19 Jan 2005 Posts: 4
|
20 Jan 2005 13:09 Re: Temprature measurement with SHT11 sensor |
|
|
|
addon: i know you need the assembly, but i have only the C-sources. The only thing i can do for you is to give you the disassembled C-Code. But disassembled C-Code isn't too easy to read. If it helps, here it is:
|
|
| Back to top |
|
 |
rolemodel
Joined: 30 Mar 2005 Posts: 2
|
30 Mar 2005 18:17 Re: Temprature measurement with SHT11 sensor |
|
|
|
| Hi i'm need help with my project , i'm building a device that read temp and humidity , i use a pic16f84 and a sht11 sencor also my device has a lcd display , please some one can help me with the source code for the pic , of any thing that can help me
|
|
| Back to top |
|
 |
gricesj
Joined: 10 Jan 2005 Posts: 6
|
30 Mar 2005 19:03 Re: Temprature measurement with SHT11 sensor |
|
|
|
Do you have to use the pic16f84? And what language do you have to program in?
Steve
|
|
| Back to top |
|
 |
rolemodel
Joined: 30 Mar 2005 Posts: 2
|
06 Apr 2005 18:50 Re: Temprature measurement with SHT11 sensor |
|
|
|
| gricesj wrote: |
Do you have to use the pic16f84? And what language do you have to program in?
Steve |
hi i have to program in C , my progam is pic c compiler , if you can help me , my email is kuku41(at)hotmail.com
|
|
| Back to top |
|
 |
vadlimus
Joined: 22 May 2005 Posts: 1
|
22 May 2005 12:30 plise help me!!! |
|
|
|
hello
anyone can help me with a schematic for connecting sht11 with an AVR Atmega8 and seding results to a PC using USB. I would appreciate some links or advices. I have to do a project with this subject and I can't find anything with usb,atmel and sht11 together. And program in C....
Thank you in advance
vadlimus(at)yahoo.com
|
|
| Back to top |
|
 |
frederic
Joined: 03 Jun 2005 Posts: 1
|
03 Jun 2005 15:05 Re: Temprature measurement with SHT11 sensor |
|
|
|
Hi Everyone,
I am currently trying to set up communication between the SHT71 sensor and a PIC18F452 microcontroller. I cant receive any data from the sensor. Please does anyone have an example code using a similar a similar microcontroller with the MPLAB C18 compiler. That would be extremely helpful.
THANK U VERY MUCH
FREDERIC
|
|
| Back to top |
|
 |
Kripton2035
Joined: 19 Jul 2001 Posts: 419 Helped: 8 Location: Earth
|
09 Jul 2005 14:47 Temprature measurement with SHT11 sensor |
|
|
|
the code I gave at the previous page is for pic 16f876 and sht11 written in ccs c
it should not be a big work to translate it (if either it needs it !!!) to 18f452, sht71 and mplab c18 !!!!!!
|
|
| Back to top |
|
 |
willie
Joined: 27 Mar 2006 Posts: 3
|
28 Mar 2006 12:21 Re: Temprature measurement with SHT11 sensor |
|
|
|
| asena wrote: |
And i have it for Microchips C18.
It works very well with the 18F series.
asena |
Could somebody maybe post some code snippets for the C18.
|
|
| Back to top |
|
 |
vlad2007
Joined: 29 Mar 2006 Posts: 2
|
29 Mar 2006 13:58 Re: Temprature measurement with SHT11 sensor |
|
|
|
| willie wrote: |
| asena wrote: |
And i have it for Microchips C18.
It works very well with the 18F series.
asena |
Could somebody maybe post some code snippets for the C18. |
Hi
do you managed to read the sht11 sensor using the mplap c18 compiler? I have a Pic18f4550 and I am trying for 2 long days to comunicate with the sensor but it`s not working. I tryed to rewrite ccs code and even the c code form the sensirion web site but it still doesn`t work.
If you succeed this issue using c18, please let me now. Even if not, maybe we can still keeping touch.
Thanks,
Vlad
|
|
| Back to top |
|
 |
willie
Joined: 27 Mar 2006 Posts: 3
|
29 Mar 2006 16:34 Re: Temprature measurement with SHT11 sensor |
|
|
|
| vlad2007 wrote: |
| willie wrote: |
| asena wrote: |
And i have it for Microchips C18.
It works very well with the 18F series.
asena |
Could somebody maybe post some code snippets for the C18. |
Hi
do you managed to read the sht11 sensor using the mplap c18 compiler? I have a Pic18f4550 and I am trying for 2 long days to comunicate with the sensor but it`s not working. I tryed to rewrite ccs code and even the c code form the sensirion web site but it still doesn`t work.
If you succeed this issue using c18, please let me now. Even if not, maybe we can still keeping touch.
Thanks,
Vlad |
Hi Vlad!
I will use the sht75, but I thing this will make not a big different.
This week I will try to find time to wirte some first comunication code (wiht mpl c18).
I will report my progress.
Willie
|
|
| Back to top |
|
 |
vlad2007
Joined: 29 Mar 2006 Posts: 2
|
01 Apr 2006 8:05 Re: Temprature measurement with SHT11 sensor |
|
|
|
Hi Willie!
I finally succeded to comunicate with the sht11 sensor. I attached the working code. Let me know how it works with your SHT75. Do you know where I can find the ftoa.c library, used to convert float numbers to ASCII ? In this example I used a trick to show the read values with two digits.
Thanks,
Vlad
|
|
| Back to top |
|
 |
willie
Joined: 27 Mar 2006 Posts: 3
|
02 Apr 2006 14:21 Re: Temprature measurement with SHT11 sensor |
|
|
|
Hi!
I will try you code!
ftoa :
http://forum.microchip.com/tm.aspx?m=141613&mpage=1&key=float𢦸
Tracy Kuhrt
Moderator
To answer the question--No, MPLAB C18 does not yet support floating-point with the standard output functions (e.g., printf, sprintf). I believe there was a post on this recently that pointed to another thread that gave example code.
...
http://forum.microchip.com/tm.aspx?m=55402&mpage=1&key=sprintf&# :
I also have a sprintf routine if anyone is interested.
/*******************************************************************
* FUNCTION: ftoa
* AUTHOR = TRAMPAS STERN
* FILE = strio.c
* DATE = 2/6/2003 4:27:14 PM
*
* PARAMETERS: long,*str, int count
*
* DESCRIPTION: Convets an float to string
* format 'f', 'E', or 'e'
*
*
* RETURNS:
*
* NOTE this code was found on the web and modified to actually work
*******************************************************************/
int ftoa (float x, CHAR *str, char prec, char format)
{
int ie, i, k, ndig, fstyle;
double y;
CHAR *start;
start=str;
//based on percission set number digits
ndig=prec+1;
if (prec<0)
ndig=7;
if (prec>22)
ndig=23;
fstyle = 0; //exponent 'e'
if (format == 'f' || format == 'F')
fstyle = 1; //normal 'f'
if (format=='g' || format=='G')
fstyle=2;
ie = 0;
/* if x negative, write minus and reverse */
if ( x < 0)
{
*str++ = '-';
x = -x;
}
//if (x<0.0) then increment by 10 till betwen 1.0 and 10.0
if (x!=0.0)
{
while (x < 1.0)
{
x =x* 10.0;
ie--;
}
}
//if x>10 then let's shift it down
while (x >= 10.0)
{
x = x*(1.0/10.0);
ie++;
}
if (ABS(ie)>MAX_MANTISA)
{
if (fstyle==1)
{
fstyle=0;
format='e';
//ie=2;
}
}
/* in f format, number of digits is related to size */
if (fstyle)
ndig =ndig + ie;
if(prec==0 && ie>ndig && fstyle)
{
ndig=ie;
}
/* round. x is between 1 and 10 and ndig will be printed to
right of decimal point so rounding is ... */
y=1;
for (i = 1; i < ndig; i++) //find lest significant digit
y = y *(1.0/10.0); //multiply by 1/10 is faster than divides
x = x+ y *(1.0/2.0); //add rounding
/* repair rounding disasters */
if (x >= 10.0)
{
x = 1.0;
ie++;
ndig++;
}
//check and see if the number is less than 1.0
if (fstyle && ie<0)
{
*str++ = '0';
if (prec!=0)
*str++ = '.';
if (ndig < 0)
ie = ie-ndig; /* limit zeros if underflow */
for (i = -1; i > ie; i--)
*str++ = '0';
}
//for each digit
for (i=0; i < ndig; i++)
{
float b;
k = x; //k = most significant digit
*str++ = k + '0'; //output the char representation
if (((!fstyle && i==0) || (fstyle && i==ie)) && prec!=0)
*str++ = '.'; //output a decimal point
b=(float)k;
//multiply by 10 before subtraction to remove
//errors from limited number of bits in float.
b=b*10.0;
x=x*10.0;
x =x - b; //subtract k from x
//b=x+b;
//x =x* 10.0; //get next digit
}
/* now, in estyle, put out exponent if not zero */
if (!fstyle && ie != 0)
{
*str++ = format;
if (ie < 0) //if number has negative exponent
{
ie = -ie;
*str++ = '-';
}
//now we need to convert the exponent to string
for (k=1000; k>ie; k=k/10); //find the decade of exponent
for (; k > 0; k=k/10)
{
char t;
t=DIV(ie,k);
*str++ = t + '0';
ie = ie -(t*k);
}
}
*str++ = '\0';
return (str-start); //return string length
}
|
|
| Back to top |
|
 |
abihasan
Joined: 06 Mar 2006 Posts: 1
|
01 May 2006 4:36 Temprature measurement with SHT11 sensor |
|
|
|
my name thedy,
i have a problem interfacing SHT11 and atmega8535,i'am using winAVR to make a program and to compile it, when i read Mr. Jobla file "sht11.pdf" i think i can use it, but the problem is, there is an include that i cannot found....
there is :
#include "ssb_sensor.h"
#include "ssb_magic_number.h"
so, since i cannot found it, i cannot use it to my project...
anybody can help me how to solve this problem???
|
|
| Back to top |
|
 |
fatihpenbe
Joined: 04 Jun 2006 Posts: 1
|
04 Jun 2006 14:36 Temprature measurement with SHT11 sensor |
|
|
|
| does anyone have the schematics and source codes? can u send it to me. thanks in advance...
|
|
| Back to top |
|
 |
meiling9
Joined: 02 May 2007 Posts: 1
|
02 May 2007 11:46 Re: Temprature measurement with SHT11 sensor |
|
|
|
i have acquired several SHT15 sensors and i am using them to monitor temperature gradients inside a room. i am already able to retrieve data and convert them to actual values. the problem i have is i observe fluctuations of almost +/-6degC in the readings. is this normal even though i can not think of anything that might cause this sharp rise? i sample every 15seconds.
here's a sample of several datapoints i have:
counter, LM35, SHT15
...
12,22.070, 33.160
13,22.119, 33.200
14,22.119, 26.960
15,22.070, 25.720
16,22.070, 25.080
17,22.070, 31.000
18,22.070, 25.720
19,22.021, 24.840
20,22.021, 30.720
21,22.021, 31.760
thank you.
|
|
| Back to top |
|
 |
kicco
Joined: 03 May 2007 Posts: 1
|
04 May 2007 0:05 Re: Temprature measurement with SHT11 sensor |
|
|
|
sorry i m new i would know how send a float number into a 16x2 lcd using st7 micro
with c code.
for esemple if the result of temperature is 76.58 i would display the same number in the lcd.
i wait for help.
yankinibra(at)hotmail.com
|
|
| Back to top |
|
 |
gpakos
Joined: 04 Apr 2008 Posts: 7
|
04 Apr 2008 18:18 Re: Temprature measurement with SHT11 sensor |
|
|
|
Hello all,
I am very new to this forum as you can see from my post number!
I have noticed that the date of these messages is a bit old, but i would appreciate you help.
Did anyone manage to attach the SHT11 humidity sensor to his circuit?
I want to interface the SHT11 with a PIC and and LCD.
If someone can, is it possible to attach the schematics and the source code for me?
I prefer the code to be in assembly (.asm)
Thank u for your time
|
|
| Back to top |
|
 |
london_bet
Joined: 16 Jun 2008 Posts: 1
|
06 Jul 2008 21:46 Temprature measurement with SHT11 sensor |
|
|
|
does anyone have a report after they fınıshed their projects or kind of similar jobs.I m gonna write a report for SHT11 and PİC 16F84 temperature and humıdıty measurement and ı m looking for a predone report whıch could be very helpful.Please contact me by thıs email:
nip-tuckca(at)hotmail.com
thanks alot
|
|
| Back to top |
|
 |