From afb39aa68080d9d44105e8767508605b94929f03 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 7 Aug 2019 12:08:13 +0200 Subject: [PATCH] Add support for CHIRP soil moisture sensor by Christian Baars Add support for CHIRP soil moisture sensor by Christian Baars --- sonoff/_changelog.ino | 3 ++- sonoff/my_user_config.h | 1 + sonoff/settings.h | 2 +- sonoff/sonoff.h | 3 ++- sonoff/sonoff.ino | 4 ++-- sonoff/sonoff_post.h | 2 +- sonoff/support_features.ino | 4 +++- sonoff/xdrv_04_light.ino | 2 +- sonoff/xdrv_20_hue.ino | 6 +++--- tools/decode-status.py | 5 +++-- 10 files changed, 19 insertions(+), 13 deletions(-) diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 9c2cf54cf..edd41da27 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,8 +1,10 @@ /*********************************************************************************************\ * 6.6.0.4 20190806 + * Add support for CHIRP soil moisture sensor by Christian Baars * * 6.6.0.3 20190725 * Change filename of configuration backup from using FriendlyName1 to Hostname solving diacritic issues (#2422) + * Change Store AWS IoT Private Key and Certificate in SPI Flash avoiding device-specific compilations * Upgrade library IRRemoteEsp8266 to 2.6.4, now using sendPioneer() * Add support for MAX31865 Thermocouple sensor by Alberto Lopez Siemens * Add option 0 to Width1 (Marker), Width2 (Second), Width3 (Minute) and Width4 (Hour) disabling display (#6152) @@ -10,7 +12,6 @@ * Add define USE_ENERGY_MARGIN_DETECTION to disable Energy Margin and Power Limit detection * Add define USE_ENERGY_POWER_LIMIT to disable Energy Power Limit detection while Energy Margin detection is active * Add allow repeat/longpress for IRSend raw, introduced IRSend option (#6074) - * Change Store AWS IoT Private Key and Certificate in SPI Flash avoiding device-specific compilations * Add SetOption68 to enable multi-channel PWM instead of a single light (#6134) * * 6.6.0.2 20190714 diff --git a/sonoff/my_user_config.h b/sonoff/my_user_config.h index 52cf6e199..589068166 100644 --- a/sonoff/my_user_config.h +++ b/sonoff/my_user_config.h @@ -367,6 +367,7 @@ #define USE_ADE7953 // Enable ADE7953 Energy monitor as used on Shelly 2.5 (I2C address 0x38) (+1k5) // #define USE_VL53L0X // Enable VL53L0x time of flight sensor (I2C address 0x29) (+4k code) // #define USE_MLX90614 // Enable MLX90614 ir temp sensor (I2C address 0x5a) (+0.6k code) +// #define USE_CHIRP // Enable CHIRP soil moisture sensor (variable I2C address, default 0x20) // #define USE_DISPLAY // Add I2C Display Support (+2k code) #define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0 diff --git a/sonoff/settings.h b/sonoff/settings.h index c4c5001c2..3b368585f 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -81,7 +81,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t tuya_show_dimmer : 1; // bit 15 (v6.5.0.15) - SetOption65 - Enable or Disable Dimmer slider control uint32_t tuya_dimmer_range_255 : 1; // bit 16 (v6.6.0.1) - SetOption66 - Enable or Disable Dimmer range 255 slider control uint32_t buzzer_enable : 1; // bit 17 (v6.6.0.1) - SetOption67 - Enable buzzer when available - uint32_t pmw_multi_channels : 1; // bit 18 (v6.6.0.3) - SetOption68 - Enable multi-channels PWM insteas of Color PWM + uint32_t pwm_multi_channels : 1; // bit 18 (v6.6.0.3) - SetOption68 - Enable multi-channels PWM instead of Color PWM uint32_t spare19 : 1; uint32_t spare20 : 1; uint32_t spare21 : 1; diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index d79724cc9..f41451781 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -59,7 +59,6 @@ const uint8_t MAX_COUNTERS = 4; // Max number of counter sensors const uint8_t MAX_TIMERS = 16; // Max number of Timers const uint8_t MAX_PULSETIMERS = 8; // Max number of supported pulse timers const uint8_t MAX_FRIENDLYNAMES = 4; // Max number of Friendly names -const uint8_t MAX_HUE_DEVICES = 15; // Max number of Philips Hue device per emulation const uint8_t MAX_DOMOTICZ_IDX = 4; // Max number of Domoticz device, key and switch indices const uint8_t MAX_DOMOTICZ_SNS_IDX = 12; // Max number of Domoticz sensors indices const uint8_t MAX_KNX_GA = 10; // Max number of KNX Group Addresses to read that can be set @@ -72,6 +71,8 @@ const uint8_t MAX_RULE_MEMS = 5; // Max number of saved vars const uint8_t MAX_RULE_SETS = 3; // Max number of rule sets of size 512 characters const uint16_t MAX_RULE_SIZE = 512; // Max number of characters in rules +const uint8_t MAX_HUE_DEVICES = 15; // Max number of Philips Hue device per emulation + const char MQTT_TOKEN_PREFIX[] PROGMEM = "%prefix%"; // To be substituted by mqtt_prefix[x] const char MQTT_TOKEN_TOPIC[] PROGMEM = "%topic%"; // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic const char WIFI_HOSTNAME[] = "%s-%04d"; // Expands to - diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 5e70b87ee..b6d84d618 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -1453,9 +1453,9 @@ void GpioInit(void) #endif // USE_SM16716 // post-process for lights - if (Settings.flag3.pmw_multi_channels) { + if (Settings.flag3.pwm_multi_channels) { uint32_t pwm_channels = (light_type & 7) > LST_MAX ? LST_MAX : (light_type & 7); - if (0 == pwm_channels) pwm_channels = 1; + if (0 == pwm_channels) { pwm_channels = 1; } devices_present += pwm_channels - 1; // add the pwm channels controls at the end } #endif // USE_LIGHT diff --git a/sonoff/sonoff_post.h b/sonoff/sonoff_post.h index 89e6dc4df..1a218311f 100644 --- a/sonoff/sonoff_post.h +++ b/sonoff/sonoff_post.h @@ -131,7 +131,7 @@ void KNX_CB_Action(message_t const &msg, void *arg); #define USE_ADE7953 // Enable ADE7953 Energy monitor as used on Shelly 2.5 (I2C address 0x38) (+1k5) //#define USE_VL53L0X // Enable VL53L0x time of flight sensor (I2C address 0x29) (+4k code) //#define USE_MLX90614 // Enable MLX90614 ir temp sensor (I2C address 0x5a) (+0.6k code) -//#define USE_CHIRP // Enable CHIRP soil moisture sensor (variable I2C address) +//#define USE_CHIRP // Enable CHIRP soil moisture sensor (variable I2C address, default 0x20) #define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code) #define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code) diff --git a/sonoff/support_features.ino b/sonoff/support_features.ino index 73c44a920..0a57eb80b 100644 --- a/sonoff/support_features.ino +++ b/sonoff/support_features.ino @@ -415,7 +415,9 @@ void GetFeatures(void) #ifdef USE_MAX31865 feature_sns2 |= 0x10000000; #endif -// feature_sns2 |= 0x20000000; +#ifdef USE_CHIRP + feature_sns2 |= 0x20000000; +#endif // feature_sns2 |= 0x40000000; // feature_sns2 |= 0x80000000; diff --git a/sonoff/xdrv_04_light.ino b/sonoff/xdrv_04_light.ino index 40f0ff64d..a83264c4a 100644 --- a/sonoff/xdrv_04_light.ino +++ b/sonoff/xdrv_04_light.ino @@ -1359,7 +1359,7 @@ void LightInit(void) light_device = devices_present; light_subtype = (light_type & 7) > LST_MAX ? LST_MAX : (light_type & 7); // Always 0 - LST_MAX (5) - light_pwm_multi_channels = Settings.flag3.pmw_multi_channels; + light_pwm_multi_channels = Settings.flag3.pwm_multi_channels; #if defined(USE_WS2812) && (USE_WS2812_CTYPE > NEO_3LED) if (LT_WS2812 == light_type) { diff --git a/sonoff/xdrv_20_hue.ino b/sonoff/xdrv_20_hue.ino index 42f471907..736b2089b 100644 --- a/sonoff/xdrv_20_hue.ino +++ b/sonoff/xdrv_20_hue.ino @@ -246,7 +246,7 @@ char prev_y_str[24] = "\0"; uint8_t getLocalLightSubtype(uint8_t device) { if (light_type) { if (device >= light_device) { - if (Settings.flag3.pmw_multi_channels) { + if (Settings.flag3.pwm_multi_channels) { return LST_SINGLE; // If SetOption68, each channel acts like a dimmer } else { return light_subtype; // the actual light @@ -511,7 +511,7 @@ void HueLights(String *path) } if (light_type && (local_light_subtype >= LST_SINGLE)) { - if (!Settings.flag3.pmw_multi_channels) { + if (!Settings.flag3.pwm_multi_channels) { light_state.getHSB(&hue, &sat, nullptr); bri = light_state.getBri(); // get the combined bri for CT and RGB, not only the RGB one ct = light_state.getCT(); @@ -614,7 +614,7 @@ void HueLights(String *path) } if (change) { if (light_type && (local_light_subtype > LST_NONE)) { // not relay - if (!Settings.flag3.pmw_multi_channels) { + if (!Settings.flag3.pwm_multi_channels) { if (g_gotct) { light_controller.changeCTB(ct, bri); } else { diff --git a/tools/decode-status.py b/tools/decode-status.py index ad86f46ad..aa8c8c51c 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -116,7 +116,8 @@ a_setoption = [[ "Disable Dimmer slider control", "Disable Dimmer range 255 slider control", "Enable buzzer when available", - "","", + "Enable multi-channels PWM instead of Color PWM", + "", "","","","", "","","","", "","","","" @@ -157,7 +158,7 @@ a_features = [[ "USE_THEO_V2","USE_ALECTO_V2","USE_AZ7798","USE_MAX31855", "USE_PN532_I2C","USE_MAX44009","USE_SCD30","USE_HRE", "USE_ADE7953","USE_SPS30","USE_VL53L0X","USE_MLX90614", - "USE_MAX31865","","",""]] + "USE_MAX31865","USE_CHIRP","",""]] usage = "usage: decode-status {-d | -f} arg" parser = OptionParser(usage)