I hope that this is something ignorant on my part, but I have looked for anything similar here and on the net, and have not found it.
I am using pigpio_if2 to read and write to sensors connected to a Raspberry Pi 4, testing using the daemon (pigpiod) or when launched by another program linked to pigpio which acts as a daemon.
uname -a returns: Linux Grape2-Pi32 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
but I am using the 32bit userland install of Raspbian for continuity reasons.
pigpiod -V returns 79.
I am working with hardware that presents three devices on the /dev/i2c-1 bus. One appears at 0x20, and has many registers which I read and write. The others are two MCP9808 temperature sensors, one local and one remote, which present at 0x18 and 0x19, respectively. 'i2cdetect -y 1' shows all sensors present at the expected addresses.
In general, your wonderful tools are working very well. At first I was just ignoring the local temp sensor. But when I was asked report both, as I had in earlier (non-pigpio) versions of the software. But when I was asked to make it report both temperatures, odd behavior began to appear.
Early in the code I open handles on each device using i2c_open(). In a stripped-down test version of the code this is what happens:
$ ./test_pigpio_opens
[CHILD] pigpio_start(RM3100) OK. p->pi = 0
[CHILD] i2c_open(RM3100) Magnetometer OK. Address: 0x20, Handle: 0
[CHILD] i2c_open(MCP9808-0) Local Temp OK. Address: 0x18, Handle: 1
[CHILD] i2c_open(MCP9808-1) Remote Temp OK. Address: 0x19, Handle: 1
(This is the same in the actual program)
The handle for the magnetometer is usually some integer, often 0, depending on how long it has been since I restarted pigpiod.
The handles returned for the two MCP9808 sensors are the same, almost always 1.
When my code reads the ambient temperature from these sensors using i2c_read_i2c_block_data() with the appropriate handle
i.e: rv = i2c_read_i2c_block_data(p->pi, p->remoteTempHandle, MCP9808_REG_AMBIENT_TEMP, (char *) data, 2);
i.e: rv = i2c_read_i2c_block_data(p->pi, p->localTempHandle, MCP9808_REG_AMBIENT_TEMP, (char *) data, 2);
each sensor returns the same value. That is not too surprising, in that the handle that I pass: - remoteTempHandle or localTempHandle, are equal, both both usually 1.
The output from the actual program looks like this, with both "lt" and "rt" values changing in locstep:
$ ./magdata
[CHILD] In ./magdata child process.
[CHILD] Open PIPE Out OK.
[CHILD] Open PIPE In OK.
[CHILD] Before setting up GPIO.
[CHILD] i2c_open(RM3100) Magnetometer OK. Reg: 32, Handle: 5
[CHILD] i2c_open(MCP9808) Local Temp OK. Reg: 24, Handle: 1
[CHILD] i2c_open(MCP9808) Remote Temp OK. Reg: 25, Remote Handle: 1
[CHILD]: { "ts":202403 7242728, "lt": 33.12, "rt": 33.12, "x":223.881, "y":-423.296, "z":-93.260 }
[CHILD]: { "ts":202403 7242729, "lt": 33.12, "rt": 33.12, "x":223.947, "y":-423.339, "z":-93.255 }
[CHILD]: { "ts":202403 7242730, "lt": 33.12, "rt": 33.12, "x":223.945, "y":-423.322, "z":-93.262 }
[CHILD]: { "ts":202403 7242731, "lt": 33.06, "rt": 33.06, "x":223.951, "y":-423.322, "z":-93.255 }
[CHILD]: { "ts":202403 7242732, "lt": 33.12, "rt": 33.12, "x":223.962, "y":-423.317, "z":-93.262 }
[CHILD]: { "ts":202403 7242733, "lt": 33.12, "rt": 33.12, "x":223.955, "y":-423.311, "z":-93.266 }
[CHILD]: { "ts":202403 7242734, "lt": 33.06, "rt": 33.06, "x":223.963, "y":-423.312, "z":-93.259 }
Any suggestions?
I am using pigpio_if2 to read and write to sensors connected to a Raspberry Pi 4, testing using the daemon (pigpiod) or when launched by another program linked to pigpio which acts as a daemon.
uname -a returns: Linux Grape2-Pi32 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
but I am using the 32bit userland install of Raspbian for continuity reasons.
pigpiod -V returns 79.
I am working with hardware that presents three devices on the /dev/i2c-1 bus. One appears at 0x20, and has many registers which I read and write. The others are two MCP9808 temperature sensors, one local and one remote, which present at 0x18 and 0x19, respectively. 'i2cdetect -y 1' shows all sensors present at the expected addresses.
In general, your wonderful tools are working very well. At first I was just ignoring the local temp sensor. But when I was asked report both, as I had in earlier (non-pigpio) versions of the software. But when I was asked to make it report both temperatures, odd behavior began to appear.
Early in the code I open handles on each device using i2c_open(). In a stripped-down test version of the code this is what happens:
$ ./test_pigpio_opens
[CHILD] pigpio_start(RM3100) OK. p->pi = 0
[CHILD] i2c_open(RM3100) Magnetometer OK. Address: 0x20, Handle: 0
[CHILD] i2c_open(MCP9808-0) Local Temp OK. Address: 0x18, Handle: 1
[CHILD] i2c_open(MCP9808-1) Remote Temp OK. Address: 0x19, Handle: 1
(This is the same in the actual program)
The handle for the magnetometer is usually some integer, often 0, depending on how long it has been since I restarted pigpiod.
The handles returned for the two MCP9808 sensors are the same, almost always 1.
When my code reads the ambient temperature from these sensors using i2c_read_i2c_block_data() with the appropriate handle
i.e: rv = i2c_read_i2c_block_data(p->pi, p->remoteTempHandle, MCP9808_REG_AMBIENT_TEMP, (char *) data, 2);
i.e: rv = i2c_read_i2c_block_data(p->pi, p->localTempHandle, MCP9808_REG_AMBIENT_TEMP, (char *) data, 2);
each sensor returns the same value. That is not too surprising, in that the handle that I pass: - remoteTempHandle or localTempHandle, are equal, both both usually 1.
The output from the actual program looks like this, with both "lt" and "rt" values changing in locstep:
$ ./magdata
[CHILD] In ./magdata child process.
[CHILD] Open PIPE Out OK.
[CHILD] Open PIPE In OK.
[CHILD] Before setting up GPIO.
[CHILD] i2c_open(RM3100) Magnetometer OK. Reg: 32, Handle: 5
[CHILD] i2c_open(MCP9808) Local Temp OK. Reg: 24, Handle: 1
[CHILD] i2c_open(MCP9808) Remote Temp OK. Reg: 25, Remote Handle: 1
[CHILD]: { "ts":202403 7242728, "lt": 33.12, "rt": 33.12, "x":223.881, "y":-423.296, "z":-93.260 }
[CHILD]: { "ts":202403 7242729, "lt": 33.12, "rt": 33.12, "x":223.947, "y":-423.339, "z":-93.255 }
[CHILD]: { "ts":202403 7242730, "lt": 33.12, "rt": 33.12, "x":223.945, "y":-423.322, "z":-93.262 }
[CHILD]: { "ts":202403 7242731, "lt": 33.06, "rt": 33.06, "x":223.951, "y":-423.322, "z":-93.255 }
[CHILD]: { "ts":202403 7242732, "lt": 33.12, "rt": 33.12, "x":223.962, "y":-423.317, "z":-93.262 }
[CHILD]: { "ts":202403 7242733, "lt": 33.12, "rt": 33.12, "x":223.955, "y":-423.311, "z":-93.266 }
[CHILD]: { "ts":202403 7242734, "lt": 33.06, "rt": 33.06, "x":223.963, "y":-423.312, "z":-93.259 }
Any suggestions?
Statistics: Posted by wittend — Fri Mar 08, 2024 5:29 pm