Skip to content

Commit 0310d33

Browse files
authored
Support ESP32 (#208)
1 parent c840ab8 commit 0310d33

File tree

20 files changed

+145
-58
lines changed

20 files changed

+145
-58
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ jobs:
1616
- examples/AstronomyDemo
1717
- examples/OpenWeatherMapCurrentDemo
1818
- examples/OpenWeatherMapForecastDemo
19-
# doesn't work on ESP32 due to WiFi Manager dependency
20-
- examples/PlaneSpotterDemo
19+
# - examples/PlaneSpotterDemo doesn't work on ESP32 due to WiFi Manager dependency
2120
- examples/SunMoonCalcDemo
2221
- examples/WeatherStationDemo
2322
- examples/WorldClockDemo
@@ -43,6 +42,6 @@ jobs:
4342
- name: Install library dependencies
4443
run: pio lib -g install "JsonStreamingParser" "thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.2.0" "WifiManager@>=0.15.0-beta"
4544
- name: Run PlatformIO
46-
run: pio ci --lib="." --project-option="lib_deps=JsonStreamingParser" --board=nodemcuv2 --board=d1_mini
45+
run: pio ci --lib="." --project-option="lib_deps=JsonStreamingParser" --board=nodemcuv2 --board=d1_mini --board=esp-wrover-kit
4746
env:
4847
PLATFORMIO_CI_SRC: ${{ matrix.example }}

examples/AerisForecastsDemo/AerisForecastsDemo.ino

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ SOFTWARE.
2323

2424
#include <Arduino.h>
2525

26+
#if defined(ESP8266)
2627
#include <ESP8266WiFi.h>
28+
#else
29+
#include <WiFi.h>
30+
#endif
2731
#include <JsonListener.h>
2832
#include "AerisForecasts.h"
2933

@@ -40,7 +44,11 @@ String AERIS_LOCATION = "Zurich,CH";
4044
/**
4145
* WiFi Settings
4246
*/
47+
#if defined(ESP8266)
4348
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
49+
#else
50+
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
51+
#endif
4452
const char* WIFI_SSID = "yourssid";
4553
const char* WIFI_PASSWORD = "yourpassw0rd";
4654

@@ -63,7 +71,7 @@ void print(String name, uint16_t value) {
6371
Serial.printf("%s: %d\n", name.c_str(), value);
6472
}
6573

66-
void print(String name, sint16_t value) {
74+
void print(String name, int16_t value) {
6775
Serial.printf("%s: %d\n", name.c_str(), value);
6876
}
6977

examples/AerisObservationDemo/AerisObservationDemo.ino

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ SOFTWARE.
2323

2424
#include <Arduino.h>
2525

26+
#if defined(ESP8266)
2627
#include <ESP8266WiFi.h>
28+
#else
29+
#include <WiFi.h>
30+
#endif
2731
#include <JsonListener.h>
2832
#include "AerisObservations.h"
2933

@@ -41,7 +45,11 @@ String AERIS_LOCATION = "Zurich,CH";
4145
/**
4246
* WiFi Settings
4347
*/
48+
#if defined(ESP8266)
4449
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
50+
#else
51+
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
52+
#endif
4553
const char* WIFI_SSID = "yourssid";
4654
const char* WIFI_PASSWORD = "yourpassw0rd";
4755

examples/AerisSunMoonDemo/AerisSunMoonDemo.ino

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ SOFTWARE.
2323

2424
#include <Arduino.h>
2525

26+
#if defined(ESP8266)
2627
#include <ESP8266WiFi.h>
28+
#else
29+
#include <WiFi.h>
30+
#endif
2731
#include <JsonListener.h>
2832
#include "AerisSunMoon.h"
2933

@@ -41,7 +45,11 @@ String AERIS_LOCATION = "Zurich,CH";
4145
/**
4246
* WiFi Settings
4347
*/
48+
#if defined(ESP8266)
4449
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
50+
#else
51+
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
52+
#endif
4553
const char* WIFI_SSID = "yourssid";
4654
const char* WIFI_PASSWORD = "yourpassw0rd";
4755

examples/AstronomyDemo/AstronomyDemo.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ See more at https://thingpulse.com
2424
*/
2525

2626
#include <Arduino.h>
27+
#if defined(ESP8266)
2728
#include <ESP8266WiFi.h>
29+
#else
30+
#include <WiFi.h>
31+
#endif
2832
#include <ESPHTTPClient.h>
2933
#include <time.h>
3034
#include "Astronomy.h"

examples/OpenWeatherMapCurrentDemo/OpenWeatherMapCurrentDemo.ino

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ SOFTWARE.
2323

2424
#include <Arduino.h>
2525

26+
#if defined(ESP8266)
2627
#include <ESP8266WiFi.h>
28+
#else
29+
#include <WiFi.h>
30+
#endif
2731
#include <JsonListener.h>
2832
#include <time.h>
2933
#include "OpenWeatherMapCurrent.h"
@@ -56,7 +60,11 @@ boolean IS_METRIC = true;
5660
/**
5761
* WiFi Settings
5862
*/
63+
#if defined(ESP8266)
5964
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
65+
#else
66+
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
67+
#endif
6068
const char* WIFI_SSID = "yourssid";
6169
const char* WIFI_PASSWORD = "yourpassw0rd";
6270

examples/OpenWeatherMapForecastDemo/OpenWeatherMapForecastDemo.ino

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ SOFTWARE.
2323

2424
#include <Arduino.h>
2525

26+
#if defined(ESP8266)
2627
#include <ESP8266WiFi.h>
28+
#else
29+
#include <WiFi.h>
30+
#endif
2731
#include <JsonListener.h>
2832
#include <time.h>
2933
#include "OpenWeatherMapForecast.h"
@@ -57,7 +61,11 @@ uint8_t MAX_FORECASTS = 15;
5761
/**
5862
* WiFi Settings
5963
*/
64+
#if defined(ESP8266)
6065
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
66+
#else
67+
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
68+
#endif
6169
const char* WIFI_SSID = "yourssid";
6270
const char* WIFI_PASSWORD = "yourpassw0rd";
6371

examples/OpenWeatherMapOneCallDemo/OpenWeatherMapOneCallDemo.ino

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ SOFTWARE.
2323

2424
#include <Arduino.h>
2525

26+
#if defined(ESP8266)
2627
#include <ESP8266WiFi.h>
28+
#else
29+
#include <WiFi.h>
30+
#endif
2731
#include <JsonListener.h>
2832
#include <time.h>
2933
#include "OpenWeatherMapOneCall.h"
@@ -52,7 +56,11 @@ boolean IS_METRIC = false;
5256
/**
5357
* WiFi Settings
5458
*/
59+
#if defined(ESP8266)
5560
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
61+
#else
62+
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
63+
#endif
5664
const char* WIFI_SSID = "yourssid";
5765
const char* WIFI_PASSWORD = "yourpassw0rd";
5866

examples/PlaneSpotterDemo/PlaneSpotterDemo.ino

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,18 @@ SOFTWARE.
2323
See more at https://thingpulse.com
2424
*/
2525
#include <Arduino.h>
26+
#if defined(ESP8266)
2627
#include <ESP8266WiFi.h>
28+
#include <ESP8266mDNS.h>
29+
#else
30+
#include <WiFi.h>
31+
#include <ESPmDNS.h>
32+
#include <WiFiUdp.h>
33+
#endif
2734
#include <ESPHTTPClient.h>
2835
#include <Ticker.h>
2936
#include <JsonListener.h>
3037
#include <ArduinoOTA.h>
31-
#include <ESP8266mDNS.h>
3238

3339
#include <DNSServer.h>
3440
#include <ESP8266WebServer.h>

examples/SunMoonCalcDemo/SunMoonCalcDemo.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ SOFTWARE.
2222
*/
2323

2424
#include <Arduino.h>
25+
#if defined(ESP8266)
2526
#include <ESP8266WiFi.h>
27+
#else
28+
#include <WiFi.h>
29+
#endif
2630
#include <ESPHTTPClient.h>
2731
#include <time.h>
2832
#include "SunMoonCalc.h"

0 commit comments

Comments
 (0)