DHT11

Arco

Special Member

Ik ga de SHT21 gebruiken, maar die is wel duurder...

Arco - "Simplicity is a prerequisite for reliability" - hard-, firm-, en software ontwikkeling: www.arcovox.com
Bavelt

Golden Member

Ik had inmiddels een site gevonden die verschillende sensoren vergelijkt.
De BME280 wordt veel genoemd. Die had ik ook, maar herinner me dat het geen fijn ding was om te lezen met allerlei ingewikkelde 'conversies'.
Komt bij dat de BME280 licht 'zelfverwarmend' is vanwege zijn stroomverbruik.
Dat resulteert dan al gauw in een afwijking van 1 tot 1,5 Gr (te hoog).
Dat vind ik nogal wat...

Fouten zijn het bewijs dat je het probeert..
Arco

Special Member

Met de BME280 heb ik het na de datasheet lezen opgegeven, die is veel en veel te gecompliceerd.
De conversies vallen wel mee, het ergste vind ik dat alle metingen van elkaar afhangen en gecalibreerd moeten worden.

Daarbij hanteert men schijnbaar ook de regel: "hoe omschrijf ik de werking zo moeilijk mogelijk"... ;)

Arco - "Simplicity is a prerequisite for reliability" - hard-, firm-, en software ontwikkeling: www.arcovox.com

Er zijn goede libraries voor. Ook als je het zelf wilt schrijven geeft dat een basis.
Ik ben wel een fan van de BME280. Hij kan het verschil in luchtdruk tussen op de tafel en op de grond meten :)

Dit zijn de voorbeelden van de BME- en oled Adafruit libraries aan elkaar geknoopt, met een zero drukknopje als extra om relatief te meten.
Eigen opwarming is in mijn beleving alleen een probleem als men erg vaak uitleest.

Bavelt

Golden Member

Op 31 mei 2021 22:18:07 schreef Aart:
Er zijn goede libraries voor. Ook als je het zelf wilt schrijven geeft dat een basis.
Ik ben wel een fan van de BME280. Hij kan het verschil in luchtdruk tussen op de tafel en op de grond meten :)
[bijlage]

Dit zijn de voorbeelden van de BME- en oled Adafruit libraries aan elkaar geknoopt, met een zero drukknopje als extra om relatief te meten.
Eigen opwarming is in mijn beleving alleen een probleem als men erg vaak uitleest.

Mooi groot lettertype, Aart. Is toch een 0,96" Oled displaytje?
Heb je daar een character tabel van?

(De grootste die ik heb is (8 * 16)

Fouten zijn het bewijs dat je het probeert..
Arco

Special Member

Is ook een 16*32 voor, hoor... ;) (doet gewoon de 8x16 characters * 2)

pic basic code:


'==================================================================================================
Sub Function Lcd_Split(Dim pOdd, pByte As Byte) As Byte
'==================================================================================================
  If pOdd Then
    Result.0 = pByte.4
    Result.1 = pByte.4
    Result.2 = pByte.5
    Result.3 = pByte.5
    Result.4 = pByte.6
    Result.5 = pByte.6
    Result.6 = pByte.7
    Result.7 = pByte.7
  Else
    Result.0 = pByte.0
    Result.1 = pByte.0
    Result.2 = pByte.1
    Result.3 = pByte.1
    Result.4 = pByte.2
    Result.5 = pByte.2
    Result.6 = pByte.3
    Result.7 = pByte.3
  End If
End Sub


'==================================================================================================
Sub Procedure Lcd_Char_16x32(Dim px, py, pchar As Byte)
'==================================================================================================
  Dim lIndex As Word
      lByte As Byte
  '----------------------------------------------------------------------------
  lIndex = pChar - 0x20
  lIndex = (lIndex << 4)

  Lcd_SetPos(px, py)
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+7]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+7]))

  Lcd_SetPos(px, py+1)
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+7]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+7]))

  Lcd_SetPos(px, py+2)
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+15]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+15]))

  Lcd_SetPos(px, py+3)
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+15]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+15]))
End Sub

'==================================================================================================
Sub Procedure Lcd_String_16x32(Dim px, py As Byte, Dim ByRef pDisp As String)
'==================================================================================================
  Dim lLen, lCnt As Byte
  '----------------------------------------------------------------------------
  lLen = Length(pDisp)
  For lCnt = 0 To (lLen-1)
    Lcd_Char_16x32(px+1, py, pDisp[lCnt])
    px = px + 16
  Next lCnt
End Sub

Voor de BME 280 staat trouwens een MB library op Libstock...
https://libstock.mikroe.com/projects/view/1555/weather-click

Arco - "Simplicity is a prerequisite for reliability" - hard-, firm-, en software ontwikkeling: www.arcovox.com
Bavelt

Golden Member

Ja, dat is ook een grappige, zeg :)

Geen nieuwe tabel, maar twee keer zo groot maken met een routine...

Het werkt (uiteraard).
Is nu wel héél groot: er kunnen net 2 'regels' op.

In het voorbeeld van Aart kunnen er precies 3 rijen op een 0,96" Oled displayje van 128 * 64 pixels.

Die 64 - 2 (blanke 'regel') = 62 / 3 kom je uit op ca 21.

Ik heb al wel lopen zoeken naar iets in die geest...

Fouten zijn het bewijs dat je het probeert..
Arco

Special Member

Simpelste oplossing: 1.3" display nemen... ;)
Ik heb me wel altijd verwonderd over het feit dat ze er maar in 2 maten zijn: 0.96" (0.91" in kleur) en 1.3"

