Added INA219 sensor
This commit is contained in:
1 parent
e296c49580
commit
ff4c28985c
5 files changed
+88
-2
No files matched your search
@@ -42,6 +42,8 @@ jobs:
|
||||
- wio-e5-mini_repeater
|
||||
- LilyGo_T3_STM32_repeater
|
||||
- LilyGo_T3_STM32_companion_radio_usb
|
||||
- LilyGo_T3_STM32_repeater_ina219
|
||||
- LilyGo_T3_STM32_companion_radio_usb_ina219
|
||||
# ESP32-C6
|
||||
- LilyGo_Tlora_C6_repeater_
|
||||
# LR1110 (nRF52)
|
||||
|
||||
@@ -15,6 +15,41 @@ The companion supports 100 contacts and eight channels. Radio settings inherit
|
||||
the repository defaults; select settings appropriate to the board's RF band.
|
||||
Existing saved preferences override build defaults.
|
||||
|
||||
## Optional INA219 telemetry
|
||||
|
||||
The INA219 builds use MeshCore's existing environment sensor driver to report
|
||||
voltage, current, and power. Build either role with:
|
||||
|
||||
```sh
|
||||
pio run -e LilyGo_T3_STM32_repeater_ina219
|
||||
pio run -e LilyGo_T3_STM32_companion_radio_usb_ina219
|
||||
```
|
||||
|
||||
Connect the sensor's logic supply to **3.3 V** and use a common ground:
|
||||
|
||||
| INA219 connection | T3 STM32 connection |
|
||||
| --- | --- |
|
||||
| VCC / logic supply | 3.3 V |
|
||||
| GND | GND |
|
||||
| SDA | PB7 (JP2 pin 9) |
|
||||
| SCL | PB8 (JP2 pin 10) |
|
||||
|
||||
PB7/PB8 are the alternate I2C1 pins exposed on the board headers. The default
|
||||
STM32 I2C pins, PA9/PA10, are reserved for USB serial. The OLED uses SPI.
|
||||
The sensor is detected at startup at address **0x40**; to use another address,
|
||||
override `TELEM_INA219_ADDRESS` in the build flags. An absent sensor produces no
|
||||
additional telemetry. The base builds do not initialize I2C or include the driver.
|
||||
|
||||
The measurement terminals (VIN+ and VIN-) go in series with the positive supply
|
||||
of the circuit being measured; these are separate from the sensor's logic supply.
|
||||
See the [INA219 wiring guide](https://learn.adafruit.com/adafruit-ina219-current-sensor-breakout/wiring).
|
||||
USB power can bypass a sensor placed only in the battery lead.
|
||||
|
||||
Readings use environment telemetry permissions. Existing telemetry encodes current
|
||||
in 1 mA steps and power in whole watts; it does not provide accumulated mAh or
|
||||
battery percentage. INA219 telemetry has been confirmed on hardware with the
|
||||
repeater build; the USB companion sensor build has been compile-tested only.
|
||||
|
||||
## Flash and connect
|
||||
|
||||
Connect the USB serial port. Hold BOOT, press and release RST, then release BOOT:
|
||||
@@ -63,4 +98,4 @@ pings timed out; long-term reliability has not been established. Higher transmit
|
||||
powers are outside the validated MVP setting.
|
||||
|
||||
The repeater builds successfully; forwarding has not been hardware-tested.
|
||||
Battery telemetry, SD storage, and low-power optimization are not implemented.
|
||||
Built-in battery telemetry, SD storage, and low-power optimization are not implemented.
|
||||
@@ -50,3 +50,32 @@ build_src_filter = ${lilygo_t3_stm32.build_src_filter}
|
||||
+<../examples/companion_radio/ui-orig/*.cpp>
|
||||
lib_deps = ${lilygo_t3_stm32.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
; Optional INA219 telemetry on I2C1. Keep the base builds sensor-free.
|
||||
[lilygo_t3_stm32_ina219]
|
||||
build_flags =
|
||||
-D ENV_INCLUDE_INA219=1
|
||||
-D PIN_WIRE_SDA=PB7
|
||||
-D PIN_WIRE_SCL=PB8
|
||||
build_src_filter =
|
||||
+<helpers/sensors/EnvironmentSensorManager.cpp>
|
||||
lib_deps =
|
||||
adafruit/Adafruit INA219 @ ^1.2.3
|
||||
|
||||
[env:LilyGo_T3_STM32_repeater_ina219]
|
||||
extends = env:LilyGo_T3_STM32_repeater
|
||||
build_flags = ${env:LilyGo_T3_STM32_repeater.build_flags}
|
||||
${lilygo_t3_stm32_ina219.build_flags}
|
||||
build_src_filter = ${env:LilyGo_T3_STM32_repeater.build_src_filter}
|
||||
${lilygo_t3_stm32_ina219.build_src_filter}
|
||||
lib_deps = ${lilygo_t3_stm32.lib_deps}
|
||||
${lilygo_t3_stm32_ina219.lib_deps}
|
||||
|
||||
[env:LilyGo_T3_STM32_companion_radio_usb_ina219]
|
||||
extends = env:LilyGo_T3_STM32_companion_radio_usb
|
||||
build_flags = ${env:LilyGo_T3_STM32_companion_radio_usb.build_flags}
|
||||
${lilygo_t3_stm32_ina219.build_flags}
|
||||
build_src_filter = ${env:LilyGo_T3_STM32_companion_radio_usb.build_src_filter}
|
||||
${lilygo_t3_stm32_ina219.build_src_filter}
|
||||
lib_deps = ${env:LilyGo_T3_STM32_companion_radio_usb.lib_deps}
|
||||
${lilygo_t3_stm32_ina219.lib_deps}
|
||||
@@ -1,12 +1,19 @@
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
#if ENV_INCLUDE_INA219
|
||||
#include <Wire.h>
|
||||
#endif
|
||||
#include "target.h"
|
||||
|
||||
LilyGoT3STM32Board board;
|
||||
RADIO_CLASS radio = new STM32WLx_Module();
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
VolatileRTCClock rtc_clock;
|
||||
#if ENV_INCLUDE_INA219
|
||||
EnvironmentSensorManager sensors;
|
||||
#else
|
||||
SensorManager sensors;
|
||||
#endif
|
||||
DISPLAY_CLASS display;
|
||||
// PH3 is also BOOT0: the board's button is active high with an external pull-down.
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, false);
|
||||
@@ -24,6 +31,11 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||
void LilyGoT3STM32Board::begin() {
|
||||
STM32Board::begin();
|
||||
|
||||
#if ENV_INCLUDE_INA219
|
||||
// These builds remap Wire to PB7/PB8; PA9/PA10 are used by USART1.
|
||||
Wire.begin();
|
||||
#endif
|
||||
|
||||
// The SD card shares SPI1 with the OLED; keep it deselected.
|
||||
digitalWrite(PA4, HIGH);
|
||||
pinMode(PA4, OUTPUT);
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
#include <helpers/stm32/STM32Board.h>
|
||||
#include <helpers/radiolib/CustomSTM32WLxWrapper.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#if ENV_INCLUDE_INA219
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
#else
|
||||
#include <helpers/SensorManager.h>
|
||||
#endif
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
|
||||
@@ -20,7 +24,11 @@ public:
|
||||
extern LilyGoT3STM32Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern VolatileRTCClock rtc_clock;
|
||||
#if ENV_INCLUDE_INA219
|
||||
extern EnvironmentSensorManager sensors;
|
||||
#else
|
||||
extern SensorManager sensors;
|
||||
#endif
|
||||
extern DISPLAY_CLASS display;
|
||||
extern MomentaryButton user_btn;
|
||||
|
||||
|
||||
Reference in new issue
Block a user