Notifications
Clear all

making an Xiao into a remote sensor on I2C

2 Posts
1 Users
0 Likes
604 Views
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
Topic starter  

This is all part of getting smarter with Arduino compatible programming and I2C communication.

I've been noticing that some I2C sensors not only have a device address, but also register addresses. To better understand this I used a Raspberry PI and the PIGPIO libraries to send data on the I2C bus to a device and to specific registers.

On the Xiao, I just wait for the data, byte at a time and print that byte in hex on the SerialUSB console.

What I see is the first byte is the register number, the second byte is the number of the bytes to follow, and then the bytes them self.

My goal of this experiment is to make the Xiao a I2C sensor slave.  it will use the registers for different functions that need performing.  i.e. turn on or off and LED. or change the data being displayed on a 4 bit LCD1602 display.

This should be a good test as it uses a lot of the I2C features.

I'm just struggling finding to separate the data sent to one register from another within the device.

any pointer to examples would be a big help.

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
Quote
Topic Tags
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
Topic starter  

From what I read when others have posted this question is that the register concept is a hardware function the sensors developed. SMBUS libraries on things like PIGPIO can deal with it, but Arduino Wire library doesn't seem to deal with it. So I think I just need to develop code that reads all the data and responses accordingly.

 

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
ReplyQuote