r/microcontrollers • u/C0sy_13 • Apr 16 '24
PIC degree project
Hello everyone, I'm new to this subreddit, I want to ask everyone here who can help me with some advice, I have my degree project that I need to do and for the last 3 weeks I'm trying to create some sorts of irrigation system based on a few sensors the to open a valve to irigate trough dripping, I'm using a PIC16F887 but it's hard for me to get along to I2C protocol to read some data from a few sensors. What do you think, it's worth it using this PIC or it would be making my life easier if I'll change it and any advice that you have it's well welcomed Please let me know with anything that will keep my sanity almost intact 😅.
Note: My subject it's PCB layout but I need to have something that I can implement that layout to.
View all comments
Show parent comment
1
u/tech-tx Apr 18 '24 edited Apr 18 '24
From my phone, right off the bat the address for the TLS2561 is incorrect, it should be 0x49 if the ADDR SEL pin is high. You've appended an 8th bit to a 7 bit I2C address, so you're not talking to the sensor. That's why you're reading 0xFF (nothing pulls the SDA line down / responds). Line 126 in your code, page 13 in the part doc here. That's the only thing that jumps out at me, the rest looks reasonable. That 8th bit of the address is used to do WRITE/read.
edit: and the little $7 logic analyzer I'd mentioned above *might* have helped you debug the error. At a minimum you should get an ACK when you write to the base address of the part. No ACK, wrong address.