Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: telemetry from i2c sensor not sent in DeviceTelemetryModule packages #5139

Open
xinrag opened this issue Oct 24, 2024 · 14 comments
Open
Labels
bug Something isn't working

Comments

@xinrag
Copy link

xinrag commented Oct 24, 2024

Category

Other

Hardware

Linux Native

Firmware Version

2.5.6.d55c08d

Description

meshtasticd_2.5.6.d55c08d_arm64.deb
mestatic-2.5.3
raspberry pi 3b+ with bookworm
SPI Hat with SX1262

i2c bmp-280 is recognized...:
Oct 24 17:15:46 dc8lz-mesh meshtasticd[1647]: INFO | 17:15:23 0 Using /dev/i2c-1 as I2C device.
Oct 24 17:15:46 dc8lz-mesh meshtasticd[1647]: INFO | 17:15:23 0 Scanning for i2c devices...
Oct 24 17:15:46 dc8lz-mesh meshtasticd[1647]: INFO | 17:15:23 0 BMP-280 sensor found at address 0x76
Oct 24 17:15:46 dc8lz-mesh meshtasticd[1647]: INFO | 17:15:23 0 1 I2C devices found

Telemetry is enabled:
"telemetry": {
"deviceUpdateInterval": 15,
"environmentUpdateInterval": 15,
"environmentMeasurementEnabled": true,
"environmentScreenEnabled": false,
"environmentDisplayFahrenheit": false,
"airQualityEnabled": false,
"airQualityInterval": 0,
"powerMeasurementEnabled": false,
"powerUpdateInterval": 0,
"powerScreenEnabled": false
},

Packages does not contain the sensor informations...:

Oct 24 17:22:46 dc8lz-mesh meshtasticd[1647]: INFO | 15:21:08 345 [DeviceTelemetryModule] (Sending): air_util_tx=0.381472, channel_utilization=3.780000, battery_level=101, voltage=0.000000, uptime=345
Oct 24 17:22:46 dc8lz-mesh meshtasticd[1647]: INFO | 15:21:08 345 [DeviceTelemetryModule] Sending packet to mesh

Sidenote: can read out the bmp-280 with a simple python script.

Can you help me out? Found a bug?
Thank you!

btw: powersaving disabled

Relevant log output

Oct 24 17:15:46 dc8lz-mesh meshtasticd[1647]: INFO  | 17:15:23 0 Using /dev/i2c-1 as I2C device.
Oct 24 17:15:46 dc8lz-mesh meshtasticd[1647]: INFO  | 17:15:23 0 Scanning for i2c devices...
Oct 24 17:15:46 dc8lz-mesh meshtasticd[1647]: INFO  | 17:15:23 0 BMP-280 sensor found at address 0x76
Oct 24 17:15:46 dc8lz-mesh meshtasticd[1647]: INFO  | 17:15:23 0 1 I2C devices found

Oct 24 17:22:46 dc8lz-mesh meshtasticd[1647]: INFO  | 15:21:08 345 [DeviceTelemetryModule] (Sending): air_util_tx=0.381472, channel_utilization=3.780000, battery_level=101, voltage=0.000000, uptime=345
Oct 24 17:22:46 dc8lz-mesh meshtasticd[1647]: INFO  | 15:21:08 345 [DeviceTelemetryModule] Sending packet to mesh
@xinrag xinrag added the bug Something isn't working label Oct 24, 2024
@fifieldt
Copy link
Contributor

Hi, thank you for the report. I checked the code for the BMP-280 and on first glance it looks like it should be working

I noticed the log lines you focused on were for DeviceTelemetryModule.

For the BPM-280, the log lines to look for are EnvironmentTelemetryModule.
Can you run the logs for a bit longer and see if you see EnvironmentTelemetryModule ?

@garthvh
Copy link
Member

garthvh commented Oct 25, 2024

Most of the modules are not yet supported on linux

@xinrag
Copy link
Author

xinrag commented Oct 25, 2024

@fifieldt Thank you for diggin in... the the complete output does not list any EnvironmentTelemetryModule notices:

INFO | 21:48:47 0 Using /dev/i2c-1 as I2C device.
INFO | 21:48:47 0 Scanning for i2c devices...
INFO | 21:48:47 0 BMP-280 sensor found at address 0x76
INFO | 21:48:47 0 1 I2C devices found
INFO | 21:48:47 0 S:B:37,2.5.6.d55c08d
INFO | 21:48:47 0 Initializing NodeDB
INFO | 21:48:47 0 Loading /prefs/db.proto
INFO | 21:48:47 0 Loaded /prefs/db.proto successfully
INFO | 21:48:47 0 Loaded saved devicestate version 23, with nodecount: 69
INFO | 21:48:47 0 Loading /prefs/config.proto
INFO | 21:48:47 0 Loaded /prefs/config.proto successfully
INFO | 21:48:47 0 Loaded saved config version 23
INFO | 21:48:47 0 Loading /prefs/module.proto
INFO | 21:48:47 0 Loaded /prefs/module.proto successfully
INFO | 21:48:47 0 Loaded saved moduleConfig version 23
INFO | 21:48:47 0 Loading /prefs/channels.proto
INFO | 21:48:47 0 Loaded /prefs/channels.proto successfully
INFO | 21:48:47 0 Loaded saved channelFile version 23
/root/.portduino/default/oem/oem.proto does not exist
ERROR | 21:48:47 0 Could not open / read /oem/oem.proto
INFO | 21:48:47 0 Wanted region 3, using EU_868
/root/.portduino/default/prefs/cannedConf.proto does not exist
ERROR | 19:48:47 0 Could not open / read /prefs/cannedConf.proto
INFO | 19:48:47 0 CannedMessageModule is enabled
INFO | 19:48:47 0 Starting meshradio init...
INFO | 19:48:47 0 Radio freq=869.525, config.lora.frequency_offset=0.000
INFO | 19:48:47 0 Set radio: region=EU_868, name=LongFast, config=0, ch=0, power=1
INFO | 19:48:47 0 myRegion->freqStart -> myRegion->freqEnd: 869.400024 -> 869.650024 (0.250000 MHz)
INFO | 19:48:47 0 numChannels: 1 x 250.000kHz
INFO | 19:48:47 0 channel_num: 1
INFO | 19:48:47 0 frequency: 869.525024
INFO | 19:48:47 0 Slot time: 77 msec
INFO | 19:48:47 0 Set radio: final power level=1
INFO | 19:48:47 0 SX126x init result 0
INFO | 19:48:47 0 Frequency set to 869.525024
INFO | 19:48:47 0 Bandwidth set to 250.000000
INFO | 19:48:47 0 Power output set to 1
INFO | 19:48:47 0 Set RX gain to power saving mode (boosted mode off); result: 0
INFO | 19:48:47 0 SX1262 Radio init succeeded, using SX1262 radio
INFO | 19:48:47 0 Using webserver port from yaml config. 443
INFO | 19:48:47 0 Webserver started ....
INFO | 19:48:47 0 Web Server framework started on port: 443
INFO | 19:48:47 0 Web Server root /usr/share/doc/meshtasticd/web
INFO | 19:48:47 0 API server listening on TCP port 4403
INFO | 19:48:47 0 PowerFSM init, USB power=1
INFO | 19:49:01 15 [Router] Received position from=0xda5853cc, id=0x5527bfb0, portnum=3, payloadlen=21
INFO | 19:49:01 15 [Router] updatePosition REMOTE node=0xda5853cc time=1729885772 lat=480100352 lon=76955648
INFO | 19:49:01 15 [Router] Received routing from=0xda5853cc, id=0x5527bfb0, portnum=3, payloadlen=21
INFO | 19:49:01 15 [Router] Rebroadcasting received floodmsg
INFO | 19:49:17 30 [NodeInfoModule] Sending our nodeinfo to mesh (wantReplies=1)
INFO | 19:49:17 30 [NodeInfoModule] sending owner !ebcff208/DC8LZ Raspi/8LZR
INFO | 19:49:22 36 [Router] Received nodeinfo from=0xda5aef58, id=0x9aca383d, portnum=4, payloadlen=75
INFO | 19:49:22 36 [Router] Public Key set for node, not updating!
INFO | 19:49:22 36 [Router] Received routing from=0xda5aef58, id=0x9aca383d, portnum=4, payloadlen=75
INFO | 19:49:25 38 [Router] Received position from=0xda5aef58, id=0xa251243e, portnum=3, payloadlen=28
INFO | 19:49:25 38 [Router] updatePosition REMOTE node=0xda5aef58 time=1729885761 lat=479805300 lon=79742100
INFO | 19:49:25 38 [Router] Received routing from=0xda5aef58, id=0xa251243e, portnum=3, payloadlen=28
INFO | 19:49:25 38 [Router] Rebroadcasting received floodmsg
WARN | 19:49:28 41 [RadioIf] Can not send yet, busyRx
INFO | 19:49:28 42 [Router] Received nodeinfo from=0xfa5a7454, id=0x94cf729c, portnum=4, payloadlen=52
INFO | 19:49:28 42 [Router] Received routing from=0xfa5a7454, id=0x94cf729c, portnum=4, payloadlen=52
INFO | 19:49:32 45 [DeviceTelemetryModule] (Sending): air_util_tx=0.058833, channel_utilization=10.055000, battery_level=101, voltage=0.000000, up time=45
INFO | 19:49:32 45 [DeviceTelemetryModule] Sending packet to mesh
INFO | 19:49:47 60 [PositionModule] Sending pos@0:6 to mesh (wantReplies=1)
INFO | 19:49:47 60 [PositionModule] Providing time to mesh 1729885787
INFO | 19:49:47 60 [PositionModule] Position reply: time=1729885787 lat=479805074 lon=79743520
INFO | 19:49:51 64 [Router] Received position from=0xda5aef58, id=0xaf7703f, portnum=3, payloadlen=28
INFO | 19:49:51 64 [Router] updatePosition REMOTE node=0xda5aef58 time=1729885788 lat=479805300 lon=79742100
INFO | 19:49:51 64 [Router] Received routing from=0xda5aef58, id=0xaf7703f, portnum=3, payloadlen=28
INFO | 19:49:53 66 [Router] Received position from=0xfa5a7454, id=0xfc00369d, portnum=3, payloadlen=16
INFO | 19:49:53 66 [Router] updatePosition REMOTE node=0xfa5a7454 time=0 lat=479837100 lon=79659100
INFO | 19:49:53 66 [Router] Received routing from=0xfa5a7454, id=0xfc00369d, portnum=3, payloadlen=16
INFO | 19:50:32 105 [DeviceTelemetryModule] (Sending): air_util_tx=0.091444, channel_utilization=3.915000, battery_level=101, voltage=0.000000, uptime=105
INFO | 19:50:32 105 [DeviceTelemetryModule] Sending packet to mesh
INFO | 19:50:52 125 [Router] Received position from=0x4359095c, id=0x131f8380, portnum=3, payloadlen=16
INFO | 19:50:52 125 [Router] updatePosition REMOTE node=0x4359095c time=0 lat=479899080 lon=78651180
INFO | 19:50:52 125 [Router] Received routing from=0x4359095c, id=0x131f8380, portnum=3, payloadlen=16
INFO | 19:50:52 125 [Router] Rebroadcasting received floodmsg
INFO | 19:51:32 165 [DeviceTelemetryModule] (Sending): air_util_tx=0.121778, channel_utilization=2.655000, battery_level=101, voltage=0.000000, uptime=165
INFO | 19:51:32 165 [DeviceTelemetryModule] Sending packet to mesh
INFO | 19:51:33 166 [Router] Received position from=0xfa5a7454, id=0x6ba1929e, portnum=3, payloadlen=16
INFO | 19:51:33 166 [Router] updatePosition REMOTE node=0xfa5a7454 time=0 lat=479837100 lon=79659100
INFO | 19:51:33 166 [Router] Received routing from=0xfa5a7454, id=0x6ba1929e, portnum=3, payloadlen=16
INFO | 19:51:33 166 [Router] Rebroadcasting received floodmsg
INFO | 19:52:32 225 [DeviceTelemetryModule] (Sending): air_util_tx=0.152361, channel_utilization=0.000000, battery_level=101, voltage=0.000000, uptime=225
INFO | 19:52:32 225 [DeviceTelemetryModule] Sending packet to mesh
INFO | 19:53:32 285 [DeviceTelemetryModule] (Sending): air_util_tx=0.169028, channel_utilization=0.000000, battery_level=101, voltage=0.000000, uptime=285
INFO | 19:53:32 285 [DeviceTelemetryModule] Sending packet to mesh
INFO | 19:53:35 288 [Router] Received DeviceTelemetry from=0xda5aef58, id=0xe07c2040, portnum=67, payloadlen=17
INFO | 19:53:35 288 [Router] Received PowerTelemetry from=0xda5aef58, id=0xe07c2040, portnum=67, payloadlen=17
INFO | 19:53:35 288 [Router] Received routing from=0xda5aef58, id=0xe07c2040, portnum=67, payloadlen=17
INFO | 19:53:35 288 [Router] Rebroadcasting received floodmsg
INFO | 19:54:32 345 [DeviceTelemetryModule] (Sending): air_util_tx=0.200306, channel_utilization=0.876667, battery_level=101, voltage=0.000000, uptime=345
INFO | 19:54:32 345 [DeviceTelemetryModule] Sending packet to mesh
INFO | 19:55:04 377 [Router] Received DeviceTelemetry from=0xda5aef58, id=0x33e4041, portnum=67, payloadlen=28
INFO | 19:55:04 377 [Router] (Received from 8LZS): air_util_tx=2.001528, channel_utilization=6.831667, battery_level=101, voltage=4.515000
INFO | 19:55:04 377 [Router] Received PowerTelemetry from=0xda5aef58, id=0x33e4041, portnum=67, payloadlen=28
INFO | 19:55:04 377 [Router] Received routing from=0xda5aef58, id=0x33e4041, portnum=67, payloadlen=28
INFO | 19:55:04 377 [Router] Rebroadcasting received floodmsg
INFO | 19:55:32 405 [DeviceTelemetryModule] (Sending): air_util_tx=0.233861, channel_utilization=2.026667, battery_level=101, voltage=0.000000, uptime=405
INFO | 19:55:32 405 [DeviceTelemetryModule] Sending packet to mesh

@garthvh thanks for notice! you mean f.e. sending EnvironmentTelemetryModule is here is a feature request? Maybe does come later?

@fifieldt
Copy link
Contributor

Thanks for the extra logs @xinrag . it looks like the EnvironmentTelemetryModule isn't starting up. As Garth hints, it might just be disabled due to the architecture. Fixable, but I'll need to set up a development environment to try and work out why :)

@zpatten
Copy link

zpatten commented Nov 4, 2024

I'm having the same issue using native/portduino on a pi zero 2.

Devices are detected:

Nov 04 14:54:44 meshtastic-router meshtasticd[564]: INFO  | 14:54:30 0 Using /dev/i2c-1 as I2C device.
Nov 04 14:54:44 meshtastic-router meshtasticd[564]: INFO  | 14:54:30 0 Scanning for i2c devices...
Nov 04 14:54:44 meshtastic-router meshtasticd[564]: INFO  | 14:54:30 0 PMSA0031 air quality sensor found
Nov 04 14:54:44 meshtastic-router meshtasticd[564]: INFO  | 14:54:30 0 BMP-280 sensor found at address 0x77
Nov 04 14:54:44 meshtastic-router meshtasticd[564]: INFO  | 14:54:30 0 2 I2C devices found

However as with OP, there is nothing in the logs from the EnvironmentTelemetryModule.

