Skip to content

Commit

Permalink
working on stimawifi for esp32
Browse files Browse the repository at this point in the history
  • Loading branch information
pat1 committed Jan 10, 2024
1 parent ff4b357 commit 4cc01e3
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 54 deletions.
50 changes: 36 additions & 14 deletions platformio/stima_v3/stimawifi/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = seeed_xiao_esp32c3
default_envs = lolin_c3_mini
; wemos_d1_mini32

[env]
framework = arduino
;platform = espressif32

;platform = https://github.com/platformio/platform-espressif32.git
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.12.10/platform-espressif32.zip
;platform_packages =
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32#master


lib_extra_dirs = ../../libraries/
monitor_speed = 115200
;monitor_rts = 0
;monitor_dtr = 0
upload_speed = 921600
lib_ignore =
ArduinoSTL
Expand All @@ -35,41 +45,49 @@ board_build.filesystem = littlefs
board_build.partitions = min_spiffs.csv

[env:wemos_d1_mini32]
platform = espressif32
#platform = https://github.com/platformio/platform-espressif32.git
board = wemos_d1_mini32
lib_deps =
EspSoftwareSerial
;EspSoftwareSerial
;ESP32 AnalogWrite
https://github.com/tzapu/WiFiManager.git
;LittleFS_esp32
;hmz06967/OZGPS_NMEA @ ^1.0.0

build_flags =
-DPUBSUBCLIENT_ETHERNET -D CONFIG_ARDUINO_LOOP_STACK_SIZE=10000 -Iinclude
-DPUBSUBCLIENT_ETHERNET -D CONFIG_ARDUINO_LOOP_STACK_SIZE=10000 -Iinclude
;-DPUBSUBCLIENT_ETHERNET -DCORE_DEBUG_LEVEL=5


[env:lolin_c3_mini]
platform = espressif32
;platform = https://github.com/platformio/platform-espressif32.git
board = lolin_c3_mini
lib_deps =
EspSoftwareSerial
;EspSoftwareSerial
;ESP32 AnalogWrite
https://github.com/tzapu/WiFiManager.git
;LittleFS_esp32
;hmz06967/OZGPS_NMEA @ ^1.0.0

build_flags =
-DPUBSUBCLIENT_ETHERNET -D CONFIG_ARDUINO_LOOP_STACK_SIZE=10000 -Iinclude
-DPUBSUBCLIENT_ETHERNET -D CONFIG_ARDUINO_LOOP_STACK_SIZE=10000 -Iinclude -fexceptions
;-DPUBSUBCLIENT_ETHERNET -DCORE_DEBUG_LEVEL=5

[env:lolin_s3_mini]
board = lolin_s3_mini
lib_deps =
;EspSoftwareSerial
;ESP32 AnalogWrite
https://github.com/tzapu/WiFiManager.git
;LittleFS_esp32
;hmz06967/OZGPS_NMEA @ ^1.0.0

build_flags =
-DPUBSUBCLIENT_ETHERNET -D CONFIG_ARDUINO_LOOP_STACK_SIZE=10000 -Iinclude -fexceptions
;-DPUBSUBCLIENT_ETHERNET -DCORE_DEBUG_LEVEL=5

[env:seeed_xiao_esp32c3]
platform = espressif32
board = seeed_xiao_esp32c3
lib_deps =
EspSoftwareSerial
;EspSoftwareSerial
https://github.com/tzapu/WiFiManager.git
;LittleFS_esp32
;hmz06967/OZGPS_NMEA @ ^1.0.0
Expand All @@ -78,13 +96,17 @@ build_flags =
-DPUBSUBCLIENT_ETHERNET -D CONFIG_ARDUINO_LOOP_STACK_SIZE=10000 -Iinclude

[env:seeed_xiao_esp32s3]
platform = espressif32
board = seeed_xiao_esp32s3
lib_deps =
EspSoftwareSerial
;EspSoftwareSerial
https://github.com/tzapu/WiFiManager.git
;LittleFS_esp32
;hmz06967/OZGPS_NMEA @ ^1.0.0

build_flags =
-DPUBSUBCLIENT_ETHERNET -D CONFIG_ARDUINO_LOOP_STACK_SIZE=10000 -Iinclude
;-D ARDUINO_USB_MODE=1
;-D ARDUINO_USB_CDC_ON_BOOT=1
-D PUBSUBCLIENT_ETHERNET
-D CONFIG_ARDUINO_LOOP_STACK_SIZE=10000
-I include

64 changes: 31 additions & 33 deletions platformio/stima_v3/stimawifi/src/arduino_thread.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "arduino_thread.h"

void analogWriteFreq(const double frequency){
analogWriteFrequency(frequency);
//analogWriteFrequency(frequency);
}

