0 votes
in WeatherStationClassic by (270 points)
This is the ino file
#include <ESPWiFi.h>
#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"
#include "Wire.h"
#include "OpenWeatherMapCurrent.h"
#include "OpenWeatherMapForecast.h"
#include "WeatherStationFonts.h"
#include "WeatherStationImages.h"
#include "DHT.h"

/***************************
 * Begin Settings
 **************************/

// WIFI
const char* WIFI_SSID = "HUAWEI-vgh8";
const char* WIFI_PWD = "Nd52Ld72";

#define TZ              +3      // (utc+) TZ in hours
#define DST_MN          0      // use 60mn for summer time in some countries

// Setup
const int UPDATE_INTERVAL_SECS = 5 * 60; // Update every 20 minutes

// Display Settings
const int I2C_DISPLAY_ADDRESS = 0x3c;
#define OLED_RESET -1
#if defined(ESP8266)
const int SDA_PIN = D2; //"D3;
const int SDC_PIN = D3; //"D4;
#else
const int SDA_PIN = 5; //D3;
const int SDC_PIN = 4; //D4;
#endif

// DHT Settings
#define DHTPIN 14// NodeMCU
//#define DHTPIN D6 // Wemos D1R2 Mini
#define DHTTYPE DHT11  // DHT22  (AM2302), AM2321
char FormattedTemperature[10];
char FormattedHumidity[10];

// OpenWeatherMap Settings
// Sign up here to get an API key:
// https://docs.thingpulse.com/how-tos/openweathermap-key/
String OPEN_WEATHER_MAP_APP_ID = "aae20b6addd62b5b6a555ba9cd257f58";
/*
Go to https://openweathermap.org/find?q= and search for a location. Go through the
result set and select the entry closest to the actual location you want to display
data for. It'll be a URL like https://openweathermap.org/city/2657896. The number
at the end is what you assign to the constant below.
 */
String OPEN_WEATHER_MAP_LOCATION_ID = "625144";

// Pick a language code from this list:
// Arabic - ar, Bulgarian - bg, Catalan - ca, Czech - cz, German - de, Greek - el,
// English - en, Persian (Farsi) - fa, Finnish - fi, French - fr, Galician - gl,
// Croatian - hr, Hungarian - hu, Italian - it, Japanese - ja, Korean - kr,
// Latvian - la, Lithuanian - lt, Macedonian - mk, Dutch - nl, Polish - pl,
// Portuguese - pt, Romanian - ro, Russian - ru, Swedish - se, Slovak - sk,
// Slovenian - sl, Spanish - es, Turkish - tr, Ukrainian - ua, Vietnamese - vi,
// Chinese Simplified - zh_cn, Chinese Traditional - zh_tw.
String OPEN_WEATHER_MAP_LANGUAGE = "se";
const uint8_t MAX_FORECASTS = 3;

const boolean IS_METRIC = true;

// Adjust according to your language
//const String WDAY_NAMES[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
const String WDAY_NAMES[] = {"SÖN", "MÅN", "TIS", "ONS", "TOR", "FRE", "LÖR"};
const String MONTH_NAMES[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};

/***************************
 * End Settings
 **************************/
 // Initialize the oled display for address 0x3c
 // sda-pin=14 and sdc-pin=12
 SSD1306Wire     display(I2C_DISPLAY_ADDRESS, SDA_PIN, SDC_PIN);
 OLEDDisplayUi   ui( &display );

OpenWeatherMapCurrentData currentWeather;
OpenWeatherMapCurrent currentWeatherClient;

OpenWeatherMapForecastData forecasts[MAX_FORECASTS];
OpenWeatherMapForecast forecastClient;

#define TZ_MN           ((TZ)*60)
#define TZ_SEC          ((TZ)*3600)
#define DST_SEC         ((DST_MN)*60)
time_t now;

// flag changed in the ticker function every 10 minutes
bool readyForWeatherUpdate = false;
// flag changed in the ticker function every 1 minute
bool readyForDHTUpdate = false;

String lastUpdate = "--";

long timeSinceLastWUpdate = 0;

//declaring prototypes
void drawProgress(OLEDDisplay *display, int percentage, String label);
void updateData(OLEDDisplay *display);
void drawDateTime(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
void drawCurrentWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
void drawForecast(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
void drawForecastDetails(OLEDDisplay *display, int x, int y, int dayIndex);
void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state);
void drawIndoor(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
void setReadyForWeatherUpdate();

// Initialize the temperature/ humidity sensor
DHT dht(DHTPIN, DHTTYPE);
float humidity = 0.0;
float temperature = 0.0;

// Add frames
// this array keeps function pointers to all frames
// frames are the single views that slide from right to left
FrameCallback frames[] = { drawDateTime, drawCurrentWeather, drawForecast, drawIndoor };
int numberOfFrames = 4;

OverlayCallback overlays[] = { drawHeaderOverlay };
int numberOfOverlays = 1;

void setup() {

AND here it always say

'Serial' does not name a typein this lines

  Serial.begin(115200);
  Serial.println();
  Serial.println();
related to an answer for: Fail to verify
by (270 points)
DTH11Weather:165:3: error: 'Serial' does not name a type

   Serial.begin(115200);

   ^

DTH11Weather:170:3: error: 'display' does not name a type

   display.init();

   ^

DTH11Weather:171:3: error: 'display' does not name a type

   display.clear();

   ^

DTH11Weather:172:3: error: 'display' does not name a type

   display.display();

   ^

DTH11Weather:175:3: error: 'display' does not name a type

   display.setFont(ArialMT_Plain_10);

   ^

DTH11Weather:176:3: error: 'display' does not name a type

   display.setTextAlignment(TEXT_ALIGN_CENTER);

   ^

DTH11Weather:177:3: error: 'display' does not name a type

   display.setContrast(255);

   ^

DTH11Weather:179:3: error: 'WiFi' does not name a type

   WiFi.begin(WIFI_SSID, WIFI_PWD);

   ^

DTH11Weather:182:3: error: expected unqualified-id before 'while'

   while (WiFi.status() != WL_CONNECTED) {

   ^

DTH11Weather:195:13: error: expected constructor, destructor, or type conversion before '(' token

   configTime(TZ_SEC, DST_SEC, "pool.ntp.org");

             ^

DTH11Weather:197:3: error: 'ui' does not name a type

   ui.setTargetFPS(30);

   ^

DTH11Weather:199:3: error: 'ui' does not name a type

   ui.setActiveSymbol(activeSymbole);

   ^

DTH11Weather:200:3: error: 'ui' does not name a type

   ui.setInactiveSymbol(inactiveSymbole);

   ^

DTH11Weather:204:3: error: 'ui' does not name a type

   ui.setIndicatorPosition(BOTTOM);

   ^

DTH11Weather:207:3: error: 'ui' does not name a type

   ui.setIndicatorDirection(LEFT_RIGHT);

   ^

DTH11Weather:211:3: error: 'ui' does not name a type

   ui.setFrameAnimation(SLIDE_LEFT);

   ^

DTH11Weather:213:3: error: 'ui' does not name a type

   ui.setFrames(frames, numberOfFrames);

   ^

DTH11Weather:215:3: error: 'ui' does not name a type

   ui.setOverlays(overlays, numberOfOverlays);

   ^

DTH11Weather:218:3: error: 'ui' does not name a type

   ui.init();

   ^

DTH11Weather:222:13: error: expected constructor, destructor, or type conversion before '(' token

   updateData(&display);

             ^

DTH11Weather:224:1: error: expected declaration before '}' token

 }

 ^

Multiple libraries were found for "ESPWiFi.h"
 Använd: C:\Users\LD\Documents\Arduino\libraries\ESP8266_Weather_Station
Oanvänd: C:\Arduino\libraries\ESP8266_Weather_Station
Multiple libraries were found for "JsonListener.h"
 Använd: C:\Users\LD\Documents\Arduino\libraries\arduino_893449
Oanvänd: C:\Arduino\libraries\arduino_893449
Oanvänd: C:\Arduino\libraries\arduino_893449
Oanvänd: C:\Arduino\libraries\arduino_893449
Oanvänd: C:\Arduino\libraries\arduino_893449
Multiple libraries were found for "OLEDDisplay.h"
 Använd: C:\Users\LD\Documents\Arduino\libraries\ESP8266_and_ESP32_Oled_Driver_for_SSD1306_display
Oanvänd: C:\Arduino\libraries\ESP8266_and_ESP32_Oled_Driver_for_SSD1306_display
Multiple libraries were found for "Wire.h"
 Använd: C:\Users\LD\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\Wire
Oanvänd: C:\Users\LD\Documents\Arduino\libraries\Wire-master
Oanvänd: C:\Arduino\libraries\Wire-master
exit status 1
'Serial' does not name a type
by (270 points)
Nodemcu ESP8266 chip cilabs 2102

Please log in or register to answer this question.

Welcome to ThingPulse Q&A, where you can ask questions and receive answers from other members of the community.

https://thingpulse.com

...