diff --git a/docs/12.HarddwareSONOFF.md b/docs/12.HarddwareSONOFF.md deleted file mode 100644 index d183ea98c..000000000 --- a/docs/12.HarddwareSONOFF.md +++ /dev/null @@ -1,9 +0,0 @@ -BrewPiLess can run on [SONOFF Basic](https://www.itead.cc/wiki/Sonoff) and [SONOFF TH10/16](https://www.itead.cc/wiki/Sonoff_TH_10/16). You will need to solder the header pins for the first flashing and install temperature sensors. However, because of the small 1M byte flash memory, you will either sacrifice -* OTA web update for log storage, or -* 500k log storage for OTA update -* LCD is not available. - -SONOFF dual is not supported, because the Relays are controlled by Serial instead of GPIO.Instead, SONOFF Dual **R2** should work by specify correct PINs. - -Please note that some older SONOFFs, maybe before 2018, use ESP8266 while new ones use ESP8285. Right configuration must be used. - diff --git a/docs/12.HardwareSONOFF.md b/docs/12.HardwareSONOFF.md new file mode 100644 index 000000000..6cf62a3e3 --- /dev/null +++ b/docs/12.HardwareSONOFF.md @@ -0,0 +1,23 @@ +BrewPiLess can run on [SONOFF Basic](https://www.itead.cc/wiki/Sonoff) and [SONOFF TH10/16](https://www.itead.cc/wiki/Sonoff_TH_10/16). You will need to solder the header pins for the first flashing and install temperature sensors. However, because of the small 1M byte flash memory, you will either sacrifice +* OTA web update for log storage, or +* 500k log storage for OTA update +* LCD is not available. + +SONOFF dual is not supported, because the Relays are controlled by Serial instead of GPIO.Instead, SONOFF Dual **R2** should work by specify correct PINs. + +Please note that some older SONOFFs, maybe before 2018, use ESP8266 while new ones use ESP8285. Right configuration must be used. + +### ESP32 SonOff devices (Sonoff TH Origin and Sonoff TH Elite) + +For Sonoff TH Elite the built-in lcd display can be removed and a OLED LCD screen can be connected in it's place.. Use electrical tape to make sure that the LCD pcb is not touching the main pcb. The front glass is a thin plastic be gentle with it. + +#### Conntecting sensor +The sensor that has the RJ9 connector comes with a controller in the wire that needs to be removed +Option 1: Remove the controller and reconntect the wires (not tested). +Option 2: Use `Sonoff AL010 2.5mm Audio Jack to RJ9 Adapter` with the old sensor using the audio jack conntector. + +##### Connecting OLED LCD (optional) +* Connect SDA to WR solder pad +* Connect SCL to CS solder pad +* Use hotglue over soldered contacts so that you don't ripoff the solder pads accidentally. +* Connect 3v and Gnd to corresponding solderpads diff --git a/docs/README.md b/docs/README.md index 342505ee8..bae696b81 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ * [Hardware Setup](10.HardwareGeneral.md) * [Example#1](11.HardwareExample1.md) - * [SONOFF](12.HarddwareSONOFF.md) + * [SONOFF](12.HardwareSONOFF.md) * [Thorrax’s Board](https://github.com/thorrak/brewpi-esp8266) * [ESP32](13.ESP32Pins.md) * [ESP32 Build](14.ESP32BuildInstructions.md) diff --git a/platformio.ini b/platformio.ini index 615f1178b..136747fbf 100644 --- a/platformio.ini +++ b/platformio.ini @@ -135,7 +135,27 @@ lib_extra_dirs = ${common_env_data.esp32_lib} board_build.partitions = ./partition2.csv build_flags = - -DOLED_LCD=true + -DOLED_LCD=true + +monitor_speed = 115200 +lib_deps = ${common_env_data.lib_deps_external_esp32} + +[env:esp32-sonoff] # for newgen sonoff devices like sonoff elite and origin +platform = ${common_env_data.esp32_framework} +board = esp32dev +framework = arduino +board_build.mcu = esp32 +lib_extra_dirs = ${common_env_data.esp32_lib} + +board_build.partitions = ./partition2.csv + +build_flags = + -DOLED_LCD=true + -DSerialDebug=false + -DEnableHumidityControlSupport=false + -DEanbleParasiteTempControl=false + -DEnableBME280Support=false + -DSONOFF_NEWGEN=true monitor_speed = 115200 lib_deps = ${common_env_data.lib_deps_external_esp32} diff --git a/src/BrewPiLess.cpp b/src/BrewPiLess.cpp index b13880e57..644f47246 100644 --- a/src/BrewPiLess.cpp +++ b/src/BrewPiLess.cpp @@ -1702,7 +1702,12 @@ void handleReset() void brewpi_setup() { - + if (SONOFF_NEWGEN) { + pinMode(sensorPowerPin, OUTPUT); // Power for sonoff temp sensor + digitalWrite(sensorPowerPin, HIGH); + pinMode(powerIndicatorPin, OUTPUT); + digitalWrite(powerIndicatorPin, LOW); // Red power led + } #if defined(ESP8266) // We need to initialize the EEPROM on ESP8266 EEPROM.begin(MAX_EEPROM_SIZE_LIMIT); diff --git a/src/Config.h b/src/Config.h index e9f0da046..8d73fc7b1 100644 --- a/src/Config.h +++ b/src/Config.h @@ -313,6 +313,10 @@ #endif +#ifndef SONOFF_NEWGEN +#define SONOFF_NEWGEN false +#endif + #if ESP32 #define FS_EEPROM true #endif @@ -344,6 +348,21 @@ // pins #ifdef ESP32 +#if SONOFF_NEWGEN + +#define PIN_SCL 17 // TM1621 CS +#define PIN_SDA 18 // TM1621 WR + + +#define oneWirePin 25 + +#define actuatorPin1 21 // This is relay 1 +#define actuatorPin2 23 // TM1621 RD +#define actuatorPin3 5 // TM1621 DAT +#define actuatorPin4 24 +#define actuatorPin5 26 +#else // SONOFF_NEWGEN ends + #define PIN_SDA 21 #define PIN_SCL 22 @@ -356,6 +375,8 @@ #define actuatorPin4 27 #define actuatorPin5 26 +#endif + #if MORE_PINS_CONFIGURATION #define actuatorPin6 18 @@ -368,14 +389,20 @@ #else #define BuzzPin 18 #endif + // 34,35,66,39 input only #define rotaryAPin 32 #define rotaryBPin 33 +#if SONOFF_NEWGEN +#define rotarySwitchPin 35 +#else #define rotarySwitchPin 25 +#endif // Only ADC1 (pin 32~39) is allowed #define PressureAdcPin 36 + #else // #ifdef ESP32 #define NODEMCU_PIN_A0 17 // Analog diff --git a/src/Pins.h b/src/Pins.h index 74e6aa44c..4ed5e2946 100644 --- a/src/Pins.h +++ b/src/Pins.h @@ -97,6 +97,21 @@ #define fridgeSensorPin 11 #endif #endif + +#if SONOFF_NEWGEN +#ifndef powerIndicatorPin +#define powerIndicatorPin 16 +#endif +#ifndef relayIndicatorPin +#define relayIndicatorPin 13 +#endif +#ifndef wifiIndicatorPin +#define wifiIndicatorPin 15 +#endif +#ifndef sensorPowerPin +#define sensorPowerPin 27 +#endif +#endif // Pay attention when changing the pins for the rotary encoder. // They should be connected to external interrupt INT0, INT1 and INT3 diff --git a/src/TempControl.cpp b/src/TempControl.cpp index 5f7b87dbf..bb7a0954a 100644 --- a/src/TempControl.cpp +++ b/src/TempControl.cpp @@ -31,6 +31,7 @@ #include "EepromManager.h" #include "TempSensorDisconnected.h" #include "RotaryEncoder.h" +#include "Config.h" TempControl tempControl; @@ -77,6 +78,9 @@ uint16_t TempControl::waitTime; #endif void TempControl::init(void){ + if (SONOFF_NEWGEN) { + pinMode(relayIndicatorPin, OUTPUT); + } state=IDLE; cs.mode = MODE_OFF; @@ -398,6 +402,12 @@ void TempControl::updateOutputs(void) { heater->setActive(!cc.lightAsHeater && heating); light->setActive(isDoorOpen() || (cc.lightAsHeater && heating) || cameraLightState.isActive()); fan->setActive(heating || cooling); + if (SONOFF_NEWGEN && (heating || cooling)) { + digitalWrite(relayIndicatorPin, LOW); + } + else { + digitalWrite(relayIndicatorPin, HIGH); + } } diff --git a/src/WiFiSetup.cpp b/src/WiFiSetup.cpp index fda2ae1dd..62cbecb02 100644 --- a/src/WiFiSetup.cpp +++ b/src/WiFiSetup.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "Pins.h" #endif //needed for library @@ -83,7 +84,9 @@ bool WiFiSetupClass::isApMode(){ void WiFiSetupClass::begin(WiFiMode mode, char const *ssid,const char *passwd,char const* targetSSID,const char *targetPass) { wifi_info("begin:"); - + if(SONOFF_NEWGEN) { + pinMode(wifiIndicatorPin, OUTPUT); // Blue Wifi led + } if(targetSSID && targetSSID[0]){ if(_targetSSID) free((void*)_targetSSID); _targetSSID=strdup(targetSSID); @@ -192,6 +195,9 @@ String WiFiSetupClass::status(void){ bool WiFiSetupClass::stayConnected(void) { + if(SONOFF_NEWGEN) { + digitalWrite(wifiIndicatorPin, HIGH); + } if(WiFi.getMode() == WIFI_AP || WiFi.getMode() == WIFI_AP_STA){ dnsServer->processNextRequest(); // if(_mode == WIFI_AP) return true; @@ -342,6 +348,9 @@ bool WiFiSetupClass::stayConnected(void) } // WiFi.status() != WL_CONNECTED else // connected { + if(SONOFF_NEWGEN) { + digitalWrite(wifiIndicatorPin, LOW); + } if(_mode == WIFI_AP){ DBG_PRINTF("Connected in AP_mode\n"); }else{