String Json(){
Expand Down Expand Up @@ -196,6 +196,10 @@ String rmap_get_remote_config(){
return payload;
}

void firmware_upgrade() {
}

/*
void firmware_upgrade() {
StaticJsonDocument<200> doc;
Expand Down Expand Up @@ -246,23 +250,23 @@ void firmware_upgrade() {
break;
case HTTP_UPDATE_OK:
frtosLog.notice(F("[update] Update ok.")); // may not called we reboot the ESP
/*
if (oledpresent) {
u8g2.setCursor(0, 20);
u8g2.print(F("FW Updated!"));
u8g2.sendBuffer();
}
digitalWrite(LED_PIN,LOW);
delay(1000);
digitalWrite(LED_PIN,HIGH);
delay(1000);
digitalWrite(LED_PIN,LOW);
delay(1000);
digitalWrite(LED_PIN,HIGH);
delay(1000);
digitalWrite(LED_PIN,LOW);
delay(1000);
*/
// if (oledpresent) {
// u8g2.setCursor(0, 20);
// u8g2.print(F("FW Updated!"));
// u8g2.sendBuffer();
// }
// digitalWrite(LED_PIN,LOW);
// delay(1000);
// digitalWrite(LED_PIN,HIGH);
// delay(1000);
// digitalWrite(LED_PIN,LOW);
// delay(1000);
// digitalWrite(LED_PIN,HIGH);
// delay(1000);
// digitalWrite(LED_PIN,LOW);
// delay(1000);
break;
}
Expand All @@ -271,7 +275,7 @@ void firmware_upgrade() {
analogWriteFreq(1);
digitalWrite(LED_PIN,HIGH);
}

*/

String readconfig_rmap() {

Expand Down Expand Up @@ -662,8 +666,10 @@ void setup() {
delay(500);
digitalWrite(PMS_RESET,HIGH);

//Serial.setTxTimeoutMs(0); // https://github.com/espressif/arduino-esp32/issues/6983
Serial.begin(115200);

//Serial.setDebugOutput(true);

// Pass log level, whether to show log level, and print interface.
// Available levels are:
// LOG_LEVEL_SILENT, LOG_LEVEL_FATAL, LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, LOG_LEVEL_NOTICE, LOG_LEVEL_VERBOSE
Expand All @@ -677,20 +683,12 @@ void setup() {
frtosLog.notice(F("Started"));
frtosLog.notice(F("Version: " SOFTWARE_VERSION));

#ifdef I2CPULLUP
//if you want to set the internal pullup
digitalWrite( SDA, HIGH);
digitalWrite( SCL, HIGH);
#else
// here we enforce we do not want pullup
digitalWrite( SDA, LOW);
digitalWrite( SCL, LOW);
#endif


espClient.setTimeout(5000); // esp32 issue https://github.com/espressif/arduino-esp32/issues/3732

Wire.begin(SDA,SCL);
Wire.setClock(I2C_CLOCK);
Wire.begin();
//Wire.begin(SDA_PIN,SCL_PIN);
//Wire.setClock(I2C_CLOCK);

// check return value of
// the Write.endTransmisstion to see if
Expand Down Expand Up @@ -823,7 +821,7 @@ void setup() {
wifiManager.addParameter(&custom_rmap_password);
wifiManager.addParameter(&custom_rmap_slug);

//set minimu quality of signal so it ignores AP's under that quality
//set minimum quality of signal so it ignores AP's under that quality
//defaults to 8%
//wifiManager.setMinimumSignalQuality();

Expand Down
9 changes: 4 additions & 5 deletions platformio/stima_v3/stimawifi/src/stimawifi-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@
// set the frequency
// 30418,25 Hz : minimum freq with prescaler set to 1 and CPU clock to 16MHz
#define I2C_CLOCK 10000
// #define I2CPULLUP define this if you want software pullup on I2C

//disable debug at compile time but call function anyway
//#define DISABLE_LOGGING disable

#define FIRMWARE_TYPE "WEMOS_D1_MINI32"
#define PMS_RESET D0
#define PMS_RESET 0

//#define SCL D1
//#define SDA D2
#define SCL_PIN SCL
#define SDA_PIN SDA

#define RESET_PIN D7 // pin to connect to ground for reset wifi configuration
#define RESET_PIN 4 // pin to connect to ground for reset wifi configuration
// Set LED_BUILTIN if it is not defined by Arduino framework
#ifndef LED_BUILTIN
#define LED_BUILTIN 2
Expand Down
4 changes: 2 additions & 2 deletions platformio/stima_v3/stimawifi/src/stimawifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <ESPmDNS.h>
#include <WebServer.h>
#include <HTTPClient.h>
#include <ESP32httpUpdate.h>
//#include <ESP32httpUpdate.h>
#include <LittleFS.h>
#include "thread.hpp"
//#include "critical.hpp"
Expand All @@ -23,7 +23,6 @@
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
#include <ArduinoJson.h> //https://github.com/bblanchon/ArduinoJson
#include <PubSubClient.h>
#include <SoftwareSerial.h>
#include <TimeAlarms.h>
#include <Wire.h>
#include <SensorDriverb.h>
Expand All @@ -38,6 +37,7 @@
#include "measure_thread.h"
#include "publish_thread.h"
#include "arduino_thread.h"
#include "USB.h"

//////////////// REMOVE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
extern String readconfig_rmap();
Expand Down

0 comments on commit 4cc01e3

Please sign in to comment.