Arco - "Simplicity is a prerequisite for reliability" - hard-, firm-, en software ontwikkeling: www.arcovox.com
Frederick E. Terman

Honourable Member

Op 31 mei 2021 22:18:07 schreef Aart:
Ik ben wel een fan van de BME280. Hij kan het verschil in luchtdruk tussen op de tafel en op de grond meten :)

Zo'n tafel heb ik ook eens gehad, maar was toch onpraktisch, zo hoog. :) ;)

Keramisch, kalibratie, parasitair: woordenlijst.org
Bavelt

Golden Member

Op 2 juni 2021 01:34:34 schreef Arco:
Is ook een 16*32 voor, hoor... ;) (doet gewoon de 8x16 characters * 2)

pic basic code:


'==================================================================================================
Sub Function Lcd_Split(Dim pOdd, pByte As Byte) As Byte
'==================================================================================================
  If pOdd Then
    Result.0 = pByte.4
    Result.1 = pByte.4
    Result.2 = pByte.5
    Result.3 = pByte.5
    Result.4 = pByte.6
    Result.5 = pByte.6
    Result.6 = pByte.7
    Result.7 = pByte.7
  Else
    Result.0 = pByte.0
    Result.1 = pByte.0
    Result.2 = pByte.1
    Result.3 = pByte.1
    Result.4 = pByte.2
    Result.5 = pByte.2
    Result.6 = pByte.3
    Result.7 = pByte.3
  End If
End Sub


'==================================================================================================
Sub Procedure Lcd_Char_16x32(Dim px, py, pchar As Byte)
'==================================================================================================
  Dim lIndex As Word
      lByte As Byte
  '----------------------------------------------------------------------------
  lIndex = pChar - 0x20
  lIndex = (lIndex << 4)

  Lcd_SetPos(px, py)
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+7]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+7]))

  Lcd_SetPos(px, py+1)
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+7]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+7]))

  Lcd_SetPos(px, py+2)
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+15]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+15]))

  Lcd_SetPos(px, py+3)
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+15]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+15]))
End Sub

'==================================================================================================
Sub Procedure Lcd_String_16x32(Dim px, py As Byte, Dim ByRef pDisp As String)
'==================================================================================================
  Dim lLen, lCnt As Byte
  '----------------------------------------------------------------------------
  lLen = Length(pDisp)
  For lCnt = 0 To (lLen-1)
    Lcd_Char_16x32(px+1, py, pDisp[lCnt])
    px = px + 16
  Next lCnt
End Sub

Er zit hier ergens nog een (piep)klein hiaatje in:

Je moet nl de te tonen string (Temperature), in dit geval 8 Characters lang, eerst "vullen" met

pic basic code:


Temperature   = "        "

(8 spaties)

pic basic code:


Temperature =  "  ,    "
Humidity    =  "  ,    "
Temperature[0]  = T_Byte1/10  + 48
Temperature[1]  = T_Byte1 Mod 10  + 48
Temperature[3]  = T_Byte2/10  + 48
Lcd_String_16x32(0,0, Temperature)

Doe je dat niet, dan toont het display allerlei rommel. (Je ziet wel even in een flits de juiste waarde).

Bij het vullen met spaties werkt het, maar het display 'knippert' even even bij een nieuwe waarde.

Maar alá..

Fouten zijn het bewijs dat je het probeert..
Arco

Special Member

Er zal dan wel iets misgaan na het uitvoeren van Lcd_String_16x32 (omdat de waarde wel te zien is)

Arco - "Simplicity is a prerequisite for reliability" - hard-, firm-, en software ontwikkeling: www.arcovox.com
Bavelt

Golden Member

Het leuke van de routine is dat je twee lettertypes door elkaar kan gebruiken;
zoals de symbolen:

Ondertussen heb ik een SHT21 besteld. Is nauwkeuriger én kan negatieve waarden aan.

De Decimale waarde zoals getoond op het scherm is eigenlijk fake; de DHT11 kan volgens mij geen fracties van graden aan.
(altijd 0)

[Bericht gewijzigd door Bavelt op woensdag 2 juni 2021 13:53:01 (49%)

Fouten zijn het bewijs dat je het probeert..
Arco

Special Member

Karakters gewoon 'uitrekken' tot 16x32 was 't simpelst: anders had je een enorme tabel extra gekregen van 3+kbyte...

Arco - "Simplicity is a prerequisite for reliability" - hard-, firm-, en software ontwikkeling: www.arcovox.com
Bavelt

Golden Member

Wel, nemen én geven, nietwaar? ;)

Daarom hierbij het werkende programma met:

PIC16F1936
Sensor DHT11
OLED display SPI 0,96"
Mikro Basic

pic basic code:


'====================================================================================================
 Program Test1936
'====================================================================================================
' Project name: Test1936
' MCU:          PIC16F1936
' Oscillator:   Internal 8 MHz
' Display: Oled SPI 0,96"
' SDO:          PORT C.5                 Pin 16
' SCK:          PORT C.3                 Pin 14
' D/C:          LAT C.0                  Pin 11
' RES:          LAT C.1                  Pin 12
' DHT11-Sensor  PORTB.0                  Pin 21
'====================================================================================================

