gvalkov / micropython-esp8266-hmc5883l

Micropython driver for the HMC5883l on the ESP8266
13 stars 12 forks source link

small error #2

Open uraich opened 2 years ago

uraich commented 2 years ago

Hi, I know, this is already pretty old , but I wanted to pull your attention to a very small error: In line 30: i2c.writeto_mem(30, 0x00, pack('B', 0b111000)) should read: i2c.writeto_mem(30, 0x00, pack('B', 0b1111000)) (0x78 instead of 0x38) The program works fine nevertheless only that the average is 2 instead of 8. I have written a complete hcm5883 driver for a course on IoT and had quite a few problems with it. Looking at your code helped me a lot to find a bug I would probably not have found otherwise. Starting from a worrking program makes things so much easier. Thanks a lot.

adam-stamand commented 7 months ago

To add to that, it seems like the default pin assignment and documentation is incorrect. At least for the dev board I have (HiLetgo) and for all references I've found online,

SCL is on pin 5 and SDA is on pin4

If anyone experiences issues finding the device on the bus, ensure you've got the correct pins assigned. Thanks to the author for posting this reference code!

niallp commented 1 month ago

@uraich > Hi, I know, this is already pretty old , but I wanted to pull your attention to a very small error: In line 30: i2c.writeto_mem(30, 0x00, pack('B', 0b111000)) should read: i2c.writeto_mem(30, 0x00, pack('B', 0b1111000)) (0x78 instead of 0x38) The program works fine nevertheless only that the average is 2 instead of 8.

From my read of the datasheet and comments, the value should be 0b1110000 (0x70) not 0x78 (unless you want the output rate at 75 Hz instead of the 15 Hz default from the comment)