Skip to content

Commit 470a7e0

Browse files
authored
v2.2
1 parent 6cc24d1 commit 470a7e0

File tree

13 files changed

+2596
-1255
lines changed

13 files changed

+2596
-1255
lines changed

ESP32_SpecificGravity.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ static bool startedUp = false;
3030

3131
void setup() {
3232
logSetup();
33-
startStorage();
34-
loadConfig();
33+
// prep SD card storage & load saved user configuration
34+
if (startStorage()) loadConfig();
3535

3636
#ifdef DEV_ONLY
3737
devSetup();
@@ -44,9 +44,7 @@ void setup() {
4444
if (strlen(startupFailure)) LOG_ERR("%s", startupFailure);
4545
else {
4646
// start rest of services
47-
SGsetup();
48-
LOG_INF(APP_NAME " v" APP_VER " ready ...");
49-
startedUp = true;
47+
if (SGsetup()) startedUp = true;
5048
checkMemory();
5149
}
5250
}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ The generated data is packaged into a json string, this data can be viewed:
1414
On power up, ESP32 will remain awake for calibration purposes (see below) until user presses the __Start__ button on the web page.
1515
The ESP32 will then periodically wakeup to collect data and send this to the remote host, then return to deep sleep.
1616

17+
## Installation
18+
19+
Download github files into the Arduino IDE sketch folder, removing `-main` from the application folder name.
20+
21+
Compile with PSRAM enabled and the following Partition scheme:
22+
* ESP32-S3 - `8M with spiffs (...)`
23+
* ESP32 - `Minimal SPIFFS (...)`
24+
25+
On first installation, the application will start in wifi AP mode - connect to SSID: **ESP32_SG_...**, to allow router and password details to be entered via the web page on `192.168.4.1`. The configuration data file (except passwords) is automatically created, and the application web pages automatically downloaded from GitHub to the SD card **/data** folder when an internet connection is available.
26+
27+
Subsequent updates to the application, or to the **/data** folder files, can be made using the **OTA Upload** tab. The **/data** folder can also be reloaded from GitHub using the **Reload /data** button on the **Edit Config** tab, or by using a WebDAV client.
28+
1729
## Setup and Calibration
1830

1931
The ESP32 and GY-521 modules fit snugly into a 33mm width x 120mm height PETling:

appGlobals.h

Lines changed: 78 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,75 +8,120 @@
88
#define ALLOW_SPACES false // set true to allow whitespace in configs.txt key values
99

1010
// web server ports
11-
#define WEB_PORT 80 // app control
12-
#define OTA_PORT (WEB_PORT + 1) // OTA update
11+
#define HTTP_PORT 80 // app access
12+
#define HTTPS_PORT 443 // secure app access
1313

1414
/*********************** Fixed defines leave as is ***********************/
1515
/** Do not change anything below here unless you know what you are doing **/
1616

1717
//#define DEV_ONLY // leave commented out
1818
#define STATIC_IP_OCTAL "123" // dev only
19-
#define CHECK_MEM false // leave as false
20-
#define FLUSH_DELAY 200 // for debugging crashes
21-
19+
#define DEBUG_MEM false // leave as false
20+
#define FLUSH_DELAY 0 // for debugging crashes
21+
#define DBG_ON false // esp debug output
22+
#define DOT_MAX 50
23+
#define HOSTNAME_GRP 0
24+
2225
#define APP_NAME "ESP32_SG" // max 15 chars
23-
#define APP_VER "1.2"
26+
#define APP_VER "2.2"
2427

25-
#define MAX_CLIENTS 2 // allowing too many concurrent web clients can cause errors
28+
#define HTTP_CLIENTS 2 // http, ws
29+
#define MAX_STREAMS 0
2630
#define INDEX_PAGE_PATH DATA_DIR "/SG" HTML_EXT
2731
#define FILE_NAME_LEN 64
28-
#define JSON_BUFF_LEN (1024 * 4)
32+
#define IN_FILE_NAME_LEN 128
33+
#define JSON_BUFF_LEN (1024 * 4) // set big enough to hold json string
2934
#define MAX_CONFIGS 100 // > number of entries in configs.txt
30-
#define GITHUB_URL "https://raw.githubusercontent.com/s60sc/ESP32_SpecificGravity/master"
35+
#define GITHUB_PATH "/s60sc/ESP32_SpecificGravity/master"
36+
3137
#define STORAGE LittleFS // One of LittleFS or SD_MMC
3238
#define RAMSIZE (1024 * 8)
3339
#define CHUNKSIZE (1024 * 4)
34-
#define RAM_LOG_LEN 5000 // size of ram stored system message log in bytes
35-
//#define INCLUDE_FTP
36-
//#define INCLUDE_SMTP
37-
//#define INCLUDE_SD
38-
//#define INCLUDE_MQTT
40+
#define MIN_RAM 8 // min object size stored in ram instead of PSRAM default is 4096
41+
#define MAX_RAM 4096 // max object size stored in ram instead of PSRAM default is 4096
42+
#define TLS_HEAP (64 * 1024) // min free heap for TLS session
43+
#define WARN_HEAP (32 * 1024) // low free heap warning
44+
#define WARN_ALLOC (16 * 1024) // low free max allocatable free heap block
45+
#define MAX_ALERT 1024
46+
47+
#define INCLUDE_FTP_HFS false // ftp.cpp (file upload)
48+
#define INCLUDE_SMTP false // smtp.cpp (email)
49+
#define INCLUDE_MQTT false // mqtt.cpp
50+
#define INCLUDE_TGRAM false // telegram.cpp
51+
#define INCLUDE_CERTS false // certificates.cpp (https and server certificate checking)
52+
#define INCLUDE_WEBDAV true // webDav.cpp (WebDAV protocol)
3953

4054
#define IS_IO_EXTENDER false // must be false except for IO_Extender
4155
#define EXTPIN 100
4256

4357
// to determine if newer data files need to be loaded
44-
#define HTM_VER "1"
45-
#define JS_VER "0"
46-
#define CFG_VER "1"
47-
48-
#define NULL_TEMP -127.0
49-
#define FILE_EXT ""
50-
51-
// I2C devices requiring separate libraries
58+
#define CFG_VER 2
59+
60+
#ifdef CONFIG_IDF_TARGET_ESP32S3
61+
#define SERVER_STACK_SIZE (1024 * 8)
62+
#define DS18B20_STACK_SIZE (1024 * 2)
63+
#define STICK_STACK_SIZE (1024 * 4)
64+
#else
65+
#define SERVER_STACK_SIZE (1024 * 4)
66+
#define DS18B20_STACK_SIZE (1024)
67+
#define STICK_STACK_SIZE (1024 * 2)
68+
#endif
69+
#define BATT_STACK_SIZE (1024 * 2)
70+
#define EMAIL_STACK_SIZE (1024 * 6)
71+
#define FS_STACK_SIZE (1024 * 4)
72+
#define LOG_STACK_SIZE (1024 * 3)
73+
#define MQTT_STACK_SIZE (1024 * 4)
74+
#define PING_STACK_SIZE (1024 * 5)
75+
#define SERVO_STACK_SIZE (1024)
76+
#define SUSTAIN_STACK_SIZE (1024 * 4)
77+
#define TGRAM_STACK_SIZE (1024 * 6)
78+
#define TELEM_STACK_SIZE (1024 * 4)
79+
#define UART_STACK_SIZE (1024 * 2)
80+
81+
// task priorities
82+
#define HTTP_PRI 5
83+
#define STICK_PRI 5
84+
#define TGRAM_PRI 1
85+
#define EMAIL_PRI 1
86+
#define FTP_PRI 1
87+
#define LOG_PRI 1
88+
#define SERVO_PRI 1
89+
#define UART_PRI 1
90+
#define BATT_PRI 1
91+
#define IDLEMON_PRI 5
92+
93+
// devices requiring separate libraries
5294
#define USE_BMP280 false
5395
#define USE DS3231 false
5496
#define USE_SSD1306 false
55-
#define USE_MPU6050 true
5697
#define USE_DS18B20 false
5798

58-
// LCD 1602
59-
enum onoffType {OFF, ON};
60-
enum lfType {LEFT, RIGHT};
61-
enum customChar {CELSIUS, CC1, CC2, CC3, CC4, CC5, CC6, CC7};
99+
// devices not requiring separate libraries
100+
#define USE_LCD1602 false
101+
#define USE_PCF8591 false
102+
#define USE_MPU6050 true
103+
104+
#define NULL_TEMP -127.0
105+
#define FILE_EXT ""
106+
62107

63108
/******************** Function declarations *******************/
64109

65110
// global app specific functions
66-
void SGsetup();
111+
bool SGsetup();
67112
void SGloop();
68113
bool checkMPU6050();
69-
double* readMPU6050();
114+
float* readMPU6050();
70115
bool sleepMPU6050(bool doSleep = true);
71-
void checkI2C();
72-
bool getI2Cdata (uint8_t clientAddr, uint8_t controlByte, uint8_t numBytes);
73-
bool sendI2Cdata(int clientAddr, uint8_t controlByte, uint8_t numBytes);
116+
float* getBMP280();
117+
bool checkI2Cdevices(bool showWarn = false);
74118
bool startI2C();
75-
void displayValuesOled(int inDispIndex, bool dispChanged);
119+
void setLamp(uint8_t lampVal);
76120

77121
/******************** Global app declarations *******************/
78122

79123
// status & control fields
124+
extern const char* appConfig;
80125

81126
// batt monitoring
82127
extern int voltPin;
@@ -87,4 +132,3 @@ extern int voltInterval;
87132

88133
extern int I2C_SDA;
89134
extern int I2C_SCL;
90-
extern int MPU6050addr;

0 commit comments

Comments
 (0)