const Dos8x16 As Byte [1520]=   (
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  '
  0x00,0x00,0x00,0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,  ' !
  0x00,0xF3,0xF3,0x00,0x00,0xF3,0xF3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  ' "
  0x30,0xF3,0xF3,0x30,0x30,0xF3,0xF3,0x30,0x03,0x0F,0x0F,0x03,0x03,0x0F,0x0F,0x03,  ' #
  0x00,0x78,0xF3,0xCF,0xCF,0xCC,0x8C,0x00,0x00,0x0C,0x0C,0x3C,0x3C,0x0F,0x07,0x00,  ' $
  0x00,0x1C,0x1C,0xC0,0xF0,0x3C,0x0C,0x00,0x00,0x0C,0x0F,0x03,0x00,0x0E,0x0E,0x00,  ' %
  0x00,0xD8,0xFC,0xCC,0x7C,0x18,0x00,0x00,0x1F,0x3F,0x31,0x33,0x1F,0x3F,0x33,0x00,  ' &
  0x00,0x00,0x00,0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  ' '
  0x00,0x00,0x00,0xF0,0xF8,0x1C,0x04,0x00,0x00,0x00,0x00,0x0F,0x1F,0x38,0x20,0x00,  ' (
  0x00,0x04,0x1C,0xF8,0xF0,0x00,0x00,0x00,0x00,0x20,0x38,0x1F,0x0F,0x00,0x00,0x00,  ' )
  0xC0,0xCC,0xFC,0xF0,0xF0,0xFC,0xCC,0xC0,0x00,0x0C,0x0F,0x03,0x03,0x0F,0x0C,0x00,  ' *
  0x00,0xC0,0xC0,0xF8,0xF8,0xC0,0xC0,0x00,0x00,0x00,0x00,0x07,0x07,0x00,0x00,0x00,  ' +
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x7C,0x3C,0x00,0x00,0x00,  ' ,
  0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  ' -
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x3C,0x00,0x00,0x00,  ' .
  0x00,0x00,0x00,0x80,0xE0,0x7C,0x1C,0x00,0x00,0x38,0x3E,0x07,0x01,0x00,0x00,0x00,  ' /
  0x00,0xF8,0xFC,0x0C,0x8C,0xFC,0xF8,0x00,0x00,0x1F,0x3F,0x31,0x30,0x3F,0x1F,0x00,  ' 0
  0x00,0x00,0x30,0xFC,0xFC,0x00,0x00,0x00,0x00,0x30,0x30,0x3F,0x3F,0x30,0x30,0x00,  ' 1
  0x00,0x38,0x3C,0x0C,0xCC,0xFC,0x38,0x00,0x00,0x30,0x3C,0x3F,0x33,0x30,0x30,0x00,  ' 2
  0x00,0x0C,0x0C,0xCC,0xFC,0x3C,0x0C,0x00,0x00,0x1C,0x3C,0x30,0x33,0x3F,0x1C,0x00,  ' 3
  0x00,0x00,0xC0,0xF0,0xFC,0xFC,0x00,0x00,0x00,0x0F,0x0F,0x0C,0x3F,0x3F,0x0C,0x00,  ' 4
  0x00,0xFC,0xFC,0xCC,0xCC,0xCC,0x8C,0x00,0x00,0x18,0x38,0x30,0x30,0x3F,0x1F,0x00,  ' 5
  0x00,0xF0,0xF8,0x9C,0x8C,0x8C,0x00,0x00,0x00,0x1F,0x3F,0x31,0x31,0x3F,0x1F,0x00,  ' 6
  0x00,0x0C,0x0C,0x0C,0xCC,0xFC,0x3C,0x00,0x00,0x00,0x3C,0x3F,0x03,0x00,0x00,0x00,  ' 7
  0x00,0x38,0xFC,0xCC,0xCC,0xFC,0x38,0x00,0x00,0x1F,0x3F,0x30,0x30,0x3F,0x1F,0x00,  ' 8
  0x00,0x78,0xFC,0xCC,0xCC,0xFC,0xF8,0x00,0x00,0x00,0x30,0x30,0x38,0x1F,0x0F,0x00,  ' 9
  0x00,0x00,0x00,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x3C,0x00,0x00,0x00,  ' :
  0x00,0x00,0x00,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0xC0,0x7C,0x3C,0x00,0x00,0x00,  ' ;
  0x80,0xC0,0xE0,0x70,0x38,0x18,0x08,0x00,0x00,0x01,0x03,0x07,0x0E,0x0C,0x08,0x00,  ' <
  0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x00,  ' =
  0x08,0x18,0x38,0x70,0xE0,0xC0,0x80,0x00,0x08,0x0C,0x0E,0x07,0x03,0x01,0x00,0x00,  ' >
  0x00,0x38,0x3C,0x0C,0xCC,0xFC,0x38,0x00,0x00,0x00,0x00,0x37,0x37,0x00,0x00,0x00,  ' ?
  0xF0,0xF8,0x1C,0xCC,0x4C,0x98,0xF0,0x00,0x0F,0x1F,0x38,0x33,0x32,0x33,0x19,0x00,  ' @
  0x00,0xF0,0xF8,0x1C,0x1C,0xF8,0xF0,0x00,0x00,0x3F,0x3F,0x03,0x03,0x3F,0x3F,0x00,  ' A
  0x00,0xFC,0xFC,0xCC,0xCC,0xFC,0x78,0x00,0x00,0x3F,0x3F,0x30,0x30,0x3F,0x1F,0x00,  ' B
  0x00,0xF8,0xFC,0x0C,0x0C,0x3C,0x38,0x00,0x00,0x1F,0x3F,0x30,0x30,0x3C,0x1C,0x00,  ' C
  0x00,0xFC,0xFC,0x0C,0x1C,0xF8,0xF0,0x00,0x00,0x3F,0x3F,0x30,0x38,0x1F,0x0F,0x00,  ' D
  0x00,0xFC,0xFC,0xCC,0xCC,0xCC,0x0C,0x00,0x00,0x3F,0x3F,0x30,0x30,0x30,0x30,0x00,  ' E
  0x00,0xFC,0xFC,0xCC,0xCC,0xCC,0x0C,0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,0x00,0x00,  ' F
  0x00,0xF8,0xFC,0x0C,0xCC,0xCC,0xCC,0x00,0x00,0x1F,0x3F,0x30,0x30,0x3F,0x1F,0x00,  ' G
  0x00,0xFC,0xFC,0xC0,0xC0,0xFC,0xFC,0x00,0x00,0x3F,0x3F,0x00,0x00,0x3F,0x3F,0x00,  ' H
  0x00,0x0C,0x0C,0xFC,0xFC,0x0C,0x00,0x00,0x00,0x30,0x30,0x3F,0x3F,0x30,0x00,0x00,  ' I
  0x00,0x00,0x00,0x00,0x00,0xFC,0xFC,0x00,0x00,0x1C,0x3C,0x30,0x30,0x3F,0x1F,0x00,  ' J
  0xFC,0xFC,0xC0,0xF0,0x3C,0x0C,0x00,0x00,0x3F,0x3F,0x00,0x03,0x0F,0x3C,0x30,0x00,  ' K
  0x00,0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0x30,0x30,0x30,0x30,0x00,  ' L
  0xFC,0xFC,0x70,0xC0,0x70,0xFC,0xFC,0x00,0x3F,0x3F,0x00,0x01,0x00,0x3F,0x3F,0x00,  ' M
  0x00,0xFC,0xFC,0xE0,0x80,0xFC,0xFC,0x00,0x00,0x3F,0x3F,0x01,0x07,0x3F,0x3F,0x00,  ' N
  0x00,0xF8,0xFC,0x0C,0x0C,0xFC,0xF8,0x00,0x00,0x1F,0x3F,0x30,0x30,0x3F,0x1F,0x00,  ' O
  0x00,0xFC,0xFC,0x0C,0x0C,0xFC,0xF8,0x00,0x00,0x3F,0x3F,0x03,0x03,0x03,0x01,0x00,  ' P
  0x00,0xF8,0xFC,0x0C,0x0C,0xFC,0xF8,0x00,0x00,0x1F,0x3F,0x38,0x1E,0x3F,0x37,0x00,  ' Q
  0xFC,0xFC,0x8C,0x8C,0xFC,0xF8,0x00,0x00,0x3F,0x3F,0x01,0x03,0x0F,0x3C,0x30,0x00,  ' R
  0x00,0x78,0xFC,0xCC,0x8C,0x8C,0x18,0x00,0x00,0x18,0x31,0x31,0x33,0x3F,0x1E,0x00,  ' S
  0x00,0x0C,0x0C,0xFC,0xFC,0x0C,0x0C,0x00,0x00,0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,  ' T
  0x00,0xFC,0xFC,0x00,0x00,0xFC,0xFC,0x00,0x00,0x1F,0x3F,0x30,0x30,0x3F,0x1F,0x00,  ' U
  0x00,0xFC,0xFC,0x00,0x00,0xFC,0xFC,0x00,0x00,0x03,0x0F,0x3C,0x3C,0x0F,0x03,0x00,  ' V
  0xFC,0xFC,0x00,0x80,0x00,0xFC,0xFC,0x00,0x3F,0x1F,0x0E,0x07,0x0E,0x1F,0x3F,0x00,  ' W
  0x00,0x1C,0x7C,0xE0,0xE0,0x7C,0x1C,0x00,0x00,0x38,0x3E,0x07,0x07,0x3E,0x38,0x00,  ' X
  0x00,0x3C,0xFC,0xC0,0xC0,0xFC,0x3C,0x00,0x00,0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,  ' Y
  0x00,0x0C,0x0C,0xCC,0xFC,0x3C,0x0C,0x00,0x00,0x3C,0x3F,0x33,0x30,0x30,0x30,0x00,  ' Z
  0x00,0x00,0x00,0xFC,0xFC,0x0C,0x0C,0x00,0x00,0x00,0x00,0x3F,0x3F,0x30,0x30,0x00,  ' [
  0x00,0x0C,0x0C,0xFC,0xFC,0x00,0x00,0x00,0x00,0x30,0x30,0x3F,0x3F,0x00,0x00,0x00,  ' \
  0x80,0xE0,0x78,0x1E,0x78,0xE0,0xE0,0x00,0x01,0x01,0x00,0x00,0x00,0x01,0x01,0x00,  ' ]
  0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  ' ^
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00,  ' _
  0x00,0x07,0x0E,0x1C,0x38,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  ' `
  0x00,0x00,0x60,0x60,0x60,0xE0,0xC0,0x00,0x00,0x1E,0x3F,0x33,0x33,0x3F,0x3F,0x00,  ' a
  0x00,0xFC,0xFC,0x60,0x60,0xE0,0xC0,0x00,0x00,0x3F,0x3F,0x30,0x30,0x3F,0x1F,0x00,  ' b
  0x00,0xC0,0xE0,0x60,0x60,0x60,0x00,0x00,0x00,0x1F,0x3F,0x30,0x30,0x30,0x30,0x00,  ' c
  0x00,0xC0,0xE0,0x60,0x60,0xFC,0xFC,0x00,0x00,0x1F,0x3F,0x30,0x30,0x3F,0x3F,0x00,  ' d
  0x00,0xC0,0xE0,0x60,0x60,0xE0,0xC0,0x00,0x00,0x1F,0x3F,0x32,0x32,0x33,0x33,0x00,  ' e
  0x00,0xC0,0xC0,0xF8,0xFC,0xCC,0xCC,0x00,0x00,0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,  ' f
  0x00,0xC0,0xE0,0x60,0x60,0xE0,0xE0,0x00,0x00,0xCF,0xDF,0xD8,0xD8,0xFF,0x7F,0x00,  ' g
  0x00,0xFC,0xFC,0x60,0x60,0xE0,0xC0,0x00,0x00,0x3F,0x3F,0x00,0x00,0x3F,0x3F,0x00,  ' h
  0x00,0x00,0x60,0xEC,0xEC,0x00,0x00,0x00,0x00,0x00,0x30,0x3F,0x3F,0x30,0x00,0x00,  ' i
  0x00,0x00,0x00,0x00,0xEC,0xEC,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xFF,0x7F,0x00,0x00,  ' j
  0xFC,0xFC,0x80,0xC0,0xE0,0x60,0x00,0x00,0x3F,0x3F,0x03,0x07,0x1E,0x38,0x30,0x00,  ' k
  0x00,0x00,0x0C,0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0x30,0x3F,0x3F,0x30,0x00,0x00,  ' l
  0xC0,0xE0,0xE0,0xC0,0xE0,0xE0,0xC0,0x00,0x3F,0x3F,0x00,0x07,0x00,0x3F,0x3F,0x00,  ' m
  0x00,0xC0,0xE0,0x60,0x60,0xE0,0xC0,0x00,0x00,0x3F,0x3F,0x00,0x00,0x3F,0x3F,0x00,  ' n
  0x00,0xC0,0xE0,0x60,0x60,0xE0,0xC0,0x00,0x00,0x1F,0x3F,0x30,0x30,0x3F,0x1F,0x00,  ' o
  0x00,0xE0,0xE0,0x60,0x60,0xE0,0xC0,0x00,0x00,0xFF,0xFF,0x30,0x30,0x3F,0x1F,0x00,  ' p
  0x00,0xC0,0xE0,0x60,0x60,0xE0,0xE0,0x00,0x00,0x1F,0x3F,0x30,0x30,0xFF,0xFF,0x00,  ' q
  0x00,0xE0,0xE0,0x60,0x60,0xE0,0xC0,0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,0x00,0x00,  ' r
  0x00,0xC0,0xE0,0x60,0x60,0x60,0x60,0x00,0x00,0x31,0x33,0x33,0x36,0x3E,0x3C,0x00,  ' s
  0x00,0x60,0x60,0xF8,0xF8,0x60,0x60,0x00,0x00,0x00,0x00,0x1F,0x3F,0x30,0x30,0x00,  ' t
  0x00,0xE0,0xE0,0x00,0x00,0xE0,0xE0,0x00,0x00,0x1F,0x3F,0x30,0x30,0x3F,0x3F,0x00,  ' u
  0x00,0xE0,0xE0,0x00,0x00,0xE0,0xE0,0x00,0x00,0x03,0x0F,0x3C,0x3C,0x0F,0x03,0x00,  ' v
  0xE0,0xE0,0x00,0x80,0x00,0xE0,0xE0,0x00,0x3F,0x1F,0x0E,0x07,0x0E,0x1F,0x3F,0x00,  ' w
  0x00,0x60,0xE0,0x80,0x80,0xE0,0x60,0x00,0x00,0x30,0x3D,0x0F,0x0F,0x3D,0x30,0x00,  ' x
  0x00,0xE0,0xE0,0x00,0x00,0xE0,0xE0,0x00,0x00,0xCF,0xDF,0xD8,0xD8,0xFF,0x7F,0x00,  ' y
 '0x00,0x60,0x60,0x60,0xE0,0xE0,0x60,0x00,0x00,0x30,0x3C,0x3F,0x33,0x30,0x30,0x00,  ' z
  0x80,0x80,0xC0,0xFC,0x7E,0x02,0x02,0x00,0x01,0x01,0x03,0x3F,0x7E,0x40,0x40,0x00,  ' {
  0x00,0x00,0x00,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x00,0x00,0x00,  ' |
  0x02,0x02,0x7E,0x7C,0xC0,0x80,0x80,0x00,0x40,0x40,0x7E,0x3F,0x03,0x01,0x01,0x00,  ' }
  0xC0,0x60,0xE0,0xC0,0x80,0x80,0xE0,0x00,0x01,0x00,0x00,0x01,0x01,0x01,0x00,0x00)  ' ~
  
     Correction As Byte = 2                       'Temperature Correction on result

