Skip to content

Commit 9494337

Browse files
committed
more platforms
1 parent 691d13b commit 9494337

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

ESP32_S2_WiFi_Tests/JSONdemo/JSONdemo.ino

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ void setup() {
5050
//Initialize serial and wait for port to open:
5151
Serial.begin(115200);
5252

53+
// Connect to WPA/WPA2 network
54+
WiFi.begin(ssid, pass);
55+
5356
#if defined(USE_OLED)
54-
#if defined(ARDUINO_ADAFRUIT_QTPY_ESP32S2) \
55-
|| defined(ARDUINO_ADAFRUIT_QTPY_ESP32_PICO)
56-
// ESP32 is kinda odd in that secondary ports must be manually
57-
// assigned their pins with setPins()!
58-
Wire1.setPins(SDA1, SCL1);
59-
#endif
57+
setupI2C();
58+
delay(200); // wait for OLED to reset
6059

6160
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
6261
Serial.println(F("SSD1306 allocation failed"));
@@ -67,11 +66,12 @@ void setup() {
6766
display.setTextColor(WHITE);
6867
display.clearDisplay();
6968
display.setCursor(0,0);
70-
#else
71-
// Don't wait for serial if we have an OLED
72-
while (!Serial) {
73-
delay(10); // wait for serial port to connect. Needed for native USB port only
74-
}
69+
#else
70+
// Don't wait for serial if we have an OLED
71+
while (!Serial) {
72+
// wait for serial port to connect. Needed for native USB port only
73+
delay(10);
74+
}
7575
#endif
7676
// attempt to connect to Wifi network:
7777
Serial.print("Attempting to connect to SSID: ");
@@ -82,8 +82,7 @@ void setup() {
8282
display.display();
8383
#endif
8484

85-
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
86-
WiFi.begin(ssid, pass);
85+
8786
while (WiFi.status() != WL_CONNECTED) {
8887
delay(500);
8988
Serial.print(".");
@@ -179,7 +178,11 @@ void loop() {
179178
display.clearDisplay();
180179
display.display();
181180
#endif // OLED
181+
#if defined(NEOPIXEL_POWER)
182182
digitalWrite(NEOPIXEL_POWER, LOW); // off
183+
#elif defined(NEOPIXEL_I2C_POWER)
184+
digitalWrite(NEOPIXEL_I2C_POWER, LOW); // off
185+
#endif
183186
// wake up 1 second later and then go into deep sleep
184187
esp_sleep_enable_timer_wakeup(10 * 1000UL * 1000UL); // 10 sec
185188
esp_deep_sleep_start();
@@ -188,6 +191,17 @@ void loop() {
188191
#endif
189192
}
190193

194+
void setupI2C() {
195+
#if defined(ARDUINO_ADAFRUIT_QTPY_ESP32S2) || defined(ARDUINO_ADAFRUIT_QTPY_ESP32_PICO)
196+
// ESP32 is kinda odd in that secondary ports must be manually
197+
// assigned their pins with setPins()!
198+
Wire1.setPins(SDA1, SCL1);
199+
#endif
200+
#if defined(NEOPIXEL_I2C_POWER)
201+
pinMode(NEOPIXEL_I2C_POWER, OUTPUT);
202+
digitalWrite(NEOPIXEL_I2C_POWER, HIGH); // on
203+
#endif
204+
}
191205

192206
void printWifiStatus() {
193207
// print the SSID of the network you're attached to:

0 commit comments

Comments
 (0)