Can anyone provide me a sample MicroPython code to read temperature in Celsius/Fahrenheit from the TMP102 through micro:bit I2C? The datasheet for I2C can be found at http://www.sparkfun.com/datasheets/Sens ... tmp102.pdf.
Thanks in advance.
Pradeeka
Reading TMP102 over I2C bus
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Reading TMP102 over I2C bus
A quick search of this forum revealed this https://github.com/khoulihan/micropython-tmp102.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Reading TMP102 over I2C bus
Thanks for the reply. But I want to implement the code with methods mentioned in the http://microbit-micropython.readthedocs ... t/i2c.html.
Re: Reading TMP102 over I2C bus
What's stopping you?
Re: Reading TMP102 over I2C bus
Instead of the TMP102 sensor, I tried to read the micro:bit on board accelerator at 0x1d.
http://www.nxp.com/docs/en/data-sheet/MMA8652FC.pdf
I want to get 8-bit results for x-axis from OUT_X_MSB.
Can you verify the below code snippet?
i2c.write(0x1d, bytes([0x2a,1]), repeat=False) #To use only 8-bit results, the F_READ bit in CTRL_REG1 must
be set. When the F_READ bit is cleared, the fast read mode is disabled.
Byte = i2c.read(0x1d, 2) [1] #read from OUT_X_MSB
print(Byte * 16) #If only the 8-bit results are used, then the resolution is reduced by a factor of 16.
http://www.nxp.com/docs/en/data-sheet/MMA8652FC.pdf
I want to get 8-bit results for x-axis from OUT_X_MSB.
Can you verify the below code snippet?
i2c.write(0x1d, bytes([0x2a,1]), repeat=False) #To use only 8-bit results, the F_READ bit in CTRL_REG1 must
be set. When the F_READ bit is cleared, the fast read mode is disabled.
Byte = i2c.read(0x1d, 2) [1] #read from OUT_X_MSB
print(Byte * 16) #If only the 8-bit results are used, then the resolution is reduced by a factor of 16.