Dim D_C         As sBit at LATC.0                 'Data/Command    Pin 11
    ClockPin    As sbit at PORTC.3                'Clock           Pin 14
    Datapin     As sbit at PORTC.5                'SDO             Pin 16
    RES         As sbit at LATC.1                 'RESET           Pin 12
    DHT11_PIN   As sbit at PORTB.0                'DHT11 Sensor    Pin 21
    DHT11_PIN_Direction as sbit at TRISB0_bit

    T_byte1     As Byte
    T_byte2     As Byte
    RH_byte1    As Byte
    RH_byte2    As Byte
    CheckSum    As Byte
    
    Temperature As String[8]
    Humidity    As String[8]

'====================================================================================================
Sub Procedure Lcd_WrCmd(Dim pCmd As Byte)         'Write Command to display
'====================================================================================================
  D_C = 0
  Spi1_Write(pCmd)
End Sub

'====================================================================================================
Sub Procedure Lcd_WrDat(Dim pDat As Byte)         'Write Data to display
'====================================================================================================
  Dim lCnt As Byte
  D_C = 1
  Spi1_Write(pDat)
End Sub

'====================================================================================================
Sub Procedure Lcd_SetPos(Dim px, py as Byte)      'Set write position on display
'====================================================================================================
  Delay_us(1)
  Lcd_WrCmd(0xB0 + py)
  Lcd_WrCmd((px  >> 4) Or 0x10)
  Lcd_WrCmd((px And 0x0F))
  delay_us(1)
