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

Add health telemetry module #4927

Merged
merged 30 commits into from
Oct 8, 2024
Merged

Add health telemetry module #4927

merged 30 commits into from
Oct 8, 2024

Conversation

thebentern
Copy link
Contributor

@thebentern thebentern commented Oct 2, 2024

Adds a new telemetry module covering health aspects - body temperature, oxygen saturation and heart rate. Currently the MLX90614 IR temperature sensor and MAX30102 temperature/oxygen saturation/heart rate sensors are supported.

The module will add a frame to devices with a screen, and broadcast to the mesh based on the set interval.

Fixes #4738

@thebentern thebentern added the requires-docs Documentation must be updated label Oct 2, 2024
@fifieldt
Copy link
Contributor

fifieldt commented Oct 3, 2024

For reference - looked up emissivity and cows and humans are both 0.98, so that's a good value if we need to set that for temperature sensors. Pigs also >0.95. If this needs to go on furry animals like a mouse, then we need to revisit :)

@fifieldt
Copy link
Contributor

fifieldt commented Oct 4, 2024

I just wrote up the MLX90614 temp sensor quickly as an EnvironmentalTelemetry sensor to get it working. It works now. So we can steal the code for HealthTelemetry testing :)

@fifieldt
Copy link
Contributor

fifieldt commented Oct 4, 2024

OK, and there's the MAX30102 - or, at least the temperature bit - working. As an EnvironmentalTelemetry sensor.

@fifieldt
Copy link
Contributor

fifieldt commented Oct 4, 2024

now for the fun bit?

@fifieldt
Copy link
Contributor

fifieldt commented Oct 4, 2024

Big difference when compared with EnvironmentalTelemetry seems to be that we need to get multiple readings in order to get SPO2 or heart rate. This might end up being more like GPS where we turn it on to get a 'fix', and then sleep it.

thebentern and others added 8 commits October 6, 2024 09:25
It lives on I2C bus at 0x57, which conflicts with an existing
sensor. Add code to check the PARTID register for its response 0x15
per spec.
An IR Temperature sensor suitable for livestock monitoring.
If a MAX30102 is connected, its temperature will be sent to the
mesh as HealthTelemetry.
@fifieldt fifieldt changed the title Add stub health telemetry module Add health telemetry module Oct 6, 2024
@fifieldt
Copy link
Contributor

fifieldt commented Oct 6, 2024

After the last set of changes, spO2 and temperature both look accurate.

Heart rate is too high - tried increasing bus speed to 400Khz but no change, also tried taking 8 seconds (original: 4 secs) of samples and no change.

Also, only works on nrf52 due to some hard-coded references to SCL/SDA.

Sparkfun was having fun with SDA/SCL variables which we can avoid
by switching to this highly similar library.
@fifieldt
Copy link
Contributor

fifieldt commented Oct 6, 2024

Fixed the SCL/SDA stuff by switching libraries for MAX90614.

Screen works!

fifieldt added a commit to fifieldt/meshtastic that referenced this pull request Oct 6, 2024
The health telemetry module, implemented by meshtastic/firmware#4927 , allows heart rate, oxygen saturation, and body temperature measurements to be shared over the mesh.

The first users are likely to be cows, rather than humans :)
@fifieldt fifieldt marked this pull request as ready for review October 6, 2024 12:57
@fifieldt
Copy link
Contributor

fifieldt commented Oct 7, 2024

"Common libs for environmental measurements in telemetry module are not included in native / portduino" - which is why those builds are failing. Need to fix.

@fifieldt
Copy link
Contributor

fifieldt commented Oct 7, 2024

Also need to wrap the screen stuff in a HAS SCREEN it seems.

@fifieldt
Copy link
Contributor

fifieldt commented Oct 7, 2024

"It works!"

@HarukiToreda
Copy link
Contributor

any sneak peek on how the screen will display this data?

@thebentern
Copy link
Contributor Author

