DS 3231 temperature reading


Results 1 to 8 of 8

Threaded View

  1. #5
    Join Date
    Oct 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: DS 3231 temperature reading

    Code:
     
     
           TempRegister CON $11        'temperature integer  REGISTER
           TempRegisterFRA CON $12   'temperature fraction REGISTER
           
           
    TempInt var byte             ' variable for temperature integer from register 11h
    TempFrac var byte           ' variable for temperature fraction for register 12h
    TempSign var bit              ' Variable to hold sign bit   
    
    
    main: 
    
    LCDOut $fe,1
    
           B0 = 0
           button Taster0, 0, 100, 10, B0, 1, meni0
    
    
               
           I2CRead SDA, SCL, RTC, SecReg, [sec,MINs,hr,day,date,mon,yr] 
    
    
            LCDOut $fe,2,     HEX2 hr, ":", HEX2 MINs, ":", HEX2 sec 
            LCDOut $fe,$c0, HEX2 date, "/", HEX2 mon, "/","20" ,HEX2 yr
            
            
            
                
           I2Cread SDA, SCL, rtc, TempRegister, [TempInt, TempFrac]
           
           TempFrac = (TempFrac >> 6)
           TempFrac = (TempFrac * 25)
           
           
           
           TempSign = TempInt.7   ' save the sign bit for later
    
    If TempSign = 1 then  TempInt = (TempInt XOR $FF) + 1
     
    
    
    
    If TempSign = 0 then
        LCDOUT $FE, $80+9,   "+", dec TempInt, ".",DEC TempFrac
    Else
        LCDOUT $FE, $80+9,   "-", dec TempInt, ".",DEC TempFrac
    Endif
             
           
        
           
           GoTo main


    The piece of main part of the code in which I read time, date and temperature.
    The example shows only the registers and variables to read temperature
    Last edited by visnja30; - 6th June 2015 at 15:45.

Similar Threads

  1. Reading temperature using multi DS18B20
    By KVLV in forum Code Examples
    Replies: 16
    Last Post: - 3rd November 2017, 20:48
  2. Max31855 Thermocouple Temperature Reading
    By Lefteris in forum Code Examples
    Replies: 5
    Last Post: - 21st January 2015, 04:20
  3. Thermistor based temperature reading short code required
    By asifiqbal in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th November 2014, 09:18
  4. Dallas 3231
    By jpeakall in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 5th May 2012, 16:10
  5. DS18S20 reading negative temperature
    By srob in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 28th December 2007, 22:21

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts