Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ESP32 #208

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
- examples/AstronomyDemo
- examples/OpenWeatherMapCurrentDemo
- examples/OpenWeatherMapForecastDemo
# doesn't work on ESP32 due to WiFi Manager dependency
- examples/PlaneSpotterDemo
# - examples/PlaneSpotterDemo doesn't work on ESP32 due to WiFi Manager dependency
- examples/SunMoonCalcDemo
- examples/WeatherStationDemo
- examples/WorldClockDemo
Expand All @@ -43,6 +42,6 @@ jobs:
- name: Install library dependencies
run: pio lib -g install "JsonStreamingParser" "thingpulse/ESP8266 and ESP32 OLED driver for SSD1306 displays@^4.2.0" "WifiManager@>=0.15.0-beta"
- name: Run PlatformIO
run: pio ci --lib="." --project-option="lib_deps=JsonStreamingParser" --board=nodemcuv2 --board=d1_mini
run: pio ci --lib="." --project-option="lib_deps=JsonStreamingParser" --board=nodemcuv2 --board=d1_mini --board=esp-wrover-kit
env:
PLATFORMIO_CI_SRC: ${{ matrix.example }}
10 changes: 9 additions & 1 deletion examples/AerisForecastsDemo/AerisForecastsDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ SOFTWARE.

#include <Arduino.h>

#if defined(ESP8266)
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <JsonListener.h>
#include "AerisForecasts.h"

Expand All @@ -40,7 +44,11 @@ String AERIS_LOCATION = "Zurich,CH";
/**
* WiFi Settings
*/
#if defined(ESP8266)
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
#else
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
#endif
const char* WIFI_SSID = "yourssid";
const char* WIFI_PASSWORD = "yourpassw0rd";

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

void print(String name, sint16_t value) {
void print(String name, int16_t value) {
Serial.printf("%s: %d\n", name.c_str(), value);
}

Expand Down
8 changes: 8 additions & 0 deletions examples/AerisObservationDemo/AerisObservationDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ SOFTWARE.

#include <Arduino.h>

#if defined(ESP8266)
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <JsonListener.h>
#include "AerisObservations.h"

Expand All @@ -41,7 +45,11 @@ String AERIS_LOCATION = "Zurich,CH";
/**
* WiFi Settings
*/
#if defined(ESP8266)
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
#else
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
#endif
const char* WIFI_SSID = "yourssid";
const char* WIFI_PASSWORD = "yourpassw0rd";

Expand Down
8 changes: 8 additions & 0 deletions examples/AerisSunMoonDemo/AerisSunMoonDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ SOFTWARE.

#include <Arduino.h>

#if defined(ESP8266)
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <JsonListener.h>
#include "AerisSunMoon.h"

Expand All @@ -41,7 +45,11 @@ String AERIS_LOCATION = "Zurich,CH";
/**
* WiFi Settings
*/
#if defined(ESP8266)
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
#else
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
#endif
const char* WIFI_SSID = "yourssid";
const char* WIFI_PASSWORD = "yourpassw0rd";

Expand Down
4 changes: 4 additions & 0 deletions examples/AstronomyDemo/AstronomyDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ See more at https://thingpulse.com
*/

#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <ESPHTTPClient.h>
#include <time.h>
#include "Astronomy.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ SOFTWARE.

#include <Arduino.h>

#if defined(ESP8266)
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <JsonListener.h>
#include <time.h>
#include "OpenWeatherMapCurrent.h"
Expand Down Expand Up @@ -56,7 +60,11 @@ boolean IS_METRIC = true;
/**
* WiFi Settings
*/
#if defined(ESP8266)
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
#else
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
#endif
const char* WIFI_SSID = "yourssid";
const char* WIFI_PASSWORD = "yourpassw0rd";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ SOFTWARE.

#include <Arduino.h>

#if defined(ESP8266)
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <JsonListener.h>
#include <time.h>
#include "OpenWeatherMapForecast.h"
Expand Down Expand Up @@ -57,7 +61,11 @@ uint8_t MAX_FORECASTS = 15;
/**
* WiFi Settings
*/
#if defined(ESP8266)
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
#else
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
#endif
const char* WIFI_SSID = "yourssid";
const char* WIFI_PASSWORD = "yourpassw0rd";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ SOFTWARE.

#include <Arduino.h>

#if defined(ESP8266)
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <JsonListener.h>
#include <time.h>
#include "OpenWeatherMapOneCall.h"
Expand Down Expand Up @@ -52,7 +56,11 @@ boolean IS_METRIC = false;
/**
* WiFi Settings
*/
#if defined(ESP8266)
const char* ESP_HOST_NAME = "esp-" + ESP.getFlashChipId();
#else
const char* ESP_HOST_NAME = "esp-" + ESP.getEfuseMac();
#endif
const char* WIFI_SSID = "yourssid";
const char* WIFI_PASSWORD = "yourpassw0rd";

Expand Down
8 changes: 7 additions & 1 deletion examples/PlaneSpotterDemo/PlaneSpotterDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ SOFTWARE.
See more at https://thingpulse.com
*/
#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#else
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#endif
#include <ESPHTTPClient.h>
#include <Ticker.h>
#include <JsonListener.h>
#include <ArduinoOTA.h>
#include <ESP8266mDNS.h>

#include <DNSServer.h>
#include <ESP8266WebServer.h>
Expand Down
4 changes: 4 additions & 0 deletions examples/SunMoonCalcDemo/SunMoonCalcDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ SOFTWARE.
*/

#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <ESPHTTPClient.h>
#include <time.h>
#include "SunMoonCalc.h"
Expand Down
8 changes: 6 additions & 2 deletions examples/WeatherStationDemo/WeatherStationDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ See more at https://thingpulse.com

#include <Arduino.h>

#include <ESPWiFi.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#include <coredecls.h> // settimeofday_cb()
#else
#include <WiFi.h>
#endif
#include <ESPHTTPClient.h>
#include <JsonListener.h>

// time
#include <time.h> // time() ctime()
#include <sys/time.h> // struct timeval
#include <coredecls.h> // settimeofday_cb()

#include "SSD1306Wire.h"
#include "OLEDDisplayUi.h"
Expand Down
18 changes: 8 additions & 10 deletions examples/WorldClockDemo/WorldClockDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ See more at https://thingpulse.com

#include <Arduino.h>

#if defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#else
#include <WiFi.h>
#endif
#include <ESPHTTPClient.h>
#include <Ticker.h>
#include <JsonListener.h>
#include <SSD1306Wire.h>
Expand All @@ -50,16 +54,10 @@ const int UPDATE_INTERVAL_SECS = 10 * 60; // Update every 10 minutes

// Display Settings
const int I2C_DISPLAY_ADDRESS = 0x3c;
const int SDA_PIN = D3;
const int SDC_PIN = D4;
const int SDA_PIN = SDA;
const int SCL_PIN = SCL;

// TimeClient settings


// Initialize the oled display for address 0x3c
// sda-pin=14 and sdc-pin=12

SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SDC_PIN);
SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN);
OLEDDisplayUi ui ( &display );

/***************************
Expand Down
6 changes: 5 additions & 1 deletion src/AerisForecasts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ void AerisForecasts::doUpdate(AerisForecastData *forecasts, String path, uint8_t
Serial.printf("[HTTP] Requesting resource at http://%s:%u%s\n", host.c_str(), port, path.c_str());

WiFiClient client;
if(client.connect(host, port)) {
#if defined(ESP8266)
if (client.connect(host, port)) {
#else
if (client.connect(host.c_str(), port)) {
#endif
bool isBody = false;
char c;
Serial.println("[HTTP] connected, now GETting data");
Expand Down
52 changes: 26 additions & 26 deletions src/AerisForecasts.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ typedef struct AerisForecastData {
uint64_t timestamp; // 1526706000
String validTime; // "2018-05-19T07:00:00+02:00"
String dateTimeISO; //"2018-05-19T07:00:00+02:00"
sint16_t maxTempC; //20
sint16_t maxTempF; //69
sint16_t minTempC; //14
sint16_t minTempF; // 56
sint16_t avgTempC; // 17
sint16_t avgTempF; // 62
sint16_t tempC; // null
sint16_t tempF; // null
sint16_t pop; // 20
int16_t maxTempC; //20
int16_t maxTempF; //69
int16_t minTempC; //14
int16_t minTempF; // 56
int16_t avgTempC; // 17
int16_t avgTempF; // 62
int16_t tempC; // null
int16_t tempF; // null
int16_t pop; // 20
float precipMM; // 3.53
float precipIN; // 0.14
float iceaccum; // null
Expand All @@ -53,27 +53,27 @@ typedef struct AerisForecastData {
uint8_t sky; // 99
uint16_t snowCM; // 0
uint16_t snowIN; // 0
sint16_t feelslikeC; // 14
sint16_t feelslikeF; // 56
sint16_t minFeelslikeC; // 14
sint16_t minFeelslikeF; // 56
sint16_t maxFeelslikeC; // 20
sint16_t maxFeelslikeF; // 69
sint16_t avgFeelslikeC; // 17
sint16_t avgFeelslikeF; // 63
sint16_t dewpointC; // 11
sint16_t dewpointF; // 51
sint16_t maxDewpointC; // 13
sint16_t maxDewpointF; // 55
sint16_t minDewpointC; // 10
sint16_t minDewpointF; // 51
sint16_t avgDewpointC; // 11
sint16_t avgDewpointF; // 52
int16_t feelslikeC; // 14
int16_t feelslikeF; // 56
int16_t minFeelslikeC; // 14
int16_t minFeelslikeF; // 56
int16_t maxFeelslikeC; // 20
int16_t maxFeelslikeF; // 69
int16_t avgFeelslikeC; // 17
int16_t avgFeelslikeF; // 63
int16_t dewpointC; // 11
int16_t dewpointF; // 51
int16_t maxDewpointC; // 13
int16_t maxDewpointF; // 55
int16_t minDewpointC; // 10
int16_t minDewpointF; // 51
int16_t avgDewpointC; // 11
int16_t avgDewpointF; // 52
uint16_t windDirDEG; // 2
String windDir; // "N"
uint16_t windDirMaxDEG; // 40
String windDirMax; // "NE"
sint16_t windDirMinDEG; // 39
int16_t windDirMinDEG; // 39
String windDirMin; // "NE"
uint16_t windGustKTS; // 6
uint16_t windGustKPH; // 11
Expand Down
6 changes: 5 additions & 1 deletion src/AerisObservations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ void AerisObservations::doUpdate(AerisObservationsData *observations, String pat
Serial.printf("[HTTP] Requesting resource at http://%s:%u%s\n", host.c_str(), port, path.c_str());

WiFiClient client;
if(client.connect(host, port)) {
#if defined(ESP8266)
if (client.connect(host, port)) {
#else
if (client.connect(host.c_str(), port)) {
#endif
bool isBody = false;
char c;
Serial.println("[HTTP] connected, now GETting data");
Expand Down
20 changes: 10 additions & 10 deletions src/AerisObservations.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
typedef struct AerisObservationsData {
uint64_t timestamp;
String dateTimeISO;
sint16_t tempC;
sint16_t tempF;
sint16_t dewpointC;
sint16_t dewpointF;
int16_t tempC;
int16_t tempF;
int16_t dewpointC;
int16_t dewpointF;
uint8_t humidity;
uint16_t pressureMB;
float pressureIN;
Expand All @@ -60,12 +60,12 @@ typedef struct AerisObservationsData {
String cloudsCoded;
String icon;
String iconMeteoCon;
sint16_t heatindexC;
sint16_t heatindexF;
sint16_t windchillC;
sint16_t windchillF;
sint16_t feelslikeC;
sint16_t feelslikeF;
int16_t heatindexC;
int16_t heatindexF;
int16_t windchillC;
int16_t windchillF;
int16_t feelslikeC;
int16_t feelslikeF;
boolean isDay;
uint64_t sunrise;
String sunriseISO;
Expand Down
Loading