DEBUG | ??:??:?? 104 [HealthTelemetryModule] heart_rate=187(1), sp02=100(1)(Sending): temperature=33.500000, heart_bpm=187, spO2=100
DEBUG | ??:??:?? 104 [HealthTelemetryModule] Partially randomized packet id 424126784
INFO | ??:??:?? 104 [HealthTelemetryModule] Sending packet to mesh

@thebentern thebentern merged commit 411aeda into master Oct 8, 2024
33 checks passed
@thebentern thebentern deleted the health-telemetry branch October 8, 2024 00:50
fifieldt added a commit to fifieldt/meshtastic that referenced this pull request Oct 8, 2024
The health telemetry module, implemented by meshtastic/firmware#4927 , allows heart rate, oxygen saturation, and body temperature measurements to be shared over the mesh.

The first users are likely to be cows, rather than humans :)
panaceya added a commit to mesh-mk-ua/meshtastic-firmware that referenced this pull request Oct 8, 2024
* Add RAK4631 Ethernet Gateway with working JSON output to MQTT

* Update platformio.ini

Fix default build environment

* Fix default build platform

* Fix #ifndef and rename the variant

* Fix traceroute, neighborinfo and waypoint

* Disable SCREEN and enable TZ

* Fix platformio.ini conflict

* Fix formatting

* Another try to get the code format correct.

* Trunk fmt

* Remove accelerometer lib