End Sub

'====================================================================================================
Sub Procedure Lcd_Fill(Dim pFill As Byte)         'Fill display with character pFill
'====================================================================================================
  Dim lx, ly As Byte
  For ly = 0 To 7
    Lcd_WrCmd(0xB0+ly)
    Lcd_WrCmd(0x00)
    Lcd_WrCmd(0x10)
    For lx = 0 to 127
      Lcd_WrDat(pFill)
    Next lx
  Next ly
End Sub

'=========================================================================================
Sub Procedure Lcd_Char_8x16(Dim px, py, pchar As Byte)
'=========================================================================================
  Dim lIndex As Word
  '----------------------------------------------------------------------------
  lIndex = pChar - 0x20
  lIndex = (lIndex << 4)

  Lcd_SetPos(px, py)
  Lcd_WrDat(Dos8x16[lIndex+0])
  Lcd_WrDat(Dos8x16[lIndex+1])
  Lcd_WrDat(Dos8x16[lIndex+2])
  Lcd_WrDat(Dos8x16[lIndex+3])
  Lcd_WrDat(Dos8x16[lIndex+4])
  Lcd_WrDat(Dos8x16[lIndex+5])
  Lcd_WrDat(Dos8x16[lIndex+6])
  Lcd_WrDat(Dos8x16[lIndex+7])

  Lcd_SetPos(px, py+1)
  Lcd_WrDat(Dos8x16[lIndex+8])
  Lcd_WrDat(Dos8x16[lIndex+9])
  Lcd_WrDat(Dos8x16[lIndex+10])
  Lcd_WrDat(Dos8x16[lIndex+11])
  Lcd_WrDat(Dos8x16[lIndex+12])
  Lcd_WrDat(Dos8x16[lIndex+13])
  Lcd_WrDat(Dos8x16[lIndex+14])
  Lcd_WrDat(Dos8x16[lIndex+15])
