SparkFun Forums 

Where electronics enthusiasts find answers.

Tips and questions relating to the GPS modules from SFE
By eXtenZy
#102911
Hello everybody.

I am trying to interface a MAXIM DS1621 thermometer with the Telit GM862 GPS using the IIC interface and frankly i am stumped...

Hardware wise, i think, it's ok. I have powered the DS1621 using two AA batteries, the GM862 is powered from a separate source, grounds are connected. The reason i used separate power supplies is because i didn't want to convert the logic levels (i'm a beginner in electronics).

The software part...this one is the big one...
First off...I didn't knew what address to poll. The datasheet said that, for my setup, the address would be 90h, but when i tried to connect i only got errors. So i made a small script that polled all available addresses to see from which it would get a result. The script found the sensor at 48h (which is just a right shift away from 90h, but i guess the GM862 adds the last bit for read/write commands) and another device at C8h, don't know whats that about...
Anyway, I made a simple script that, theoretically, sets the DS1621 in continuous conversion mode and reads the temperature. The code looks like this :
Code: Select all
import SER
import GPIO
import MOD
import IIC
import MDM
import sys

class SerWriter:
    def write(self,s):
        SER.send(s+'\r')
sys.stdout = sys.stderr = SerWriter()
SER.set_speed('115200','8N1')
thermometer = IIC.new(3,4,0x48)
thermometer.init()
if thermometer.readwrite('\xac\x02',0) == -1:
    SER.send('\r\nError setting the configuration register!')
else:
    SER.send('\r\nConfiguration ok')
    #Read the configuration register
    result = thermometer.readwrite('\xac',1)
    if result == -1:
        SER.send('Configuration not received!')
    else:
        SER.send('\r\nRead value: ' + str(len(result)))
        if thermometer.readwrite('\xee',0) == -1:
            SER.send('\r\nError starting the conversion!')
        else:
            SER.send('\r\nConversion started...')
            while 1:
                temp = thermometer.readwrite('\xaa',2)
                SER.send('\r\nGot : ' +str(len(temp)) +' bytes, value is : '+ str(temp))
                MOD.sleep(5)
The problem is that i cannot get the data in any representation i can use. I tried to use hex(), but i get an error (TypeError : hex() argument can't be converted to hex), I tried int(), but I get an error (ValueError : invalid literal for int(): Ä). I can only use str(), but that doesn't give me any meaning full information (see the int() error).
I guess that the thermometer works, because if i touch the chip, after a while the readout changes, but how can i use that data?

Any ideas?
Thanks a lot!