* Toggle Bluetooth with Fn+b shortcut (meshtastic#4977)

* Toggle Blutooth with Fn+b shortcut

Problem:
As many are aware, ESP32 devices are known for their high power consumption. For instance, the Heltec ESP32 V3 draws around 110mA when powered on with the screen active and connected to a phone via Bluetooth. The Bluetooth radio alone is responsible for approximately 50mA of that consumption. For keyboard-based standalone devices, which rarely need Bluetooth other than for changing settings, users were forced to keep Bluetooth on regardless of necessity. There was no way to toggle Bluetooth on or off without physically connecting the device to a computer via serial or using the admin channel, which required another node for access.

Solution:
I implemented a new feature that allows users to turn off Bluetooth on keyboard devices by pressing Fn+b and turn it back on when needed. This enhancement significantly improves power efficiency for these devices.

Result:
With Bluetooth off, the device now consumes only 55mA. When combined with Power Save mode, the consumption can drop as low as 11mA, a substantial reduction from the previous 110mA. Users can still easily reconnect to a phone using the shortcut when necessary, offering greater flexibility and extended battery life.

* Remove 1 reboot at least.

I was able to prevent a reboot using the disableBluetooth(); command, current tested at 47-55mA, it doesn't require a reboot to turn off, but it does need reboot to turn back on.

* Update CannedMessageModule.cpp

* Add health telemetry module (meshtastic#4927)

* Add stub health telemetry module

* Add detection for MAX30102 Health Sensor

It lives on I2C bus at 0x57, which conflicts with an existing
sensor. Add code to check the PARTID register for its response 0x15
per spec.

* Add detection for MLX90614

An IR Temperature sensor suitable for livestock monitoring.

* Add libraries for MLX90614 and MAX30102 sensors

* Fix Trunk

* Add support for MLX90614 IR Temperature Sensor

* Add support for MAX30102 (Temperature)

* Make it build - our first HealthTelemetry on the mesh.

If a MAX30102 is connected, its temperature will be sent to the
mesh as HealthTelemetry.

* Add spo2 and heart rate calculations to MAX30102

* Switch MLX90614 to Adafruit library

Sparkfun was having fun with SDA/SCL variables which we can avoid
by switching to this highly similar library.

* Enable HealthTelemetry if MLX90614 detected

* Change MLX90614 emissivity for human skin.

* Add health screen!

* Remove autogenerated file from branch

* Preparing for review

* Fix MeshService master sync from before.

* Prepare for review

* For the americans

* Fix native build

* Fix for devices with no screen

* Remove extra log causing issues

---------

Co-authored-by: Tom Fifield <[email protected]>

* In shutdown, on button press, wake back to application rather than into the loader. (meshtastic#4997)

Suggested by lyusupov and implemented by todd-herbert.
meshtastic#4651

* De-conflict MLX90614_ADDR macro

* First version of a DeepSleep state for the RP2040 (meshtastic#4976)

* Adding pico-extra utils

* RP2040 can now go to deepsleep

* First RP2040 DeepSleep code - TODO : do better and restore

* FIX RAK11310 compilation (revert SDK + missing defines)

---------

Co-authored-by: Ben Meadors <[email protected]>

* Posthumous tronkination

* No idea why trunk wants to disturb these PNGs but...

* preliminary Othernet Dreamcatcher Support (meshtastic#4933)

* preliminary Othernet Dreamcatcher 2206 Support
Need to adapt to 2301 final version

* second target for latest revision

* preliminary Othernet Dreamcatcher 2206 Support
Need to adapt to 2301 final version

* second target for latest revision

* preliminary Othernet Dreamcatcher 2206 Support
Need to adapt to 2301 final version

* second target for latest revision

* address comments

---------

Co-authored-by: Ben Meadors <[email protected]>
Co-authored-by: Tom Fifield <[email protected]>

---------

Co-authored-by: beegee-tokyo <[email protected]>
Co-authored-by: Bernd Giesecke <[email protected]>
Co-authored-by: Ben Meadors <[email protected]>
Co-authored-by: GUVWAF <[email protected]>
Co-authored-by: GUVWAF <[email protected]>
Co-authored-by: Jonathan Bennett <[email protected]>
Co-authored-by: Tom Fifield <[email protected]>
Co-authored-by: HarukiToreda <[email protected]>
Co-authored-by: jhps <[email protected]>
Co-authored-by: Thomas Göttgens <[email protected]>
Co-authored-by: TheMalkavien <[email protected]>
panaceya added a commit to mesh-mk-ua/meshtastic-firmware that referenced this pull request Oct 9, 2024
* Add RAK4631 Ethernet Gateway with working JSON output to MQTT

* Update platformio.ini

Fix default build environment

* Fix default build platform

* Fix #ifndef and rename the variant

* Fix traceroute, neighborinfo and waypoint

* Disable SCREEN and enable TZ

* Fix platformio.ini conflict

* Fix formatting

* Another try to get the code format correct.

* Trunk fmt

* Remove accelerometer lib

* Toggle Bluetooth with Fn+b shortcut (meshtastic#4977)

* Toggle Blutooth with Fn+b shortcut

Problem:
As many are aware, ESP32 devices are known for their high power consumption. For instance, the Heltec ESP32 V3 draws around 110mA when powered on with the screen active and connected to a phone via Bluetooth. The Bluetooth radio alone is responsible for approximately 50mA of that consumption. For keyboard-based standalone devices, which rarely need Bluetooth other than for changing settings, users were forced to keep Bluetooth on regardless of necessity. There was no way to toggle Bluetooth on or off without physically connecting the device to a computer via serial or using the admin channel, which required another node for access.

Solution:
I implemented a new feature that allows users to turn off Bluetooth on keyboard devices by pressing Fn+b and turn it back on when needed. This enhancement significantly improves power efficiency for these devices.

Result:
With Bluetooth off, the device now consumes only 55mA. When combined with Power Save mode, the consumption can drop as low as 11mA, a substantial reduction from the previous 110mA. Users can still easily reconnect to a phone using the shortcut when necessary, offering greater flexibility and extended battery life.

* Remove 1 reboot at least.

I was able to prevent a reboot using the disableBluetooth(); command, current tested at 47-55mA, it doesn't require a reboot to turn off, but it does need reboot to turn back on.

* Update CannedMessageModule.cpp

* Add health telemetry module (meshtastic#4927)

* Add stub health telemetry module

* Add detection for MAX30102 Health Sensor

It lives on I2C bus at 0x57, which conflicts with an existing
sensor. Add code to check the PARTID register for its response 0x15
per spec.

* Add detection for MLX90614

An IR Temperature sensor suitable for livestock monitoring.

* Add libraries for MLX90614 and MAX30102 sensors

* Fix Trunk

* Add support for MLX90614 IR Temperature Sensor

* Add support for MAX30102 (Temperature)

* Make it build - our first HealthTelemetry on the mesh.

If a MAX30102 is connected, its temperature will be sent to the
mesh as HealthTelemetry.

* Add spo2 and heart rate calculations to MAX30102

* Switch MLX90614 to Adafruit library

Sparkfun was having fun with SDA/SCL variables which we can avoid
by switching to this highly similar library.

* Enable HealthTelemetry if MLX90614 detected

* Change MLX90614 emissivity for human skin.

* Add health screen!

* Remove autogenerated file from branch

* Preparing for review

* Fix MeshService master sync from before.

* Prepare for review

* For the americans

* Fix native build

* Fix for devices with no screen

* Remove extra log causing issues

---------

Co-authored-by: Tom Fifield <[email protected]>

* In shutdown, on button press, wake back to application rather than into the loader. (meshtastic#4997)

Suggested by lyusupov and implemented by todd-herbert.
meshtastic#4651

* De-conflict MLX90614_ADDR macro

* First version of a DeepSleep state for the RP2040 (meshtastic#4976)

* Adding pico-extra utils

* RP2040 can now go to deepsleep

* First RP2040 DeepSleep code - TODO : do better and restore

* FIX RAK11310 compilation (revert SDK + missing defines)

---------

Co-authored-by: Ben Meadors <[email protected]>

* Posthumous tronkination

* No idea why trunk wants to disturb these PNGs but...

* preliminary Othernet Dreamcatcher Support (meshtastic#4933)

* preliminary Othernet Dreamcatcher 2206 Support
Need to adapt to 2301 final version

* second target for latest revision

* preliminary Othernet Dreamcatcher 2206 Support
Need to adapt to 2301 final version

* second target for latest revision

* preliminary Othernet Dreamcatcher 2206 Support
Need to adapt to 2301 final version

* second target for latest revision

* address comments

---------

Co-authored-by: Ben Meadors <[email protected]>
Co-authored-by: Tom Fifield <[email protected]>

* Ignore packets coming from the broadcast address (meshtastic#4998)

---------

Co-authored-by: beegee-tokyo <[email protected]>
Co-authored-by: Bernd Giesecke <[email protected]>
Co-authored-by: Ben Meadors <[email protected]>
Co-authored-by: GUVWAF <[email protected]>
Co-authored-by: GUVWAF <[email protected]>
Co-authored-by: Jonathan Bennett <[email protected]>
Co-authored-by: Tom Fifield <[email protected]>
Co-authored-by: HarukiToreda <[email protected]>
Co-authored-by: jhps <[email protected]>
Co-authored-by: Thomas Göttgens <[email protected]>
Co-authored-by: TheMalkavien <[email protected]>
fifieldt added a commit to fifieldt/meshtastic that referenced this pull request Oct 11, 2024
The health telemetry module, implemented by meshtastic/firmware#4927 , allows heart rate, oxygen saturation, and body temperature measurements to be shared over the mesh.

The first users are likely to be cows, rather than humans :)
fifieldt added a commit to fifieldt/meshtastic that referenced this pull request Oct 13, 2024
The health telemetry module, implemented by meshtastic/firmware#4927 , allows heart rate, oxygen saturation, and body temperature measurements to be shared over the mesh.

The first users are likely to be cows, rather than humans :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requires-docs Documentation must be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Addtional Sensor for Farm Animals Health
3 participants