End Sub

'==================================================================================================
Sub Function Lcd_Split(Dim pOdd, pByte As Byte) As Byte
'==================================================================================================
  If pOdd Then
    Result.0 = pByte.4
    Result.1 = pByte.4
    Result.2 = pByte.5
    Result.3 = pByte.5
    Result.4 = pByte.6
    Result.5 = pByte.6
    Result.6 = pByte.7
    Result.7 = pByte.7
  Else
    Result.0 = pByte.0
    Result.1 = pByte.0
    Result.2 = pByte.1
    Result.3 = pByte.1
    Result.4 = pByte.2
    Result.5 = pByte.2
    Result.6 = pByte.3
    Result.7 = pByte.3
  End If
End Sub


'==================================================================================================
Sub Procedure Lcd_Char_16x32(Dim px, py, pchar As Byte)
'==================================================================================================
  Dim lIndex As Word
      lByte As Byte
  lIndex = pChar - 0x20
  lIndex = (lIndex << 4)

  Lcd_SetPos(px, py)
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+7]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+7]))

  Lcd_SetPos(px, py+1)
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+0]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+1]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+2]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+3]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+4]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+5]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+6]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+7]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+7]))

  Lcd_SetPos(px, py+2)
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+15]))
  Lcd_WrDat(Lcd_Split(0, Dos8x16[lIndex+15]))

  Lcd_SetPos(px, py+3)
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+8]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+9]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+10]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+11]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+12]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+13]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+14]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+15]))
  Lcd_WrDat(Lcd_Split(1, Dos8x16[lIndex+15]))
End Sub

'==================================================================================================
Sub Procedure Lcd_String_16x32(Dim px, py As Byte, Dim ByRef pDisp As String)
'==================================================================================================
  Dim lLen, lCnt As Byte
  lLen = Length(pDisp)
  For lCnt = 0 To (lLen-1)
    Lcd_Char_16x32(px+1, py, pDisp[lCnt])
    px = px + 16
  Next lCnt
End Sub

'=========================================================================================
Sub Procedure Lcd_String_8x16(Dim px, py As Byte, Dim ByRef pDisp As String)
'=========================================================================================
  Dim lLen, lCnt As Byte
  lLen = Length(pDisp)
  For lCnt = 0 To (lLen-1)
    Lcd_Char_8x16(px+1, py, pDisp[lCnt])
    px = px + 8
  Next lCnt
End Sub

'====================================================================================================
Sub Procedure Display_Init()
'====================================================================================================
  Lcd_WrCmd(0xAF)                                 'Turn OLED panel off
  Lcd_WrCmd(0xA8)                                 'Multiplex ratio set to
  Lcd_WrCmd(0x3F)                                 '63
  Lcd_WrCmd(0xD3)                                 'Display offset RAM counter
  Lcd_WrCmd(0x00)                                 'none
  Lcd_WrCmd(0x40)                                 'Start line address
  Lcd_WrCmd(0xA1)                                 'Set segment remap rotation to left
  Lcd_WrCmd(0xC8)                                 'Common output scan direction
  Lcd_WrCmd(0xDA)                                 'Common signals pad
  Lcd_WrCmd(0x12)                                 'value
  Lcd_WrCmd(0x81)                                 'Contrast control
  Lcd_WrCmd(0xFF)                                 'value
  Lcd_WrCmd(0xA4)
  Lcd_WrCmd(0xA6)                                 'Normal display
  Lcd_WrCmd(0xD5)                                 'Clock ratio:oscillator frequency
  Lcd_WrCmd(0x80)                                 'oooo:rrrr
  Lcd_WrCmd(0x8D)
  Lcd_WrCmd(0x14)
  Lcd_WrCmd(0x00)                                 'Set lower column address
  Lcd_WrCmd(0x10)                                 'Set higher column address
  Lcd_WrCmd(0xD9)                                 '15 clocks, discharge 1 clock
  Lcd_WrCmd(0xF1)                                 'dddd:pppp
  Lcd_WrCmd(0xDB)                                 'Common output voltage
  Lcd_WrCmd(0x40)                                 'level
  Lcd_WrCmd(0x20)                                 'Addressing mode
  Lcd_WrCmd(0x02)                                 'value
  Lcd_WrCmd(0xAE)                                 'Turn OLED panel off
