Hallo,
habe jetzt mal den Sensor auf andere Ports gelegt (PD4 und PD5) allerdings mit dem gleichen Ergebnis!![]()
Auch ein anderes Beispiel Programm:
Funktionierte nicht!Code:'Routine to read the SHT75 Humidity sensor chip 'By Stuart Leslie 'Contact stu@4sightinc.com with any questions 'Uses BascomAVR 'a .01 uf capacitor across VCC and Ground on the SHT75 really cleans up the data 'a pullup is required on "data" pin as shown in the data sheet $regfile = "m8def.dat" $crystal = 16000000 ' used crystal frequency $baud = 9600 ' use baud rate $hwstack = 32 ' default use 32 for the hardware stack $swstack = 32 ' default use 10 for the SW stack $framesize = 32 ' default use 40 for the frame space Dim Ctr As Byte Dim Dataword As Word Dim Command As Byte Dim Dis As String * 20 Dim Calc As Single Dim Calc2 As Single Dim Rhlinear As Single Dim Rhlintemp As Single Dim Tempc As Single 'Dim Tempf As Single Const C1 = -4 Const C2 = 0.0405 Const C3 = -0.0000028 Const T1c = .01 Const T2 = .00008 'Const T1f = .018 Sck Alias Portd.4 Dataout Alias Portd.5 Datain Alias Pind.5 'Redled Alias PortD.2 Declare Sub Getit() Ddrd = &B11111111 'all port b are output Config Pind.4 = Output 'sck Config Pind.5 = Output 'datain 'reset the serial communications first, it is easily confused! Set Dataout For Ctr = 1 To 12 Set Sck Waitus 2 Reset Sck Waitus 2 Next Ctr Do 'continually read the tempfature and humidity Command = &B00000011 Call Getit 'Get the temperature, puts result in "dataword" for us ' 'Tempf = T1f * Dataword 'Tempf = Tempf - 40 Tempc = T1c * Dataword 'get celcius for later calculations and for "the rest of the world" Tempc = Tempc - 40 Dis = Fusing(tempc , "###.##") Print "Temperatur = " ; Dis ; Chr(167) ; "C" Command = &B00000101 Call Getit 'get the humidity Calc = C2 * Dataword Calc2 = Dataword * Dataword 'that "2" in the datasheet sure looked like a footnote for a couple days, nope it means "squared"! Calc2 = C3 * Calc2 Calc = Calc + C1 Rhlinear = Calc + Calc2 'Dis = Fusing(rhlinear , "##.##") 'Print "Humidity adjusted for linear = " ; Dis Calc = T2 * Dataword Calc = Calc + T1c Calc2 = Tempc - 25 Calc = Calc2 * Calc Rhlintemp = Calc + Rhlinear Dis = Fusing(rhlintemp , "##.##") Print "Luftfeuchte = " ; Dis ; " %" Wait 1 Loop Sub Getit() Local Datavalue As Word Local Databyte As Byte 'start with "transmission start" Set Sck Reset Dataout Reset Sck Set Sck Set Dataout Reset Sck 'now send the command Shiftout Dataout , Sck , Command , 1 Ddrd = &B11111101 'datain is now input Config Pind.5 = Input 'datain Set Sck 'click one more off Reset Sck Waitus 10 'no idea why, but it doesn't work without it! Bitwait Pind.7 , Reset 'wait for the chip to have data ready Shiftin Datain , Sck , Databyte , 1 'get the MSB Datavalue = Databyte Ddrd = &B11111111 Config Pind.5 = Output Reset Dataout 'this is the tricky part- Lot's of hair pulling- have to tick the ack! Set Sck Reset Sck Ddrd = &B11111101 'datain is now input Config Pind.5 = Input Shiftin Datain , Sck , Databyte , 1 'get the LSB Shift Datavalue , Left , 8 Datavalue = Datavalue Or Databyte 'don't tick the clock or ack since we don't need the CRC value, leave it hanging! Dataword = Datavalue Ddrd = &B11111111 Config Pind.5 = Output Reset Dataout Set Sck Reset Sck Ddrd = &B11111101 'datain is now input Config Pind.5 = Input Shiftin Datain , Sck , Databyte , 1 'not using the CRC value for now- can't figure it out! Anybody know how to impliment? 'Print "CRC value was - " ; Databyte Ddrd = &B11111111 Config Pind.5 = Output Set Dataout Set Sck Reset Sck End Sub End
Ausgabe war immer:
Was kann das sein?Code:Temperatur = 612.80°C Luftfeuchte = -6216.70 %
Der Sensor ist in Ordung, an einer C-Control funktioniert er!!!







Zitieren

Lesezeichen