I2c Jetson nano

I use my old library https://github.com/blademoon/sensum-library. To reproduce the situation, you can use the file of an example of sensor health check
https://github.com/blademoon/sensum-library/blob/master/examples/sensor_read.cpp
For its correct operation, it is necessary to delete lines from 12 to 26 inclusively and from 41 to 69 in this file.

The choice of the Jetson Nano Bus with which to read data from sensor is made by changing line 11 in the file
https://github.com/blademoon/sensum-library/blob/master/lib/tsl2561.cpp

For example, if you need to read data from a sensor connected to bus 1, this line will look like this:
const char * i2c_file_path = “/dev/i2c-1”;

If it is necessary to read data from bus 0, then this line must be changed as follows:
const char * i2c_file_path = “/dev/i2c-0”;

Write, the result of the execution of which commands (output) is needed? I’m at work now, the equipment is at home, in the evening I will provide you with screenshots and what you ask. Good?

Could you use i2cget to read the data to confirm.

Sure! ))) I will do this and take screenshots of the error in the evening and send it to you.

root@jetson:/usr/src/tsl2561/sensum-library/examples# ./sensor_read
TSL2561 - Visible light (lx) 0. Infrared light 662. Total light 662.

root@jetson:/usr/src/tsl2561/sensum-library/examples# i2cget 0 0x39
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will read from device file /dev/i2c-0, chip address 0x39, current data
address, using read byte.
Continue? [Y/n] Y
0x92
root@jetson:/usr/src/tsl2561/sensum-library/examples# i2cget 0 0x39
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will read from device file /dev/i2c-0, chip address 0x39, current data
address, using read byte.
Continue? [Y/n] Y
0x93

When connected to bus 0, the sensor does not see the light, although the room is sufficiently lit. When the same sensor is connected to bus 1, everything works fine.

What’s the i2cget result from the bus 1?

I connect two sensors to board. This is result:

root@jetson:/usr/src/tsl2561/sensum-library/examples#
root@jetson:/usr/src/tsl2561/sensum-library/examples#
root@jetson:/usr/src/tsl2561/sensum-library/examples# i2cget -y 0 0x39
0x00
root@jetson:/usr/src/tsl2561/sensum-library/examples# i2cget -y 1 0x39
0x00
root@jetson:/usr/src/tsl2561/sensum-library/examples# ./sensor_read_bus0
TSL2561 - Visible light (lx) 0. Infrared light 134. Total light 134.

root@jetson:/usr/src/tsl2561/sensum-library/examples# ./sensor_read_bus1
TSL2561 - Visible light (lx) 120. Infrared light 19. Total light 139.

root@jetson:/usr/src/tsl2561/sensum-library/examples# i2cget -y 0 0x39
0x86
root@jetson:/usr/src/tsl2561/sensum-library/examples# i2cget -y 1 0x39
0x8b

[url]Oops!
[url]Oops!

Looks like the i2cget can get data from bus 0 too. It’s could be the is on “sensor_read_bus”

ShaneCCC maybe, but i didn’t undestand why… The source code in both cases is exactly the same, only one line is changed that is responsible for choosing the bus number with which the data is being read.

Yesterday I tried to debug the code on bus 0. The problem is that the data comes into the variable already with a zero value for the “visible light” parameter. For some reason I don’t understand …

ShaneCCC, in the evening, I will try to connect a couple of other sensors (BOSCH BME 280) and see what happens. For them, I also have a library. Do you need a sample program to reproduce the situation?

ShaneCCC, how can we check I2C speed and other paramets using i2c-tools or other linux software?

There is one way to establish exactly where the problem is. The Linux kernel has its own module for the TSL2561 sensor. Using this module, you can get information bypassing the code of various libraries and other software. If the Linux kernel correctly reads the sensor readings, then it turns out that the problem is in our code. If it also shows incorrect data on bus 0, then the problem is in the hardware or in the kernel of the OS.

Where can I find a tool to build a separate module for an existing kernel? Or do you need to rebuild the kernel with the module? Who can help?

Good morning andrey.kozeletsky & candanoza & vkuruturi & snarky & fbaez1001 & ShaneCCC. Perhaps I managed to localize two probable sources of the problem.

As you remember, at the moment, we know the following:

  1. Sensors work normally on I2C port 1
  2. Sensors fail when connected to the I2C 0 bus port.
  3. The code normally works on Raspberry Pi 2/3 / 3b / Zero / Zero, OrangePi (various models), Pin64, it works normally on I2C port 1. And it intermittently fails on the I2C 0 bus port.
  4. As previously written in this thread on the I2C 0 bus port, Nvidia Jetson there is an abnormal behavior with TTL logic levels (a problem with voltage levels).
  5. Additionally, there is such a publication on the forum - the problem of controlling the LED directly. You can read more here: Jetson Nano GPIO example problem - Jetson Nano - NVIDIA Developer Forums

How do you think? Maybe the problem arises from the bidirectional translators of the voltage level TXB0108 to GPIO allowing you to switch from 1.8 V module levels to 3.3 V header levels?

Two possible sources of problems:

  1. TXB0108
  2. Linux libraries, the Linux kernel, etc. That is, the software component.

Who, what ideas how to check and localize it? And how to fix it?

andrey.kozeletsky & candanoza & vkuruturi & snarky & fbaez1001 & ShaneCCC

How much does the level of TTL signals generated by the TXB0108 circuit depend on the power source of the board? The question is how much the board’s performance changes depending on:

  1. Power supply by USB +5 volt 2 amperes.
  2. Power supply by USB +5 volt 3 amperes.
  3. Power on the dedicated power connector

Who and what options can test and with what sensors?

ShaneCCC & vkuruturi & Trumany
Tell me where can I find a workable instruction for rebuilding a Linux ubuntu kernel? I want to check how the kernel modules for sensors work behave in order to localize the problem with user space libraries.

I found some information on our subject. But for a long time (more than 10 years I was not involved in the development of microprocessor technology) … Can someone clearly explain whether this is the source of our problems?

http://www.ti.com/lit/ds/symlink/txb0108.pdf (8.3.5 Pullup or Pulldown Resistors on I/O Lines, page 14)

https://forums.adafruit.com/viewtopic.php?f=19&t=116036

Have a check below link to build the kernel for Jetson device.

[url]Welcome — Jetson Linux<br/>Developer Guide 34.1 documentation

ShaneCC I alrady recompile kernel. New kernel not detect TSL2561…
Problem not solved (((

BME280 detect and work correctly on bus0 and bus1 but, BME280 not an ordinary I2C sensor. If you read its documentation carefully, you will find the following lines in it:

“SDA and SCL are not pure open-drain.” (page 31, 6.2 I²C Interface)

https://www.embeddedadventures.com/datasheets/BME280.pdf

Really, I don’t know which way to dig. What could be the problem? What is so special about bus 0 yet? Maybe somewhere in the kernel some settings are set? What is the difference between bus 0 and bus 1?