hi Nigel,
Below is a clip from my Oshonsoft Basic program for the DS3231
I had to use a bigger poly box and 3 frozen packs of milk to get the temperature down -11.75 degrees Centigrade
Temperature is the 2nd column from the Right of the text listing.
The temperature was checked against a glass thermometer and a Tenma electronic thermometer.
Attached is the data Log from the PC, also a clip showing the +C to -C transition.
Eric
Ensure that the DS3231 has the SN suffix
;prog fragment
Dim sgn As String
Dim templ As Byte
Dim temph As Byte
Dim tempr As Word
Dim binval As Word
Gosub read_ds3231
tempr.HB = temph
tempr.LB = templ
If tempr.15 = 0 Then
sgn = "+"
tempr = ShiftRight(tempr, 6)
tempr = (tempr * 100) / 4
Else
sgn = "-"
tempr = ShiftRight(tempr, 6)
tempr = 0x3ff - tempr
tempr = tempr + 1
tempr = tempr And 0xffff
tempr = (tempr * 100) / 4
Endif
binval = tempr
Gosub bin2asc ' convert to ASCII
sdstr = sdstr + sgn + Chr(val(3)) + Chr(val(2)) + "." + Chr(val(1)) + Chr(val(0)) + ","
----------------------------------------------------------------------------------------------------------------------------------
read_ds3231:
I2CStart
I2CSend 0xd0 'DS3231 slave addr wr
WaitUs 10
I2CSend 0x00 'first word addr wr
I2CStop
WaitUs 10
I2CStart
I2CRead sda, scl, 0xd1, 0, secs
I2CRead sda, scl, 0xd1, 1, mins
I2CRead sda, scl, 0xd1, 2, hrs
I2CRead sda, scl, 0xd1, 3, day
I2CRead sda, scl, 0xd1, 4, date
I2CRead sda, scl, 0xd1, 5, mnth
I2CRead sda, scl, 0xd1, 6, year
I2CRead sda, scl, 0xd1, 0x11, temph 'temperature
I2CRead sda, scl, 0xd1, 0x12, templ
I2CStop
Return
BTW:
I know the program can be optimised.