wildlifenaturetech
03/19/2023, 5:55 AMkasperl
03/19/2023, 5:58 AMkasperl
03/19/2023, 5:59 AMimport gpio
import i2c
main:
bus := i2c.Bus
--sda=gpio.Pin 21
--scl=gpio.Pin 22
print bus.scan
kasperl
03/19/2023, 5:59 AMwildlifenaturetech
03/19/2023, 5:59 AMkasperl
03/19/2023, 5:59 AMkasperl
03/19/2023, 6:00 AMwildlifenaturetech
03/19/2023, 6:02 AMimport binary
import serial
class Ina219:
static I2C_ADDRESS ::= 0x64
static REG_CHIPID_ ::= 0x02
d := null
registers_/serial.Registers
constructor dev/serial.Device:
d = dev
registers_ = dev.registers
r := registers_.read_u8 REG_CHIPID_
print "r $r"
kasperl
03/19/2023, 7:00 AMfloitsch
03/19/2023, 10:26 AMfloitsch
03/19/2023, 10:26 AMfloitsch
03/19/2023, 10:28 AMfloitsch
03/19/2023, 10:28 AMfloitsch
03/19/2023, 10:35 AMdevice.write #[register_address]
to set the address and then device.read 2
to read the 16 bit register.wildlifenaturetech
03/19/2023, 6:30 PMI2C_ADDRESS
was wrong in my driver 😦 I saw the correct in the i2c scan but typed in wrong in the drive.
Tanks for your help and kind contact. Hope to publish the INA219 and INA3221 pkg soon.floitsch
03/19/2023, 6:31 PM