End Sub

'====================================================================================================
 Sub Procedure Blink (Dim Dnum as Integer)        'Test purpose - Led Blink
'====================================================================================================
 Dim k1 As byte
 For k1 = 1 to Dnum
    LATB.4 = 1
    Delay_Ms(500)
     LATB.4 = 0
    Delay_Ms(500)
 Next k1
 End Sub

'====================================================================================================
Sub Procedure Start_Signal()
'====================================================================================================
 DHT11_PIN_Direction = 0                          'Configure connection pin as output
 DHT11_PIN = 0                                    'Connection pin output low
 Delay_ms(25)                                     'Wait 25 ms
 DHT11_PIN = 1                                    'Connection pin output high
 Delay_us(25)                                     'Wait 25 us
 DHT11_PIN_Direction = 1                          'Configure connection pin as input
End Sub

'====================================================================================================
Sub Function Check_Response() as Byte
'====================================================================================================
 TMR1H = 0                                        'Reset Timer1
 TMR1L = 0
 TMR1ON_bit = 1                                   'Enable Timer1 module
 While((Not DHT11_PIN) And (TMR1L < 100)) Wend    'Wait until DHT11_PIN becomes high (cheking of 80µs low time response)
 If(TMR1L > 99) Then                              'If response time > 99µS  ==> Response error
   Result = 0                                     'Return 0 (Device has a problem with response)
 Else
   TMR1H = 0                                      'Reset Timer1
   TMR1L = 0
   While(DHT11_PIN And (TMR1L < 100)) Wend        'Wait until DHT11_PIN becomes low (cheking of 80µs high time response)
   If(TMR1L > 99) Then                            'If response time > 99µS  ==> Response error
     Result = 0                                   'Return 0 (Device has a problem with response)
   Else
     Result = 1                                   'Response OK
   End If
 End If
End Sub

'====================================================================================================
Sub Function Read_Data(Dim Byref Dht_Data as byte) As Byte
'====================================================================================================
 Dim i1 As byte
 Dht_data = 0

 For i1 = 0 to 7
   TMR1H = 0                                      'Reset Timer1
   TMR1L = 0
   While(NOT DHT11_PIN)                           'Wait until DHT11_PIN becomes high
     If(TMR1L > 100) Then                         'If low time > 100  ==>  Time out error
       Result = 1                                 'Normally takes 50µs
       Exit
     End If
   Wend
   TMR1H = 0                                      'Reset Timer1
   TMR1L = 0

 While(DHT11_PIN)                                 'Wait until DHT11_PIN becomes low
   If(TMR1L > 100) Then                           'If high time > 100  ==>  Time out error (Normally it takes 26-28µs for 0 and 70µs for 1)
     Result = 1                                   'Return 1 (timeout error)
     Exit
   End If
 Wend
   If(TMR1L > 50) Then                            'If high time > 50  ==>  Sensor sent 1
      Dht_data = Dht_data Or (1<<(7-i1))
   End If
Next i1

Result = 0                                        'Data read OK
End Sub

'====================================================================================================
Main:                                             'Main program
'====================================================================================================
  TRISB =   %00000001                             'PORTB.0 Input (DHT11 Sensor)
  TRISC =   %00101000                             'PORT C.3 and C.5 Input (SPI)
  OSCCON =  %01110000                             '8Mhz internal

  ANSELB = 0                                      'Configure all PORTB pins as digital
  T1CON = %00010000                               'Set Timer1 clock source to internal with 1:2 prescaler (Timer1 clock = 1MHz)
  TMR1H = 0                                       'Reset Timer1
  TMR1L = 0

  RES = 0                                         'Reset and Init Display
  Delay_ms(10)
  RES = 1

  SPI1_Init()
  Delay_ms(100)
  Display_Init()
  Delay_ms(100)

  Lcd_WrCmd(0xAF)                                 'Turn OLED panel on
  LCD_Setpos(0,0)                                 'Set start Position
  LCD_Fill(0x00)                                  'Blank Screen
  
  Temperature =  "  ,    "
  Humidity    =  "  ,    "
  
  Lcd_String_8x16(0,1,"Temp:")
  Lcd_String_8x16(0,5,"Humi:")
  
  Lcd_String_8x16(112,0,"C")
  Lcd_String_8x16(112,5,"%")

  While True
  Start_Signal()                                  'Send start signal to the sensor

  If(Check_Response()) Then                       'Check response from sensor (If OK start reding Humidity and Temperature data)
    If(Read_Data(RH_byte1) Or Read_Data(RH_byte2) Or   'Read data from the DHT11 sensor
       Read_Data(T_byte1)  Or  Read_Data(T_byte2) Or   'and check time out errors
       Read_Data(Checksum)) Then
       Lcd_String_8x16(0,0,"Time Out!           ")
    Else
      If(CheckSum = ((RH_Byte1 + RH_Byte2 + T_Byte1 + T_Byte2) And 0xFF)) Then
        T_Byte1= (T_Byte1 - Correction)           'Correction for measure
       
        Temperature[0]  = T_Byte1/10  + 48
        Temperature[1]  = T_Byte1 Mod 10  + 48
        Temperature[3]  = T_Byte2/10  + 48
        Rtrim(Temperature)
        Lcd_String_16x32(45,0, Temperature)
       
        Humidity[0]     = RH_Byte1/10 + 48
        Humidity[1]     = RH_Byte1 Mod 10 + 48
        Humidity[3]     = RH_Byte2/10 + 48
        Rtrim(Humidity)
        Lcd_String_16x32(45,4, Humidity)

      End If
    End If
 End If

 TMR1ON_bit = 0                                   'Disable Timer1 module
 Delay_ms(2000)                                   'Wait 2 seconds
 Wend
End.
Fouten zijn het bewijs dat je het probeert..

Zo'n tafel heb ik ook eens gehad, maar was toch onpraktisch, zo hoog. :) ;)

Even wat foto's gemaakt, de druk is in Pascal ten opzichten van de situatie met de sensor houder (35 cm) horizontaal:

Ongeveer 10 Pa over 70 cm hoogteverschil klopt wel met de elders genoemde 1 hPa over 8m.
Het is niet super stabiel, maar werkt wel degelijk. Probeer het zelf :)
Dit soort sensoren wordt o.a. gebruikt om drones binnen op hoogte te houden.

Het font is text size 2 van de Adafruit gfx library.

[Bericht gewijzigd door Aart op donderdag 3 juni 2021 09:54:16 (13%)

Precies. En vandaag op hackaday: voor een paraglider-vario.

Ik ben ongeveer 20 jaar geleden met dat project begonnen. MPX5100. Analoog uit: geen temp compensatie enz. Super tricky om een verandering van zeg 0.2m/s te detecteren.

Later nog een keer geprobeerd met een digitale sensor. Temperatuurmetng met 16 bits ADC betekent dat je een hand op 30cm gewoon oppikt door de warmtestraling.... Maar goed. Weer tricky om genoeg te filteren om bruikbaar te zijn.

En nu heeft een oost-europeaan een ding gemaakt was precies reageert als de comerciele exemplaren (eur 300), met totaal 65 regels arduino code!

four NANDS do make a NOR . Kijk ook eens in onze shop: http://www.bitwizard.nl/shop/
Bavelt

Golden Member

Op 31 mei 2021 21:38:37 schreef Arco:
Ik ga de SHT21 gebruiken, maar die is wel duurder...

Ik heb er nu eentje.

Niet toevallig een voorbeeldje van een SHT21 met MikroBasic? :)

[Bericht gewijzigd door Bavelt op zondag 13 juni 2021 13:46:21 (19%)

Fouten zijn het bewijs dat je het probeert..
Arco

Special Member

Nog niet,

Druk met werk, nog niet aan toegekomen...

Arco - "Simplicity is a prerequisite for reliability" - hard-, firm-, en software ontwikkeling: www.arcovox.com

Op 13 juni 2021 00:42:13 schreef Bavelt:
Niet toevallig een voorbeeldje van een SHT21 met MikroBasic? :)

Die is toch precies hetzelfde als de DHT11 maar dan met een paar bitjes ingevuld die op de DHT11 "reserved" zijn?

four NANDS do make a NOR . Kijk ook eens in onze shop: http://www.bitwizard.nl/shop/
Bavelt

Golden Member

Op 13 juni 2021 08:01:01 schreef rew:
[...]Die is toch precies hetzelfde als de DHT11 maar dan met een paar bitjes ingevuld die op de DHT11 "reserved" zijn?

Hmm, is dat zo?
Dat ding lijkt me toch heel anders. Het begint er al mee dat de SHT21 een I2C protocol heeft, waar de DHT11 een eigen 'one wire' protocol kent.

Fouten zijn het bewijs dat je het probeert..
Bavelt

Golden Member

Ik zag op Libstock een aantal files met voorbeelden.
Maar die bestanden zijn in het formaat .mpkg.

Die zijn bedoeld voor de PackAge manager van MikroE.

(Waarom gebruiken die jongens nu niet gewoon Winzip ipv zo'n rare tool.. ;()

Maar installeren van de 'Package manager' resulteert in "Mikro Basic Pro for PIC is not installed on this computer".
Terwijl dat wel zo is...

En hij wil de downloads dus niet uitpakken.

Heb al van alles geprobeerd (installeren als administrator, etc).

Hoe krijg ik die files nu uitgepakt..?

Fouten zijn het bewijs dat je het probeert..
PE9SMS

Special Member

Op 13 juni 2021 08:01:01 schreef rew:
[...]Die is toch precies hetzelfde als de DHT11 maar dan met een paar bitjes ingevuld die op de DHT11 "reserved" zijn?

Dat zal wel de DHT22 zijn die je voor ogen hebt? De SHT21 is een sensor van Sensirion.

This signature is intentionally left blank.
Bavelt

Golden Member

Op 14 juni 2021 00:03:46 schreef PE9SMS:
[...]Dat zal wel de DHT22 zijn die je voor ogen hebt? De SHT21 is een sensor van Sensirion.

Nee, de SHT21. Temnperatuur En vochtigheidssensor.

Zit op een klein printje (GY-21)

Fouten zijn het bewijs dat je het probeert..
PE9SMS

Special Member

This signature is intentionally left blank.
Bavelt

Golden Member

Fouten zijn het bewijs dat je het probeert..