DHT11 w/ Axe033

Axel87

Senior Member
Hello again guys!

Working on this DHT11 again, and would like to add my Axe033 display module to it.

I have been following along in this thread for the DHT11 code and circuit-
http://www.picaxeforum.co.uk/showthread.php?22382-DHT11-DHT22-on-a-PICAXE-Solved-in-software&highlight=dht11
And also-
http://www.picaxeforum.co.uk/showthread.php?19459-DHT11-Humidity-Sensor&highlight=dht11

I am currently using a 40x2, and do get stable readings in the terminal window.
What I am aiming to do now is get that information onto my display.

I am using this code provided by Goeytex( I believe?)

Code:
'**********************************************************
'*   PICAXE BASIC FOR READING DHT-11 WITH PICAXE 28X2     * 
'**********************************************************

#picaxe 40x2
#no_table
setfreq em64
high c.0

init:
symbol bit_num = b0
symbol humidity = b2
symbol temperature = b4
symbol numbits = b6

GET_DATA:
pause 12500 'Stabilize 2 seconds
setfreq em64 'Must read Sensor @ 64mhz !

ptr = 1                 'Set Scratch Pad pointer to "1"
pulsout c.0, 35000      'Req Data from DHT-11

pulsin c.1,1,@ptr        'First bit (will be ignored so don't increment)

'Humidity bits (Integer) 
pulsin c.1,1,@ptrinc   'SP Location 1
pulsin c.1,1,@ptrinc   'SP location 2
pulsin c.1,1,@ptrinc   'SP location 3
pulsin c.1,1,@ptrinc   'SP location 4
pulsin c.1,1,@ptrinc   'SP location 5
pulsin c.1,1,@ptrinc   'SP location 6
pulsin c.1,1,@ptrinc   'SP location 7
pulsin c.1,1,@ptrinc   'SP location 8

'Humidity Bits (Decimal)
pulsin c.1,1,@ptrinc 'not used with DHT11
pulsin c.1,1,@ptrinc 'not used
pulsin c.1,1,@ptrinc 'not used
pulsin c.1,1,@ptrinc 'not used
pulsin c.1,1,@ptrinc 'not used
pulsin c.1,1,@ptrinc 'not used
pulsin c.1,1,@ptrinc 'not used
pulsin c.1,1,@ptrinc 'not used

'Temperature bits (Integer)
pulsin c.1,1,@ptrinc 
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc

'Temperature Bit (Decimal) 
pulsin c.1,1,@ptrinc 'Not used
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc

'Checkusm bits
pulsin c.1,1,@ptrinc 
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc
pulsin c.1,1,@ptrinc


setfreq em32 'Reduce Frequency for Serial @38400
pause 100


'******* 'For testing / debugging *****************

numbits = ptr - 1
Sertxd ( "Received: ",#Numbits," Bits",cr,lf,cr,lf)

Sertxd ("Humidity Vals:    ") 
for ptr = 1 to 8
   sertxd (#@ptr, " ")
next
sertxd(cr,lf,cr,lf)

sertxd ("Temperature Vals: ")
for ptr = 17 to 24
   sertxd (#@ptr, " ")
next
Sertxd (Cr,lf,cr,lf)

'************************************************




'*** Process 8 Humidity bits ***
Humidity = 0           ' Clear humidity variable B2

For ptr = 1 to 8         'Read bits 1 - 8 (ignoring bit 0)
   bit_num = 8 - ptr     'Bit# 7 - 0 for Humidity Var B2

   if @ptr > 90  then
      setbit humidity,bit_num     'Set b2 bit(x) to 1
   endif

   if @ptr < 60  then              'Set b2 bit(x) to 0
      clearbit humidity,bit_num
   endif
Next

'Don't care about bits 9- 16


'*** Process 8 temperature bits ***
Temperature = 0        'Clear Temperature variable B4

For ptr = 17 to 24     'Read DHT-11 bits 17 - 24
   bit_num = 24 - ptr     'Bit# 7 - 0 for Temperature Var B2

   if @ptr > 90 then       'Set b4 bit(x) to 1
      setbit temperature,bit_num
   endif

   if @ptr < 60 then 'set b4 bit(x) to 0
      clearbit temperature,bit_num
   endif
Next

'**** Skipping Checksum ****  

'**** Convert C to F****
symbol F=w0
symbol C1=Temperature

F=9*C1/5+32 

'*** Display data ***


sertxd ("Temperature: ",#w0,176,"F",cr,lf)
sertxd ("Rel Humidity: ",#humidity,"%",cr,lf,cr,lf)

GOTO GET_DATA      'LOOP

Now, I figured all I needed to do was use serial out A.4 on the 40x2 that would give me my display, but it doesnt.

Heres the code I tried most recent-


Code:
sertxd ("Temperature: ",#w0,176,"F",cr,lf)
sertxd ("Rel Humidity: ",#humidity,"%",cr,lf,cr,lf)

serout A.4,N2400,(254,128) ; move to start of first line
		serout A.4, N2400,(254,1)
		pause 30
		serout A.4, N2400,("Temperature: ",#w0,176,"F",cr,lf)
		serout A.4,n2400,(254,192)
		serout A.4,n2400,("Rel Humidity: ",#humidity,"%",cr,lf,cr,lf)
I also tried C.0,C.6 but to no avail.
Do I need to modify my circuit at all or does the problem lie in my code?

Also, While I have your attention- What is the difference between serout and Hserout?

Thank you!
 

Goeytex

Senior Member
It won't work because the processor is operating at 32MHz and your serout is at "N2400" with no freg designator. 2400 baud is not supported @ 32MHz, so you must change the processor to 16Mhz and then use "N2400_16" for sending data to the display. When using serout it always a good idea to use 2400_xx instead of "N2400" without the freq designator. See the manual 2 page 208 for proper use of serout and supported baud rate / frequency combinations.

Hserout can be used at any baud rate / freq combination. Manual 2 page 94, 93 for setup and usage.
 

Axel87

Senior Member
Thank you Goeytex

I was able to get the display to work by changing the frequency.

If I may ask, now i would like to try to add the Date/Time in the display as well.
(This will be my first attempt with Date/Time writing)
I am only getting "Serial LCD" on the second screen refresh

Thanks again for your help


Code:
' Display to Axe033
setfreq m16 ' changes op speed to INTERNAL 16MHz

pause 500 			; wait for screen to initiate
	main: serout A.4,N2400_16,(254,128) ; move to start of first line
		serout A.4, N2400_16,(254,1)
		pause 30
		serout A.4, N2400_16,("Temp: ",#w0,176,"F")
		pause 30
		serout A.4, N2400_16,(254,192)
		serout A.4, N2400_16,("Humidity: ",#humidity,"%")
		pause 500
		serout A.4, N2400_16,(254,128) ; move to start of first line for date
		serout A.4, N2400_16,(254,1)
		pause 30
		serout A.4,N2400_16, (253,0,"25/12/01 22:00")
		serout A.4,N2400_16, (254,0,"25/12/01 22:00")
		pause 1000
		serout A.4,N2400_16, (0)
		pause 30
		serout A.4,N2400_16,(254,192)' move to second line for clock
		serout A.4,N2400_16, (1)
		pause 10
		serout A.4,N2400_16, (0)
		pause 490
		goto main
 
Top