Skip to content

Commit f324e2f

Browse files
committed
Prepare for ESP32S2 based boards
1 parent 6d553d1 commit f324e2f

5 files changed

Lines changed: 68 additions & 3 deletions

File tree

VanLiveConnect/Config.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,12 @@
120120
// to simulate a power-off event.
121121
//
122122
#ifdef ARDUINO_ARCH_ESP32
123+
#ifdef CONFIG_IDF_TARGET_ESP32S2
124+
#define LIGHT_SLEEP_WAKE_PIN GPIO_NUM_35
125+
#else
123126
// Only GPIOs which are have RTC functionality can be used: 0,2,4,12-15,25-27,32-39.
124127
#define LIGHT_SLEEP_WAKE_PIN GPIO_NUM_13
128+
#endif
125129
#else
126130
#define LIGHT_SLEEP_WAKE_PIN D1
127131
#endif // ARDUINO_ARCH_ESP32
@@ -251,9 +255,15 @@
251255

252256
// IR receiver data pin
253257
#ifdef ARDUINO_ARCH_ESP32
258+
#ifdef CONFIG_IDF_TARGET_ESP32S2
259+
#define IR_RECV_PIN GPIO_NUM_7
260+
#define IR_VCC GPIO_NUM_11
261+
#define IR_GND GPIO_NUM_9
262+
#else
254263
#define IR_RECV_PIN GPIO_NUM_18
255264
#define IR_VCC GPIO_NUM_23
256265
#define IR_GND GPIO_NUM_19
266+
#endif
257267
#else
258268
#define IR_RECV_PIN D5
259269

@@ -272,16 +282,23 @@
272282

273283
// IR receiver data pin
274284
#ifdef ARDUINO_ARCH_ESP32
285+
#ifdef CONFIG_IDF_TARGET_ESP32S2
286+
#define IR_RECV_PIN GPIO_NUM_11
287+
#define IR_VCC GPIO_NUM_7
288+
#define IR_GND GPIO_NUM_5
289+
#else
275290
#define IR_RECV_PIN GPIO_NUM_23
276291
#define IR_VCC GPIO_NUM_18
277292
#define IR_GND GPIO_NUM_26
293+
#endif
278294
#else
295+
#define IR_RECV_PIN D7
296+
279297
// Using D5 as VCC and D0 as ground pin for the IR receiver. Should be possible with e.g. the
280298
// TSOP31238 IR receiver as it typically uses only 0.35 mA.
281299
#define IR_VCC D5
282300
#define IR_GND D0
283301

284-
#define IR_RECV_PIN D7
285302
#endif // ARDUINO_ARCH_ESP32
286303

287304
#endif // IR_TSOP312XX

VanLiveConnect/ESP32S2_IDE.bat

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@echo off
2+
3+
rem This batch file sets up the Arduino IDE with all the correct board options (as found in the IDE "Tools" menu)
4+
5+
rem Board spec for "ESP32S2 Dev Module"
6+
set BOARDSPEC=esp32:esp32:esp32s2:CDCOnBoot=cdc,CPUFreq=240,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=min_spiffs,DebugLevel=none
7+
8+
rem Fill in your COM port here
9+
set COMPORT=COM3
10+
11+
rem Get the full directory name of the currently running script
12+
set MYPATH=%~dp0
13+
14+
rem Launch the Arduino IDE with the specified board options
15+
call "%MYPATH%..\extras\Scripts\ArduinoIdeEnv.bat"

VanLiveConnect/ESP32S2_IDE.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/bash
2+
3+
# This script sets up the Arduino IDE with all the correct board options (as found in the IDE "Tools" menu)
4+
5+
# Board spec for "ESP32S2 Dev Module"
6+
BOARDSPEC=esp32:esp32:esp32s2:CDCOnBoot=cdc,CPUFreq=240,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=min_spiffs,DebugLevel=none
7+
8+
# Fill in your COM port here
9+
COMPORT=/dev/ttyUSB0
10+
11+
# Get the full directory name of the currently running script
12+
\cd `dirname $0`
13+
MYPATH=`pwd`
14+
\cd - > /dev/null
15+
16+
# Launch the Arduino IDE with the specified board options
17+
. "${MYPATH}/../extras/Scripts/ArduinoIdeEnv.sh"

VanLiveConnect/VanLiveConnect.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,13 @@ void SetupVanReceiver()
174174

175175
// Define these as #defines so that the Serial.printf_P below shows the correct pin name on the console
176176
#ifdef ARDUINO_ARCH_ESP32
177+
#ifdef CONFIG_IDF_TARGET_ESP32S2
178+
#define TX_PIN GPIO_NUM_18 // GPIO pin connected to VAN bus transceiver input
179+
#define RX_PIN GPIO_NUM_33 // GPIO pin connected to VAN bus transceiver output
180+
#else
177181
#define TX_PIN GPIO_NUM_16 // GPIO pin connected to VAN bus transceiver input
178182
#define RX_PIN GPIO_NUM_21 // GPIO pin connected to VAN bus transceiver output
183+
#endif
179184
#else // ! ARDUINO_ARCH_ESP32
180185
#define TX_PIN D3 // GPIO pin connected to VAN bus transceiver input
181186
#define RX_PIN D2 // GPIO pin connected to VAN bus transceiver output
@@ -329,7 +334,11 @@ void setup()
329334
// (see also: https://github.com/espressif/esp-azure/issues/17 )
330335
Serial.setDebugOutput(false);
331336

332-
delay(1000);
337+
#if defined ARDUINO_ARCH_ESP32 && defined CONFIG_IDF_TARGET_ESP32S2
338+
// Give COM port device driver time to start
339+
delay(3000);
340+
#endif
341+
333342
Serial.begin(115200);
334343
Serial.printf_P(PSTR("\nStarting VAN bus \"Live Connect\" server version %s\n"), VAN_LIVE_CONNECT_VERSION);
335344

VanLiveConnect/Wifi.ino

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ const char* SetupWifi()
193193

194194
Serial.printf_P(PSTR("Setting up captive portal on Wi-Fi access point '%s', channel %d\n"), wifiSsid, WIFI_CHANNEL);
195195

196-
WiFi.mode(WIFI_AP);
196+
#if ! defined ARDUINO_ARCH_ESP32 || ! defined CONFIG_IDF_TARGET_ESP32S2
197+
// For some reason, this seems to break DHCP on ESP32S2
197198
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
199+
#endif
198200

199201
// Register event handlers
200202
#ifdef ARDUINO_ARCH_ESP32
@@ -218,6 +220,11 @@ const char* SetupWifi()
218220
WiFi.softAP(wifiSsid, nullptr, WIFI_CHANNEL, WIFI_SSID_HIDDEN);
219221
#endif
220222

223+
#ifdef ARDUINO_ARCH_ESP32
224+
// Set STA interface bandwidth to 20 MHz
225+
esp_wifi_set_bandwidth(WIFI_IF_AP, WIFI_BW_HT20);
226+
#endif
227+
221228
softap_config config_ap;
222229
#ifdef ARDUINO_ARCH_ESP32
223230
wifi_config_t config;

0 commit comments

Comments
 (0)