Search This Blog

Wednesday, March 31, 2021

Jaycar Arduino Compass XC-4496

 I thought I might experiment with a solid state compass chip.

Jaycar conveniently has a Arduino Compatible 3 Axis Compass Magnetometer Module
https://www.jaycar.com.au/arduino-compatible-3-axis-compass-magnetometer-module/p/XC4496

So I ducked in and bought one.  $17.95

PROBLEMS
1.  Board Supplied is not board pictured.
2.  No information on whether the I2C is 3V or 5V  (Now determined as 5V)
3.  Data sheet is not a data sheet.  More of a 'glossy'

31-3-2021 1pm update. 
The supplied board does not have a genuine Honeywell chip.
The Honeywell I2C read address is $3D and write at $3C.
This chip responds at $60 & $61    ($=Hex)


This is the web page.





This is the data sheet.  The entire data sheet.






This is the back of the packet that I brought home from Jaycar.



This is the actual board supplied. 

The magnetic sensor might be a Honeywell  HMC5883L.  The Honeywell datasheet tells me it's a 3V part. Not Honeywell chip though.

https://cdn-shop.adafruit.com/datasheets/HMC5883L_3-Axis_Digital_Compass_IC.pdf

I am hopeful the the chip marked 702 is a level translator for the I2C but with no schematic and no data sheet and no idea what the 702 actually is there is a bit of a risk

YES 5V I/O.  Not Honeywell chip though.



This is a partial schematic of the supplied board.  

I powered it up and confirmed that the SDA and SCL lines are pulled up to 5V.  

This makes it easy to connect to a 5V microprocessor.




SOFTWARE

I2CScan shows this device has an address at Hex60
So obviously not a Honeywell chip which according to the data sheet is at Hex3C

When I read the registers from it, I get
00 00 00 00 00 00 00 10 10 10 10 10
Never changes => Either
a dud chip which I doubt.
I am sending the wrong command. <- Possibly because I have no data
I2C Inexperience.

' I2creceive  slave, var, b2W, b2R
'               |     |    |    |
'           Address   |    |    Number of Bytes to receive     
'                     |    Number of Bytes to Write
'                     Receive variable
    
    memfill Buffer(1) , 12 , &HFF  ' So we can see if it changes
    Buffer(1) = 00
    I2creceive &H60 , Buffer(1) , 1 , 12
    '          addr=60    00
    Print "II2creceive Error : " ; Err
    For B = 1 To 12
    Print Hex(Buffer(B));" ";
   Next
   Print


I have been having trouble reading from the compass chip.

The reason could be that my program simply does not read anything.  So I got a PCF8574 I2C port extender.  Must be the simplest I2C device in existance and has been around since the '80's

Wired it up and it works

 

 

 

 

 

 

 

 

 

 

 

if ks = "TR" then
    ' Read from PCF8574T
    ' Address is $7E
    memfill Buffer(1) , 12 , &HFF
    'Buffer(1) = 00
    I2creceive &H7E , Buffer(1) , 0 , 2
    '          addr=60    00
    Print "II2creceive Error : " ; Err
    For B = 1 To 2
    Print Hex(Buffer(B));" ";
   Next
   Print
 End If     

if ks = "TW" then
    ' Write to PCF8574T
    ' Command is
    '    TW 6A
    '        \
    '        Hex of what to write
    ' Address is $7E
    ' 76543210   76543210
    ' 10101010   10001010
    '  A   A       8  A
    Temp_str = Get_token( Command_str, 2) 
    Temp_b = HexVAL(Temp_str)
    
    
    memfill Buffer(1) , 12 , &HFF
    'Buffer(1) = 00
    Buffer(1) = Temp_b
    
    I2CSEND &H7E , Buffer(1) , 1
    Print "I2CSEND 8574 ";hex(Temp_b);"    Error : " ; Err
 End If 
      
 

 So at the moment we have both devices on the same bus.
The 8574 works.

Conclusion
1.  The Basic program can read and write I2C

 










No comments:

Post a Comment