Welcome, Guest
Username: Password: Secret Key Remember me

TOPIC: DHT11 anyone?

Re: DHT11 anyone? 8 years 1 month ago #8882

  • jmessina
  • jmessina's Avatar
  • Offline
  • Senior Boarder
  • Posts: 44
  • Thanks received: 189
Thus, eliminating the dependency of the osc with pulsin.
Well, SOMETHING has to be dependant on osc if you want to measure absolute time... pulsin is as good as any I suppose. There's a bunch of different ways of doing this, but since you know the code can work, give it a shot.

I'd take Burt's suggestion and hook up the Pickit2 and use the logic analyzer function. If you set a pin high/low around the calls to pulsin, you can see when you're sampling/what you're actually measuring wrt the sensor's output.

You want to give yourself some leeway since the sensor output isn't always going to be spot on. For example the 'if ip > 70' test checks for a high signal of roughly 43us, and says that must be a '1'. Since a '0' is 26-28us high, 43us is way longer than a '0' should be, so that's probably good enough. It never really checks for a '70us logic 1'.

Re: DHT11 anyone? 8 years 1 month ago #8883

  • jmessina
  • jmessina's Avatar
  • Offline
  • Senior Boarder
  • Posts: 44
  • Thanks received: 189
I forgot to add - if you do use the pickit2 LA function, make sure to use CH3 (AUX, pin 6) to measure the sensor data signal.

The other two channels (CH1 and CH2) have internal 4.7K pulldowns in the pickit2, so they won't work with the open-drain data signal and it's pullup. It would screw up the logic high level and you'd see ~2.5V

Re: DHT11 anyone? 8 years 1 month ago #8884

  • RogerTango
  • RogerTango's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 2
Ok, gotcha...

First things first I guess, Ill wait for my order of more DHT11 units, and try the program again with another unit and go from there.

I dont want to reinvent the wheel if it already works.

Cheers,
Andrew

Re: DHT11 anyone? 8 years 1 month ago #8890

  • red_kooga
  • red_kooga's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 1
Hi Andrew,

I got this working with AMICUS with 18F25K20 using internal osc, i enabled PLL and it worked.
i changed the serial out while testing because i used HRSOUT and didn't disable MCLR.

[proton filename=code.bas]'18f25k22 blank with serial lcd out example

'Device = 18F25K22 '----



'Xtal = 16

Config_Start

'MCLRE = INTMCLR ; RE3 input pin enabled; MCLR disabled
FOSC = INTIO67 ; Internal oscillator block, port function on RA6 and RA7
'pLLCFG = On ; Oscillator multiplied by 4


Config_End

OSCCON.6 = 1 '
OSCCON.5 = 1 'clock = 16Mhz
OSCCON.4 = 1 '

OSCCON.1 = 0 'SCS1
OSCCON.0 = 0 'SCS0

OSCTUNE.6 = 1 'PLLEN = 'PLL on'


'OSCCON = %01110000;
'OSCTUNE = %00100000;


'All_Digital = true

DelayMS 1500

SerOut PORTC.4 , 84 , [$fe,1]
DelayMS 10
SerOut PORTC.4 , 84 , [$fe,1]
DelayMS 10
SerOut PORTC.4 , 84 , ["Program Start"]
DelayMS 1000
SerOut PORTC.4 , 84 , [$fe,1]
DelayMS 10


Dim ip As Byte 'hi pulse from sensor
Dim temp As Byte
Dim hum As Byte
Dim chksm As Byte
Dim temp1 As Byte
Dim hum1 As Byte
Dim temp2 As Word
Dim hum2 As Word
Dim test As Byte
Dim i As Byte
DelayMS 1000 'give sensor time to settle


loop]
DelayMS 10
SerOut PORTC.4 , 84 , ["humidity ",Dec hum,".",Dec hum1,"%"]
SerOut PORTC.4 , 84 , [$fe,$c0]
SerOut PORTC.4 , 84 , ["temp ",Dec temp,".",Dec temp1,"C"]

DelayMS 10


test = (temp1 + hum1 + hum + temp)
If chksm <> test Then

SerOut PORTC.4 , 84 , [$fe,1]
DelayMS 10
SerOut PORTC.4 , 84 , ["SENSOR NOT READY"]


DelayMS 10

EndIf


DelayMS 3000 'give sensor time to settle
GoTo loop


loop1]
DelayMS 10
'HSerOut ["SENSOR NOT READY",13]
HRSOut "sensor not ready",13
GoTo loop[/proton]

Re: DHT11 anyone? 8 years 1 month ago #8952

  • RogerTango
  • RogerTango's Avatar
  • Offline
  • Fresh Boarder
  • Thanks received: 2
Red, I just got my new shipment of DHT11s, the new one "acts" like the original... so I "guess" neither is bad.

Ill try your above code later this week and will report back.

Thanks so much for your time,
Andrew
Time to create page: 0.263 seconds