diff --git a/html/config.htm b/html/config.htm index ce6fb2c..5b3a1c6 100644 --- a/html/config.htm +++ b/html/config.htm @@ -937,7 +937,7 @@ setButtonDisabled( true ); var url = "/api/config"; - var url = "/test/config.json"; + //var url = "/test/config.json"; $('#spinner').show(); $.getJSON(url, function (cfg) { console.log( cfg ); diff --git a/html/config.min.htm b/html/config.min.htm index c56a5a9..671e73c 100644 --- a/html/config.min.htm +++ b/html/config.min.htm @@ -1 +1 @@ -Beer Gravity Monitor

Temperature Format



(10-100) - default 50
(50-1000) - default 500
(1 - 10) - default 3 SG
(0 - 100) - default 20C/68F

(9 - 12) - default 9 bits

(1 - 60) - default 20 s
(10 - 240) - default 120 s

(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file +Beer Gravity Monitor

Temperature Format



(10-100) - default 50
(50-1000) - default 500
(1 - 10) - default 3 SG
(0 - 100) - default 20C/68F

(9 - 12) - default 9 bits

(1 - 60) - default 20 s
(10 - 240) - default 120 s

(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(0 - 5) - default 0
(C) Copyright 2021-22 Magnus Persson
\ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 06801d4..a0825ad 100644 --- a/platformio.ini +++ b/platformio.ini @@ -117,6 +117,9 @@ build_flags = #-DCORE_DEBUG_LEVEL=0 ${common_env_data.build_flags} -D LOG_LEVEL=5 + -DESP32D1 + -DCORE_DEBUG_LEVEL=0 + #-DUSE_SERIAL_PINS # Use the TX/RX pins for the serial port lib_deps = ${common_env_data.lib_deps} ${common_env_data.lib_deps32} diff --git a/src/helper.cpp b/src/helper.cpp index 9f47fbb..4b34547 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -250,8 +250,10 @@ SerialDebug::SerialDebug(const uint32_t serialSpeed) { EspSerial.begin(115200L, SERIAL_8N1, 37, 39); #elif defined(ESP32S2) EspSerial.begin(115200L); +#elif defined(USE_SERIAL_PINS) && defined(ESP32LITE) + EspSerial.begin(serialSpeed, SERIAL_8N1, 16, 17); #elif defined(USE_SERIAL_PINS) && defined(ESP32) - EspSerial.begin(serialSpeed, SERIAL_8N1, 3, 1); + EspSerial.begin(serialSpeed, SERIAL_8N1, 1, 3); #elif defined(ESP32) EspSerial.begin(115200L); #endif @@ -269,6 +271,21 @@ void printTimestamp(Print* _logOutput, int _logLevel) { _logOutput->print(c); } +bool checkPinConnected() { +#if defined(ESP8266) + pinMode(PIN_CFG1, INPUT); +#else + pinMode(PIN_CFG1, INPUT_PULLDOWN); +#endif + pinMode(PIN_CFG2, OUTPUT); + delay(5); + digitalWrite(PIN_CFG2, 1); + delay(5); + int i = digitalRead(PIN_CFG1); + digitalWrite(PIN_CFG2, 0); + return i == LOW ? false : true; +} + BatteryVoltage::BatteryVoltage() { #if defined(ESP8266) pinMode(PIN_VOLT, INPUT); diff --git a/src/helper.hpp b/src/helper.hpp index cf2f01c..622e27d 100644 --- a/src/helper.hpp +++ b/src/helper.hpp @@ -43,6 +43,9 @@ void checkResetReason(); // Sleep mode void deepSleep(int t); +// Force config mode +bool checkPinConnected(); + // Show build options void printBuildOptions(); diff --git a/src/main.cpp b/src/main.cpp index fa51d32..17a2731 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -137,6 +137,7 @@ void setup() { // Add a delay so that serial is started. // delay(3000); #endif + delay(2000); // Main startup #if defined(ESP8266) @@ -163,6 +164,11 @@ void setup() { myAdvancedConfig.loadFile(); LOG_PERF_STOP("main-config-load"); + sleepModeAlwaysSkip = checkPinConnected(); + if (sleepModeAlwaysSkip) { + Log.notice(F("Main: Forcing config mode since D7/D8 are connected." CR)); + } + // Setup watchdog #if defined(ESP8266) ESP.wdtDisable(); @@ -331,7 +337,7 @@ bool loopReadGravity() { } return true; } else { - Log.error(F("MAIN: No gyro value found, the device might be moving." CR)); + // Log.error(F("MAIN: No gyro value found, the device might be moving." CR)); } return false; } diff --git a/src/main.hpp b/src/main.hpp index 64f25a7..7b8a77e 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -44,6 +44,8 @@ extern RunMode runMode; #define ESP_RESET ESP.reset #define PIN_SDA D3 #define PIN_SCL D4 +#define PIN_CFG1 D8 +#define PIN_CFG2 D7 #define PIN_DS D6 #define PIN_LED 2 #define PIN_VOLT PIN_A0 @@ -65,6 +67,8 @@ extern RunMode runMode; #define PIN_SDA 7 #define PIN_SCL 6 #endif // JTAG_DEBUG +#define PIN_CFG1 A5 +#define PIN_CFG2 A4 #define PIN_DS A3 #define PIN_VOLT A0 // This should be the LED_BUILTIN, but that is also connected SDA (Gyro) so we @@ -82,6 +86,8 @@ extern RunMode runMode; #define ESP8266WebServer WebServer #define PIN_SDA A17 #define PIN_SCL A15 +#define PIN_CFG1 A11 +#define PIN_CFG2 A10 #define PIN_DS A8 #define PIN_VOLT A2 #define PIN_LED LED_BUILTIN @@ -99,6 +105,8 @@ extern RunMode runMode; #define PIN_SCL A19 #define PIN_DS A3 #define PIN_VOLT A7 +#define PIN_CFG1 A14 +#define PIN_CFG2 A13 #define PIN_VCC A5 #define PIN_GND A18 #define PIN_LED LED_BUILTIN @@ -115,11 +123,13 @@ extern RunMode runMode; #define PIN_SDA D3 #define PIN_SCL D4 #define PIN_DS D6 +#define PIN_CFG1 D8 +#define PIN_CFG2 D7 #define PIN_LED LED_BUILTIN #define PIN_VOLT PIN_A0 #endif -#if defined(USE_SERIAL_PINS) && defined(ESP32) +#if defined(USE_SERIAL_PINS) && ( defined(ESP32C3) || defined(ESP32S2) ) // #define EspSerial Serial0 // We cant use Serial on newer boards since this is // using USBC port #define EspSerial \ diff --git a/src_docs/source/hardware.rst b/src_docs/source/hardware.rst index 8698457..f6e98a8 100644 --- a/src_docs/source/hardware.rst +++ b/src_docs/source/hardware.rst @@ -20,6 +20,7 @@ Schema for esp8266 build :width: 700 :alt: Schema esp8266 + iSpindle based on esp32 ======================= @@ -114,3 +115,25 @@ this hardware platform as well but there are a few limitations: * Temperature is read from the GYRO and cannot be changed. This works fine when measuring gravity but when in configuration mode the temperature will increase since it shows the chip temperature. * No possibility to measure battery level (can be added with additional hardware). + + +Hardware extensions +=================== + +GravityMon has implemented a few additions to the standard iSpindel hardware. It's possible to channel the serial console to the TX/RX pins on the chip (these position also applies to all the +ESP32 chips for iSpindel). You need a USB to TTL converter for this to work. This enables you to read the serial console even when on battery (newer chips dont have a diode to remove). + +.. note:: + You need to compile the software using the -DUSE_SERIAL_PINS option to enable this feature. + +Its also possible to force the device into configuration mode by connecting D7/D8 on the board during the startup sequence. This will enable the feature "gravity mode enabled during float". + +.. image:: images/8266_pins.jpg + :width: 500 + :alt: iSpindel pins + +For the floaty device pins 16/17 are used as TX/RX pins and the 13/15 pins are used to force the device into configuration mode. Pin 35 can also be connected to the battery voltage via an voltage divider to be able to read the battery voltage. + +.. image:: images/32lite_pins.jpg + :width: 500 + :alt: Floaty pins diff --git a/src_docs/source/images/32lite_pins.jpg b/src_docs/source/images/32lite_pins.jpg new file mode 100644 index 0000000..be2c79f Binary files /dev/null and b/src_docs/source/images/32lite_pins.jpg differ diff --git a/src_docs/source/images/8266_pins.jpg b/src_docs/source/images/8266_pins.jpg new file mode 100644 index 0000000..daf2e5f Binary files /dev/null and b/src_docs/source/images/8266_pins.jpg differ