Happy to help debug in any way or run test builds. I have an environment setup on a pi 4 to compile native/portduino for my pi zero so I'd be happy to compile and test any branches with a possible fix.

@zpatten
Copy link

zpatten commented Nov 4, 2024

@fifieldt If you can show me the points of interest in the code I'd be happy to take a stab at getting this working.

@tavdog
Copy link
Contributor

tavdog commented Nov 7, 2024

Someone on the discord also seeing this. [EnvironmentTelemetryModule] (Sending): barometric_pressure=997.325378, current=0.000000, gas_resistance=0.000000, relative_humidity=56.666088, temperature=25.459999 Node serial log shows the humidity but 0% gets sent out

The new protobuf requires the "has_VALUE" to be called to indicate that there is actual data to be encoded or it just skips it. So for any actual values need to call
m.variant.environment_metrics.has_barometric_pressure = true;
i'm not sure where this logic and calls should go though.

@tavdog
Copy link
Contributor

tavdog commented Nov 7, 2024

I think I found it. Since environmentalTelem code is combining data from two sensors and the has_XXXX functions are being called on the individual sensor packets, when the data is combined into another telem packet object the has_XXX are not called again on the new packet.

            // prefer bmp280 temp if both sensors are present, fetch only humidity
            meshtastic_Telemetry m_ahtx = meshtastic_Telemetry_init_zero;
            LOG_INFO("AHTX0+BMP280 module detected: using temp from BMP280 and humy from AHTX0");
            aht10Sensor.getMetrics(&m_ahtx);
            m->variant.environment_metrics.relative_humidity = m_ahtx.variant.environment_metrics.relative_humidity;
            // NEED TO CALL has_relative_humidity = true HERE
        } else {
            // prefer bmp3xx temp if both sensors are present, fetch only humidity
            meshtastic_Telemetry m_ahtx = meshtastic_Telemetry_init_zero;
            LOG_INFO("AHTX0+BMP3XX module detected: using temp from BMP3XX and humy from AHTX0");
            aht10Sensor.getMetrics(&m_ahtx);
            m->variant.environment_metrics.relative_humidity = m_ahtx.variant.environment_metrics.relative_humidity;
        }```

@tavdog
Copy link
Contributor

tavdog commented Nov 7, 2024

This should fix the case for AHTX0 #5277

@xinrag
Copy link
Author

xinrag commented Nov 10, 2024

testing 2.5.12 atm here and poorly my system stoll does not send this env data. :/
can I help?
still no EnvironmentTelemetryModule notices in the stdout log of the meshtasticd and so no telemetry informations found with the client...

@tavdog
Copy link
Contributor

tavdog commented Nov 10, 2024 via email

@thebentern thebentern reopened this Nov 10, 2024
@riker09
Copy link

riker09 commented Nov 17, 2024

I think I am having this issue as well. My device is a Heltec ESP32 v3.1 ordered from Amazon. I have attached a BMP280 to pins 17 and 18 and the temperature and pressure values are shown on the display and are visible in the Android Meshtastic App when connected via Bluetooth.

But my "gateway" node (same hardware, but connected to my wifi with MQTT enabled) only receives device stats (like battery, airutil, chutil), no environment telemetry.

The MQTT template sensors in Home Assistent already work, I can see the values from the device, just the environment values are missing.

I'm writing this for two reasons: One, to provide more insights. Two, to get notified when a fixes firmware is released. 😅

@riker09
Copy link

riker09 commented Nov 23, 2024

A small update. I had some free time on my hands and was able to poke around a bit with the meshtastic CLI. I was able to receive telemetry from the other node in the mesh with the following command:

$ ./meshtastic --port /dev/ttyUSB1 --request-telemetry environment  --dest '!12345678'
Connected to radio
Sending environment_metrics telemetry request to !12345678 on channelIndex:0 (this could take a while)
Telemetry received:
environmentMetrics:
  temperature: 19.77
  relativeHumidity: 47.13965
  barometricPressure: 1011.6044

@riker09
Copy link

riker09 commented Nov 23, 2024

All right, a bit more investigation revealed that the sensor node, in fact, is publishing telemetry data. It just happens on a different MQTT topic than expected.

This is (part of) my mqtt.yaml file in Home Assistant, as recommended by the official HA integration documentation:

sensor:
  - name: "Node 1 Humidity"
    unique_id: "node_1_humidity"
    state_topic: "msh/EU_433/2/json/PKI/!12345678"
    state_class: measurement
    value_template: >-
      {% if value_json.from == 1129923668 and value_json.payload.relative_humidity is defined %}
        {{ (value_json.payload.relative_humidity | float) | round(2) }}
      {% else %}
        {{ this.state }}
      {% endif %}
    device_class: "humidity"
    unit_of_measurement: "%"

This is what I receive on the MQTT topic msh/EU_433/2/json/PKI/!12345678:

{
  "channel": 0,
  "from": 1129923668,
  "hop_start": 2,
  "hops_away": 0,
  "id": 3798185952,
  "payload": {
    "barometric_pressure": 1011.80029296875,
    "current": 0,
    "gas_resistance": 0,
    "iaq": 0,
    "lux": 0,
    "relative_humidity": 56.6611328125,
    "temperature": 5.88000011444092,
    "voltage": 0,
    "white_lux": 0,
    "wind_direction": 0,
    "wind_gust": 0,
    "wind_lull": 0,
    "wind_speed": 0
  },
  "rssi": -103,
  "sender": "!12345678",
  "snr": 0.5,
  "timestamp": 1732370418,
  "to": 862507976,
  "type": "telemetry"
}

Please note: I can get these messages when I manually issue the CLI command from my last post. So far I have seen no automatic messages on my MQTT broker.

Additionally I receive two messages on the topic. The first one has all measurements set to 0, but since it has a different from value it is not used in the YAML template.

1st message (contains measurement values set to 0)

from: 862507976
to: 1129923668

2nd message (contains actual values)

from: 1129923668
to: 862507976

I'm not exactly sure what's going on here, but I'm taking one step at a time. 😃

I hope this may be useful to somebody stumbling across this like I did. I am not affected by the bug initially described in this issue. Please excuse the additional noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants