I can communicate with the main chip via spi, control the gpio and check presence of the temperature sensor via i2c into my docker via i2cdetect.
But when i run the chip_id C program, it can go over the step of i2c communication with temperature sensor. It doesn’t see it. When I use the scope, I don’t see any signal going out from the mallow board.
My successfully i2cdetect command is :
i2cdetect -r -y 4
, which print out the presence of the temperature sensor on address 0x3b.
So i have updated the loragw_i2c.h located in " sx1302/libloragw/inc/ " with this path: #define I2C_DEVICE “/dev/verdin-i2c3”
Without sucess. I tried also: #define I2C_DEVICE “/dev/i2c-4/”
or #define I2C_DEVICE “/dev/verdin-i2c3/”
I always get the same result:
root@6e7908fc39a4:/sx1302/util_chip_id# ./chip_id
fonction term
fonction_init
fonction reset
Power enable High
Sx1302 Reset High
Sx1302 Reset Low
Sx1261 Reset Low
Sx1261 Reset High
Opening SPI communication interface
Note: chip version is 0x10 (v1.0)
INFO: using legacy timestamp
ARB: dual demodulation disabled for all SF
INFO: no temperature sensor found on port 0x39
INFO: no temperature sensor found on port 0x3B
INFO: no temperature sensor found on port 0x38
ERROR: no temperature sensor found.
ERROR: failed to start the gateway
I don’t understand why i’m able to see it with i2cdetect, but why i’m not able to see the clk signal with the program. I’m running the docker with this lines after building the docker and re compiling the project with my dockerfile.
Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!
Did you like my answer?
It seems like you’re encountering an issue where your C program is unable to communicate with the I2C temperature sensor, even though i2cdetect can see the sensor. Here are a few steps and considerations to help troubleshoot and resolve the issue:
Verify I2C Device Path:
Ensure that the I2C device path you are using in your code is correct. Based on your context, it seems like you have tried multiple paths. The correct path should be /dev/i2c-3 if i2cdetect -r -y 3 works. So, you should set:
#define I2C_DEVICE "/dev/i2c-3"
Check Permissions:
Ensure that your Docker container has the necessary permissions to access the I2C device. You are already using --device-cgroup-rule flags, but you might also want to try running the container with the --privileged flag to rule out any permission issues:
docker run --rm -it --privileged -v /dev:/dev imagelora
Verify I2C Communication in Code:
Double-check the I2C communication code in your chip_id program. Ensure that the I2C initialization and communication functions are correctly implemented. You might want to add additional debug prints to verify that the I2C device is being opened and accessed correctly.
Test I2C Communication in Isolation:
Create a simple standalone C program to test I2C communication with the temperature sensor. This can help isolate whether the issue is with the I2C communication code or with the integration in the chip_id program. Here is a basic example:
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/i2c-dev.h>
#define I2C_DEVICE "/dev/i2c-3"
#define TEMP_SENSOR_ADDR 0x3B
int main() {
int file;
char filename[20];
snprintf(filename, 19, I2C_DEVICE);
file = open(filename, O_RDWR);
if (file < 0) {
perror("Failed to open the i2c bus");
return 1;
}
if (ioctl(file, I2C_SLAVE, TEMP_SENSOR_ADDR) < 0) {
perror("Failed to acquire bus access and/or talk to slave");
return 1;
}
// Add code to read/write to the sensor here
close(file);
return 0;
}
Check I2C Bus Activity:
Use an oscilloscope or logic analyzer to monitor the I2C bus activity when running your chip_id program. This can help determine if the program is attempting to communicate with the sensor and if there are any signals on the bus.
Review Dockerfile and Build Process:
Ensure that your Dockerfile and build process correctly compile and link the I2C communication code. Verify that there are no missing dependencies or incorrect configurations.
If you have tried all the above steps and still face issues, it might be helpful to share more details about the I2C communication code in your chip_id program and any additional logs or error messages you receive.
Please, also check if these links can help you solve your problem: