I2C question #11908
Replies: 7 comments 6 replies
-
>>> import umachine
>>> dir(umachine.SoftI2C)
['__class__', '__name__', 'readinto', 'start', 'stop', 'write', '__bases__', '__dict__', 'init', 'readfrom', 'readfrom_into', 'readfrom_mem', 'readfrom_mem_into', 'scan', 'writeto', 'writeto_mem', 'writevto'] |
Beta Was this translation helpful? Give feedback.
-
What Dave want to tell. If you run print(dir(SoftI2C)) you get a list of methods that can be used. There is not recv. And with I2C you always have to tell the address of the device you want to communicate with. So for example: SoftI2C.readfrom(40, 3) See also the documentation: https://docs.micropython.org/en/latest/library/machine.I2C.html?highlight=softi2c#machine.SoftI2C |
Beta Was this translation helpful? Give feedback.
-
Purchased it from the inscrutable Chinese Rob, the only manufacturer I could find doing i2c depth probes (all the others are 4-20mA or RS485). Unfortunately no info on how to read it. I've lodged a ticket for some info on how to interrogate it but I'm not holding my breath. I was thinking if I could figure out what chip they've used I could dig up a data sheet on how to read it over i2C. I'm fascinated that I can push the i2c frequency up to 30kHz & still get bytes out of it over a 5m length of cable. |
Beta Was this translation helpful? Give feedback.
-
They sent me a couple of PDFs Rob, I think the one that doesn't mention temperatures or hibernation is maybe the correct one |
Beta Was this translation helpful? Give feedback.
-
That sheds a little bit of light on the protocol, even if it is inconsistent. The sequence depends in the hibernating state of the sensor.
It may be that the second method cal always be used. |
Beta Was this translation helpful? Give feedback.
-
According to the data pattern in figure 2, you have to shift the Tv value by 5 bits to the right, which is divide by 32, before conversion. Then you get 18.29 °C. |
Beta Was this translation helpful? Give feedback.
-
Yes. You could use integer divide as well or shift by 5 bit to the right. Like
I got 18.29 when starting with the raw value of 22368 of your first post. The values vary always a little bit. +/- 1 is the systematic error when taking digital values, and then there is the noise of the sensor. The question I have is, whether ~18°C is reasonable for the location of the sensor. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to work how to read data from an I2C submersible depth probe. After lots of messages about I2C being deprecated I ended up trying SoftI2C
which gives
So the device is there at address 40 but I've got the receive part wrong. Can someone suggest the correct way to receive data please?
Beta Was this translation helpful? Give feedback.
All reactions