Below is my code:
Code: Select all
from machine import I2C
import utime
i2c = I2C(0,freq=9600)
id = i2c.scan()
print(id)
utime.sleep_ms(2000)
data = i2c.readfrom(54, 4)
print(data)
Code: Select all
from machine import I2C
import utime
i2c = I2C(0,freq=9600)
id = i2c.scan()
print(id)
utime.sleep_ms(2000)
data = i2c.readfrom(54, 4)
print(data)
This error is because the device is NAKing the request. In this case because you need to tell it what you're reading. Generally devices like this you read from a specific register (i.e. you write the register address then read the result).thecomeback_king wrote: ↑Tue Aug 03, 2021 12:38 pmCan anyone help guide me in reading data from my I2C sensor? Any help is appreciated!
In the Adafruit driver:thecomeback_king wrote: ↑Wed Aug 04, 2021 12:40 pmIs the register the second argument in the read command?
Usually you'd look at the data sheet (i.e. a given chip would have a reference of all the registers and commands it supports).
Code: Select all
# Read Capactity and Temperature from Soil Sensor
ss_wetness = i2c.readfrom(54, 0x1F)
ss_temp = i2c.readfrom(54, 0x4)
ss_wetness = unpack('<I', ss_wetness)[0]
ss_temp = unpack('<I', ss_temp)[0]
I don't think this is equivalent to the seesaw code.