Compare commits

...

8 Commits

Author SHA1 Message Date
Jorropo
8af9e7fbdc enable long interleaving mode for LR11x0 and SX128x (#9399)
Using long interleaving is not a breaking change, the receiver node is able
to use the lora header to know if LI encoding is used or not and will
decode LI packets correctly.

However the problem is SX127x and other first generation LoRa IP which do not
support LI at all, for theses it is a breaking change.

HOWEVER due to the sync word bug the LR11x0 already can't talk with SX127x,
so if we enable LI on theses no one would be able to tell.
Same for SX128x altho this is because it works on 2.4Ghz which is incompatible with SX127x.

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2026-01-29 06:44:17 -06:00
Andrew Yong
1f7ed6888a feat(stm32): Add Milesight GS301 Bathroom Odor Detector (#9359)
- STM32WLE5CCU6
- NFC (unsupported): NXP NT3H2211W0FTTJ (NTAG I2C plus: NFC Forum T2T with I2C interface, password protection and energy harvesting)
- Sensor (unsupported): Analog ADuCM355 (SHTC3 is connected to ADuCM355 and not directly accessible)
- Bicolor LED
- User button (presently not functional in STM32 variants)

The definitions for sensor voltage control are present but commented out to save power, due to lack of sensor support.

Powered by 4x 4000mAh RAMWAY ER18505 Li-SOCl2 batteries.

Flashing:

1. Power down device (remove batteries)
2. Connect USB-UART to J1 (USART2), pinout is below, do not connect +3V3 pin yet
3. Short BOOT pins next to J1
4. Connect +3V3 pin or insert batteries while BOOT pins are shorted
5. Use STM32CubeProgrammer, connect by UART mode
6. Load firmware .hex and download

J1 (USART2); Molex Picoblade (P=1.25mm * 4)

1. +3V3
2. PA3_USART2_RX_J1
3. PA2_USART2_TX_J1
4. GND

Signed-off-by: Andrew Yong <me@ndoo.sg>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2026-01-29 06:43:48 -06:00
treysis
31bf51b3f2 Add support for the hardware buttons on Bluetooth Nugget device (#9468)
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2026-01-29 06:38:49 -06:00
Justin E. Mann
334a4f04cd Fix logic for rak12035 sensor default config and improve messaging (#9414)
* better logic to check if the RAK12035 soil sensor is calibrated, better log messaging if either of the default values were used.

* .

* changes to how default calibration is done and a message it the default calibration is used pointing to the actual calibration sketch so the user can find it and use it to improve accuracy.

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2026-01-29 06:29:15 -06:00
Ben Meadors
415686dd06 Trunk 2026-01-29 05:56:19 -06:00
Quency-D
b2f2f6b305 Add a watchdog module to meshsolar. (#9337)
* add watchdog module

* Restore the code in power.h

---------

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2026-01-28 20:41:27 -06:00
Jonathan Bennett
df400850c1 Undefine LED_BUILTIN where needed 2026-01-28 18:56:57 -06:00
Jonathan Bennett
6ab2f02dbc re-add unintentionally removed include 2026-01-28 17:53:12 -06:00
25 changed files with 199 additions and 33 deletions

View File

@@ -170,7 +170,7 @@ template <typename T> bool LR11x0Interface<T>::reconfigure()
if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
err = lora.setCodingRate(cr);
err = lora.setCodingRate(cr, cr != 7); // use long interleaving except if CR is 4/7 which doesn't support it
if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);

View File

@@ -126,7 +126,7 @@ template <typename T> bool SX128xInterface<T>::reconfigure()
if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
err = lora.setCodingRate(cr);
err = lora.setCodingRate(cr, cr != 7); // use long interleaving except if CR is 4/7 which doesn't support it
if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);

View File

@@ -1,6 +1,7 @@
#include "configuration.h"
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
#include "buzz/BuzzerFeedbackThread.h"
#include "modules/StatusLEDModule.h"
#include "modules/SystemCommandsModule.h"
#endif
#if !MESHTASTIC_EXCLUDE_PKI
@@ -90,6 +91,9 @@
#include "modules/DropzoneModule.h"
#endif
#if defined(HAS_HARDWARE_WATCHDOG)
#include "watchdog/watchdogThread.h"
#endif
/**
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
*/
@@ -228,6 +232,9 @@ void setupModules()
#if !MESHTASTIC_EXCLUDE_RANGETEST && !MESHTASTIC_EXCLUDE_GPS
if (moduleConfig.has_range_test && moduleConfig.range_test.enabled)
new RangeTestModule();
#endif
#if defined(HAS_HARDWARE_WATCHDOG)
watchdogThread = new WatchdogThread();
#endif
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra
// acks

View File

@@ -26,7 +26,7 @@ bool RAK12035Sensor::initDevice(TwoWire *bus, ScanI2C::FoundDevice *dev)
sensor.get_sensor_version(&data);
if (data != 0) {
LOG_INFO("Init sensor: %s", sensorName);
LOG_INFO("RAK12035Sensor Init Succeed \nSensor1 Firmware version: %i, Sensor Name: %s", data, sensorName);
LOG_INFO("RAK12035Sensor Init Succeed \nSensor Firmware version: %i, Sensor Name: %s", data, sensorName);
status = true;
sensor.sensor_sleep();
RESTORE_3V3_POWER();
@@ -49,33 +49,39 @@ void RAK12035Sensor::setup()
// TODO:: Check for and run calibration check for up to 2 additional sensors if present.
uint16_t zero_val = 0;
uint16_t hundred_val = 0;
uint16_t default_zero_val = 550;
uint16_t default_hundred_val = 420;
const uint16_t default_zero_val = 510;
const uint16_t default_hundred_val = 390;
sensor.sensor_on();
sensor.begin();
delay(200);
sensor.get_dry_cal(&zero_val);
delay(200);
sensor.get_wet_cal(&hundred_val);
delay(200);
if (zero_val == 0 || zero_val <= hundred_val) {
LOG_INFO("Dry calibration value is %d", zero_val);
LOG_INFO("Wet calibration value is %d", hundred_val);
LOG_INFO("This does not make sense. You can recalibrate this sensor using the calibration sketch included here: "
"https://github.com/RAKWireless/RAK12035_SoilMoisture.");
LOG_INFO("For now, setting default calibration value for Dry Calibration: %d", default_zero_val);
bool calibrationReset = false;
if (zero_val == 0) {
LOG_INFO("Dry calibration not set, using default: %d", default_zero_val);
sensor.set_dry_cal(default_zero_val);
sensor.get_dry_cal(&zero_val);
LOG_INFO("Dry calibration reset complete. New value is %d", zero_val);
delay(200);
zero_val = default_zero_val;
calibrationReset = true;
}
if (hundred_val == 0 || hundred_val >= zero_val) {
LOG_INFO("Dry calibration value is %d", zero_val);
LOG_INFO("Wet calibration value is %d", hundred_val);
LOG_INFO("This does not make sense. You can recalibrate this sensor using the calibration sketch included here: "
"https://github.com/RAKWireless/RAK12035_SoilMoisture.");
LOG_INFO("For now, setting default calibration value for Wet Calibration: %d", default_hundred_val);
LOG_INFO("Wet calibration not set, using default: %d", default_hundred_val);
sensor.set_wet_cal(default_hundred_val);
sensor.get_wet_cal(&hundred_val);
LOG_INFO("Wet calibration reset complete. New value is %d", hundred_val);
delay(200);
hundred_val = default_hundred_val;
calibrationReset = true;
}
if (calibrationReset) {
LOG_INFO("Default calibration values applied. Consider running the calibration sketch for better accuracy: "
"https://github.com/RAKWireless/RAK12035_SoilMoisture");
}
LOG_INFO("Dry calibration value: %d, Wet calibration value: %d", zero_val, hundred_val);
sensor.sensor_sleep();
RESTORE_3V3_POWER();
delay(200);

View File

@@ -0,0 +1,37 @@
#include "watchdogThread.h"
#include "configuration.h"
#ifdef HAS_HARDWARE_WATCHDOG
WatchdogThread *watchdogThread;
WatchdogThread::WatchdogThread() : OSThread("Watchdog")
{
setup();
}
void WatchdogThread::feedDog(void)
{
digitalWrite(HARDWARE_WATCHDOG_DONE, HIGH);
delay(1);
digitalWrite(HARDWARE_WATCHDOG_DONE, LOW);
}
int32_t WatchdogThread::runOnce()
{
LOG_DEBUG("Feeding hardware watchdog");
feedDog();
return HARDWARE_WATCHDOG_TIMEOUT_MS;
}
bool WatchdogThread::setup()
{
LOG_DEBUG("init hardware watchdog");
pinMode(HARDWARE_WATCHDOG_WAKE, INPUT);
pinMode(HARDWARE_WATCHDOG_DONE, OUTPUT);
delay(1);
digitalWrite(HARDWARE_WATCHDOG_DONE, LOW);
delay(1);
feedDog();
return true;
}
#endif

View File

@@ -0,0 +1,17 @@
#pragma once
#include "concurrency/OSThread.h"
#include <stdint.h>
#ifdef HAS_HARDWARE_WATCHDOG
class WatchdogThread : private concurrency::OSThread
{
public:
WatchdogThread();
void feedDog(void);
virtual bool setup();
virtual int32_t runOnce() override;
};
extern WatchdogThread *watchdogThread;
#endif

View File

@@ -8,6 +8,7 @@ build_flags =
-I variants/esp32/chatter2
-DMESHTASTIC_EXCLUDE_WEBSERVER=1
-DMESHTASTIC_EXCLUDE_PAXCOUNTER=1
-ULED_BUILTIN
lib_deps =
${esp32_base.lib_deps}

View File

@@ -14,3 +14,4 @@ build_flags =
${esp32_base.build_flags}
-D DIY_V1
-I variants/esp32/diy/hydra
-ULED_BUILTIN

View File

@@ -17,3 +17,4 @@ build_flags =
-D DIY_V1
-D EBYTE_E22
-I variants/esp32/diy/v1
-ULED_BUILTIN

View File

@@ -14,3 +14,4 @@ build_flags =
${esp32_base.build_flags}
-D NANO_G1_EXPLORER
-I variants/esp32/nano-g1-explorer
-ULED_BUILTIN

View File

@@ -14,3 +14,4 @@ build_flags =
${esp32_base.build_flags}
-D NANO_G1
-I variants/esp32/nano-g1
-ULED_BUILTIN

View File

@@ -9,6 +9,7 @@ build_flags =
-DHAS_STK8XXX=1
-O2
-I variants/esp32/radiomaster_900_bandit
-ULED_BUILTIN
board_build.f_cpu = 240000000L
upload_protocol = esptool
lib_deps =

View File

@@ -13,5 +13,6 @@ build_flags =
-DCONFIG_DISABLE_HAL_LOCKS=1
-O2
-I variants/esp32/radiomaster_900_bandit_nano
-ULED_BUILTIN
board_build.f_cpu = 240000000L
upload_protocol = esptool

View File

@@ -16,5 +16,6 @@ build_flags =
-DCONFIG_DISABLE_HAL_LOCKS=1
-O2
-I variants/esp32/radiomaster_900_bandit_nano
-ULED_BUILTIN
board_build.f_cpu = 240000000L
upload_protocol = esptool

View File

@@ -14,3 +14,4 @@ build_flags =
${esp32_base.build_flags}
-D STATION_G1
-I variants/esp32/station-g1
-ULED_BUILTIN

View File

@@ -12,7 +12,7 @@ extends = esp32_base
board = ttgo-lora32-v21
board_check = true
build_flags =
${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/esp32/tlora_v2_1_16
${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/esp32/tlora_v2_1_16 -ULED_BUILTIN
upload_speed = 115200
[env:sugarcube]

View File

@@ -7,3 +7,4 @@ build_flags =
-I variants/esp32/tlora_v2_1_16
-D LORA_TCXO_GPIO=12
-D BUTTON_PIN=0
-ULED_BUILTIN

View File

@@ -6,4 +6,5 @@ board_build.partitions = default_8MB.csv
build_flags =
${esp32s3_base.build_flags} -I variants/esp32s3/heltec_capsule_sensor_v3
-D HELTEC_CAPSULE_SENSOR_V3
-ULED_BUILTIN
;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output

View File

@@ -7,6 +7,7 @@ build_flags =
${esp32s3_base.build_flags}
-I variants/esp32s3/heltec_sensor_hub
-D HELTEC_SENSOR_HUB
-ULED_BUILTIN
lib_deps = ${esp32s3_base.lib_deps}
# renovate: datasource=custom.pio depName=NeoPixel packageName=adafruit/library/Adafruit NeoPixel

View File

@@ -17,3 +17,4 @@ build_flags =
${esp32s3_base.build_flags}
-D HELTEC_WSL_V3
-I variants/esp32s3/heltec_wsl_v3
-ULED_BUILTIN

View File

@@ -12,7 +12,7 @@
#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use
// Button A (44), B (43), R (12), U (13), L (11), D (18)
#define BUTTON_PIN 44 // If defined, this will be used for user button presses
#define BUTTON_PIN 43 // If defined, this will be used for user button presses
#define BUTTON_NEED_PULLUP
#define USE_RF95
@@ -20,8 +20,19 @@
#define LORA_MISO 7
#define LORA_MOSI 8
#define LORA_CS 9
#define LORA_DIO0 16 // a No connect on the SX1262 module
#define LORA_DIO0 16
#define LORA_RESET 4
#define LORA_DIO1 RADIOLIB_NC
#define LORA_DIO2 RADIOLIB_NC
// jk, its not really a trackball but we're gonna pretend!
#define HAS_TRACKBALL 1
#define TB_UP 13
#define TB_DOWN 18
#define TB_LEFT 11
#define TB_RIGHT 12
#define TB_PRESS 44 // BUTTON_PIN
#define TB_DIRECTION FALLING
#define ENABLE_AMBIENTLIGHTING

View File

@@ -39,15 +39,15 @@ extern "C" {
#define NUM_ANALOG_INPUTS (1)
#define NUM_ANALOG_OUTPUTS (0)
#define PIN_LED1 (0 + 4) // green (confirmed on 1.0 board)
#define PIN_LED1 (32 + 15) // green (confirmed on 1.0 board)
#define LED_BLUE PIN_LED1 // fake for bluefruit library
#define LED_GREEN PIN_LED1
#define LED_STATE_ON 0 // State when LED is lit
#define HAS_NEOPIXEL // Enable the use of neopixels
#define NEOPIXEL_COUNT 1 // How many neopixels are connected
#define NEOPIXEL_DATA (32 + 15) // gpio pin used to send data to the neopixels
#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use
// #define HAS_NEOPIXEL // Enable the use of neopixels
// #define NEOPIXEL_COUNT 1 // How many neopixels are connected
// #define NEOPIXEL_DATA (32 + 15) // gpio pin used to send data to the neopixels
// #define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use
/*
* Buttons
@@ -59,8 +59,8 @@ extern "C" {
/*
No longer populated on PCB
*/
#define PIN_SERIAL2_RX (0 + 9)
#define PIN_SERIAL2_TX (0 + 10)
#define PIN_SERIAL2_RX (-1)
#define PIN_SERIAL2_TX (-1)
/*
* I2C
@@ -137,6 +137,12 @@ No longer populated on PCB
// To debug via the segger JLINK console rather than the CDC-ACM serial device
// #define USE_SEGGER
// Hardware watchdog
#define HAS_HARDWARE_WATCHDOG
#define HARDWARE_WATCHDOG_DONE (0 + 9)
#define HARDWARE_WATCHDOG_WAKE (0 + 10)
#define HARDWARE_WATCHDOG_TIMEOUT_MS (6 * 60 * 1000) // 6 minute watchdog
#define BQ4050_SDA_PIN (32 + 1) // I2C data line pin
#define BQ4050_SCL_PIN (32 + 0) // I2C clock line pin
#define BQ4050_EMERGENCY_SHUTDOWN_PIN (32 + 3) // Emergency shutdown pin

View File

@@ -0,0 +1,21 @@
; Milesight GS301 Bathroom Odor Detector
; https://www.milesight.com/iot/product/lorawan-sensor/gs301
[env:milesight_gs301]
extends = stm32_base
board = wiscore_rak3172 ; Convenient choice as the same USART is used for programming/debug
board_level = extra
board_upload.maximum_size = 233472 ; reserve the last 28KB for filesystem
build_flags =
${stm32_base.build_flags}
-Ivariants/stm32/milesight_gs301
-DPRIVATE_HW
-DMESHTASTIC_EXCLUDE_GPS=1
-DMESHTASTIC_EXCLUDE_I2C=1 # Analog ADuCM355 (unsupported) so no point building support for I2C in
-DMESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1
-DMESHTASTIC_EXCLUDE_AIR_QUALITY_SENSOR=1
build_unflags =
-DDEBUG_MUTE # We have space for debug output until sensor support is added
lib_deps =
${stm32_base.lib_deps}
upload_port = stlink

View File

@@ -0,0 +1,7 @@
// Seems to use the same RF switch pins as RAK3172… getting Tx/Rx SNR +11dB with a nearby node
// PB8, PC13
static const RADIOLIB_PIN_TYPE rfswitch_pins[5] = {PB8, PC13, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC};
static const Module::RfSwitchMode_t rfswitch_table[4] = {
{STM32WLx::MODE_IDLE, {LOW, LOW}}, {STM32WLx::MODE_RX, {HIGH, LOW}}, {STM32WLx::MODE_TX_HP, {LOW, HIGH}}, END_OF_MODE_TABLE};

View File

@@ -0,0 +1,41 @@
#ifndef _VARIANT_MILESIGHT_GS301_
#define _VARIANT_MILESIGHT_GS301_
#define USE_STM32WLx
// I/O
#define LED_STATE_ON 1
#define PIN_LED1 PA0 // Green LED
#define LED_PIN PIN_LED1
#define PIN_LED2 PA0 // Red LED
#define USER_LED PIN_LED2
#define BUTTON_PIN PC13
#define BUTTON_ACTIVE_LOW true
#define BUTTON_ACTIVE_PULLUP false
#define PIN_BUZZER PA6
// EC Sense DGM10 Double Gas Module
// Analog ADuCM355 (unsupported); SHTC3 is connected to ADuCM355 and not directly accessible
#define PIN_WIRE_SDA PB7
#define PIN_WIRE_SCL PB8
// Commented out to keep sensor powered down due to lack of support
/*
#define VEXT_ENABLE PB12 // TI TPS61291DRV VSEL - set LOW before ENable for Vout = 3.3V
#define VEXT_ON_VALUE LOW
#define SENSOR_POWER_CTRL_PIN PB2 // TI TPS61291DRV EN pin
#define SENSOR_POWER_ON HIGH
#define HAS_SENSOR 1
*/
#define ENABLE_HWSERIAL1
#define PIN_SERIAL1_RX NC
#define PIN_SERIAL1_TX PB6
// LoRa
#define SX126X_DIO3_TCXO_VOLTAGE 3.0
// Required to avoid Serial1 conflicts due to board definition here:
// https://github.com/stm32duino/Arduino_Core_STM32/blob/main/variants/STM32WLxx/WL54CCU_WL55CCU_WLE4C(8-B-C)U_WLE5C(8-B-C)U/variant_RAK3172_MODULE.h
#define RAK3172
#endif