• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Problem z ponowną kompilacją programu
#1
Witam, kiedyś korzystałem z modemcu esp8266 weater station + ssd1306. Wszystko pięknie działało. Chciałem go jeszcze raz wgrać i nie mogę już. Wyskakuje:
'Meteocons_Plain_21' has a previous declaration as 'const char Meteocons_Plain_21 [8381]'

Nie mam pojęcia czemu. Wszystko działało, nic nie zmieniałem, nic nie updatowałem.

pliki do programu
https://megawrzuta.pl/filesgroup/e724cc4...2d570.html
 
Odpowiedź
#2
Załącz pliki do postu, a jeśli kod mieści się tu to też go tu wklej w znaczniki <> by można go było przeczytać.
Miło być decenianym https://buycoffee.to/kaczakat
 
Odpowiedź
#3
dużo miejsca zajmuje więc w 3 postach dam, od razu przepraszam za spam postów 


prognoza_pogody_dziala.ino
Kod:
#include <DSEG7Classic-BoldFont.h>
#include <WeatherStationFonts.h>
#include <WeatherStationImages.h>

#include <font6x8.h>
#include <nano_engine.h>
#include <nano_gfx.h>
#include <nano_gfx_types.h>
#include <sprite_pool.h>
#include <ssd1306.h>
#include <ssd1306_16bit.h>
#include <ssd1306_1bit.h>
#include <ssd1306_8bit.h>
#include <ssd1306_console.h>
#include <ssd1306_fonts.h>
#include <ssd1306_generic.h>
#include <ssd1306_uart.h>

/**The MIT License (MIT)

Copyright (c) 2018 by Daniel Eichhorn - ThingPulse

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

See more at https://thingpulse.com
*/

#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"


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

// WIFI
const char* WIFI_SSID = "Uasdw45";
const char* WIFI_PWD = "123dfgfgjfrjdkvwa456";

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

// Setup
const int UPDATE_INTERVAL_SECS = 10 * 60; // Update every 20 minutes znienione na 10

// Display Settings
const int I2C_DISPLAY_ADDRESS = 0x3c;
#if defined(ESP8266)
const int SDA_PIN = D3;
const int SDC_PIN = D5;
#else
const int SDA_PIN = 5; //D3;
const int SDC_PIN = 4; //D4;
#endif


// OpenWeatherMap Settings
// Sign up here to get an API key:
// https://docs.thingpulse.com/how-tos/openweathermap-key/
String OPEN_WEATHER_MAP_APP_ID = "3bde480597c9c9fc0c6220d0f5ed819e";
/*
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 = "769250";

// 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 = "pl";
const uint8_t MAX_FORECASTS = 4;

const boolean IS_METRIC = true;

// Adjust according to your language
const String WDAY_NAMES[] = {"NIE", "PON", "WTO", "SRO", "CZW", "PIA", "SOB"};
const String MONTH_NAMES[] = {"STY", "LUTY", "MARZ", "KWIE", "MAJ:)", "CZER", "LIP", "SIER", "WRZES", "PAZ", "LIS", "GRU"};

/***************************
* 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;

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 setReadyForWeatherUpdate();


// 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 };
int numberOfFrames = 3;

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

void setup() {
 Serial.begin(115200);
 Serial.println();
 Serial.println();

 // initialize dispaly
 display.init();
 display.clear();
 display.display();

 //display.flipScreenVertically();
 display.setFont(ArialMT_Plain_10);
 display.setTextAlignment(TEXT_ALIGN_CENTER);
 display.setContrast(255);

 WiFi.begin(WIFI_SSID, WIFI_PWD);

 int counter = 0;
 while (WiFi.status() != WL_CONNECTED) {
   delay(500);
   Serial.print(".");
   display.clear();
   display.drawString(64, 10, "LACZE Z WiFi");
   display.drawXbm(46, 30, 8, 8, counter % 3 == 0 ? activeSymbole : inactiveSymbole);
   display.drawXbm(60, 30, 8, 8, counter % 3 == 1 ? activeSymbole : inactiveSymbole);
   display.drawXbm(74, 30, 8, 8, counter % 3 == 2 ? activeSymbole : inactiveSymbole);
   display.display();

   counter++;
 }
 // Get time from network time service
 configTime(TZ_SEC, DST_SEC, "pool.ntp.org");

 ui.setTargetFPS(30);

 ui.setActiveSymbol(activeSymbole);
 ui.setInactiveSymbol(inactiveSymbole);

 // You can change this to
 // TOP, LEFT, BOTTOM, RIGHT
 ui.setIndicatorPosition(BOTTOM);

 // Defines where the first frame is located in the bar.
 ui.setIndicatorDirection(LEFT_RIGHT);

 // You can change the transition that is used
 // SLIDE_LEFT, SLIDE_RIGHT, SLIDE_TOP, SLIDE_DOWN
 ui.setFrameAnimation(SLIDE_LEFT);

 ui.setFrames(frames, numberOfFrames);

 ui.setOverlays(overlays, numberOfOverlays);

 // Inital UI takes care of initalising the display too.
 ui.init();

 Serial.println("");

 updateData(&display);

}

void loop() {

 if (millis() - timeSinceLastWUpdate > (1000L*UPDATE_INTERVAL_SECS)) {
   setReadyForWeatherUpdate();
   timeSinceLastWUpdate = millis();
 }

 if (readyForWeatherUpdate && ui.getUiState()->frameState == FIXED) {
   updateData(&display);
 }

 int remainingTimeBudget = ui.update();

 if (remainingTimeBudget > 0) {
   // You can do some work here
   // Don't do stuff if you are below your
   // time budget.
   delay(remainingTimeBudget);
 }


}

void drawProgress(OLEDDisplay *display, int percentage, String label) {
 display->clear();
 display->setTextAlignment(TEXT_ALIGN_CENTER);
 display->setFont(ArialMT_Plain_10);
 display->drawString(64, 10, label);
 display->drawProgressBar(2, 28, 124, 10, percentage);
 display->display();
}

void updateData(OLEDDisplay *display) {
 drawProgress(display, 10, "Aktualizaczja czasu...");
 drawProgress(display, 30, "Aktualizacja pogody...");
 currentWeatherClient.setMetric(IS_METRIC);
 currentWeatherClient.setLanguage(OPEN_WEATHER_MAP_LANGUAGE);
 currentWeatherClient.updateCurrentById(&currentWeather, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION_ID);
 drawProgress(display, 50, "Aktualizacja prognozy...");
 forecastClient.setMetric(IS_METRIC);
 forecastClient.setLanguage(OPEN_WEATHER_MAP_LANGUAGE);
 uint8_t allowedHours[] = {12};
 forecastClient.setAllowedHours(allowedHours, sizeof(allowedHours));
 forecastClient.updateForecastsById(forecasts, OPEN_WEATHER_MAP_APP_ID, OPEN_WEATHER_MAP_LOCATION_ID, MAX_FORECASTS);

 readyForWeatherUpdate = false;
 drawProgress(display, 100, "Zrobione...");
 delay(1000);
}



void drawDateTime(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
 now = time(nullptr);
 struct tm* timeInfo;
 timeInfo = localtime(&now);
 char buff[16];


 display->setTextAlignment(TEXT_ALIGN_CENTER);
 display->setFont(ArialMT_Plain_10);
 String date = WDAY_NAMES[timeInfo->tm_wday];

 sprintf_P(buff, PSTR("%s, %02d/%02d/%04d"), WDAY_NAMES[timeInfo->tm_wday].c_str(), timeInfo->tm_mday, timeInfo->tm_mon+1, timeInfo->tm_year + 1900);
 display->drawString(64 + x, 5 + y, String(buff));
 display->setFont(ArialMT_Plain_24);

 sprintf_P(buff, PSTR("%02d:%02d:%02d"), timeInfo->tm_hour, timeInfo->tm_min, timeInfo->tm_sec);
 display->drawString(64 + x, 15 + y, String(buff));
 display->setTextAlignment(TEXT_ALIGN_LEFT);
}

void drawCurrentWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
 display->setFont(ArialMT_Plain_10);
 display->setTextAlignment(TEXT_ALIGN_CENTER);
 display->drawString(64 + x, 38 + y, currentWeather.description);

 display->setFont(ArialMT_Plain_24);
 display->setTextAlignment(TEXT_ALIGN_LEFT);
 String temp = String(currentWeather.temp, 1) + (IS_METRIC ? "°C" : "°F");
 display->drawString(60 + x, 5 + y, temp);

 display->setFont(Meteocons_Plain_36);
 display->setTextAlignment(TEXT_ALIGN_CENTER);
 display->drawString(32 + x, 0 + y, currentWeather.iconMeteoCon);
}


void drawForecast(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
 drawForecastDetails(display, x, y, 0);
 drawForecastDetails(display, x + 44, y, 1);
 drawForecastDetails(display, x + 88, y, 2);
}

void drawForecastDetails(OLEDDisplay *display, int x, int y, int dayIndex) {
 time_t observationTimestamp = forecasts[dayIndex].observationTime;
 struct tm* timeInfo;
 timeInfo = localtime(&observationTimestamp);
 display->setTextAlignment(TEXT_ALIGN_CENTER);
 display->setFont(ArialMT_Plain_10);
 display->drawString(x + 20, y, WDAY_NAMES[timeInfo->tm_wday]);

 display->setFont(Meteocons_Plain_21);
 display->drawString(x + 20, y + 12, forecasts[dayIndex].iconMeteoCon);
 String temp = String(forecasts[dayIndex].temp, 0) + (IS_METRIC ? "°C" : "°F");
 display->setFont(ArialMT_Plain_10);
 display->drawString(x + 20, y + 34, temp);
 display->setTextAlignment(TEXT_ALIGN_LEFT);
}

void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
 now = time(nullptr);
 struct tm* timeInfo;
 timeInfo = localtime(&now);
 char buff[14];
 sprintf_P(buff, PSTR("%02d:%02d"), timeInfo->tm_hour, timeInfo->tm_min);

 display->setColor(WHITE);
 display->setFont(ArialMT_Plain_10);
 display->setTextAlignment(TEXT_ALIGN_LEFT);
 display->drawString(0, 54, String(buff));
 display->setTextAlignment(TEXT_ALIGN_RIGHT);
 String temp = String(currentWeather.temp, 1) + (IS_METRIC ? "°C" : "°F");
 display->drawString(128, 54, temp);
 display->drawHorizontalLine(0, 52, 128);
}

void setReadyForWeatherUpdate() {
 Serial.println("Setting readyForUpdate to true");
 readyForWeatherUpdate = true;
}
 
Odpowiedź
#4
WeatherStationImages.h
Kod:
#define WiFi_Logo_width 60
#define WiFi_Logo_height 36
const uint8_t WiFi_Logo_bits[] PROGMEM = {
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00,
 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00,
 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF,
 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00,
 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C,
 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00,
 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C,
 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00,
 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C,
 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00,
 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C,
 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00,
 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F,
 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00,
 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF,
 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00,
 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 };

const uint8_t activeSymbole[] PROGMEM = {
   B00000000,
   B00000000,
   B00011000,
   B00100100,
   B01000010,
   B01000010,
   B00100100,
   B00011000
};

const uint8_t inactiveSymbole[] PROGMEM = {
   B00000000,
   B00000000,
   B00000000,
   B00000000,
   B00011000,
   B00011000,
   B00000000,
   B00000000
};


nie jestem w stanie wrzucić 3 pliku w < > za dużo linijek ma, jakaś pomoc sugestia ?
 
Odpowiedź
#5
Przypadkiem mam cały ten projekt stąd: https://github.com/ThingPulse/esp8266-weather-station. Otworzyłem pierwszy lepszy ze stacją pogodową i się skompilował bez problemu. Jakie masz wersje core Arduino, ESP8266 i biblioteki ArduinoJson? Bo chyba jednak coś sobie zaupdatowałeś "w między czasie"...
Miło być decenianym https://buycoffee.to/kaczakat
 
Odpowiedź
#6
Arduino 1.8.9

ESP8266 NodeMcu V3

[Obrazek: Screenshot-1.png] 
[Obrazek: Screenshot-3.png] 
[Obrazek: Screenshot-6.png] 
[Obrazek: Screenshot-7.png] 
[Obrazek: Screenshot-8.png] 
[Obrazek: Screenshot-9.png] 
[Obrazek: Screenshot-10.png] 
[Obrazek: Screenshot-11.png]
[Obrazek: Screenshot-12.png]
 
Odpowiedź
#7
Widzę, że metoda nie wiem o co chodzi, wkleję wszystko i sobie znajdź. Wersja Arduino 1.8.9 raczej pojawiła się w tym roku w marcu, więc już coś kręcisz. Wersję core ESP znajdziesz w podobnym managerze jak do bibliotek, szukaj liczby typu 2.4.0 2.4.1, 2.5.0, ja mam 2.4.2.
Bibliotekę ArduinoJson zmień sobie na 5.13.2, może potem na coś nowszego, ale na pewno wersje 6 sypały różnymi błędami u mnie i teraz mam konkretnie 5.13.2.
Miło być decenianym https://buycoffee.to/kaczakat
 
Odpowiedź
#8
Przyznaję spanikowałem, przepraszam
Mam wersję 1.8.7 i 1.8.9. W obydwóch mam ustawione esp na 2.4.2, Json na 5.13.2. Nawet z wujkiem google sprawdziłem wszystkie punkty czy mam dobrze powgrywane. Wszystkie stare programy wgrywają się bez problemu tylko z nim mam problem.
Pozmieniałem wersie, nic nie działało, przywróciłem do poprzednich, dalej wyskakuje ten sam błąd, ale teraz dodatkowo na czerwono zaznacza się linijka 454 w WeatherStationFonts.h
to jest w tej linijce
0x11, 0x4E, 0x24, 0x0D, // 167:4430
 
Odpowiedź
#9
Może jednak modyfikowałeś te pliki? Skopiowałem te Twoje i u mnie też się nie kompiluje. Masz całą listę bibliotek, których ja nie mam, a ponadto jest różnica jak je "includujesz".
W przykładzie jest np.:
#include "WeatherStationFonts.h"
#include "WeatherStationImages.h"
i to oznacza, że dodaje je z katalogu projektu, czyli z tych plików zgranych od Ciebie, ale takie użycie jak u Ciebie:
#include <WeatherStationFonts.h>
#include <WeatherStationImages.h>
powoduje szukanie w bibliotekach wgranych do katalogu "libraries". I tu u mnie się wywala, a po poprawie na "" i tak leży na tej całej liście dziwnych bibliotek do SSD1306.
Niestety w takim projekcie to jest teraz zabawa w kopciuszka i wybieranie maku z popiołu. Po prostu wróć do miejsca skąd to wziąłeś i po kolei dodawaj jak za pierwszym razem. Może tylko Ci się wydaje, że kiedyś tę wersję wgrywałeś, a właściwa jest w innym katalogu.
Gotowe przykłady z projektu esp8266-weather-station jeszcze Ci się kompilują?
Miło być decenianym https://buycoffee.to/kaczakat
 
Odpowiedź
#10
Program modyfikowałem podając jedynie nazwę sieci, api dla pogody i zamieniłem angielskie nazwy na polskie które pojawiają się na wyświetlaczu. Nic w nim nie modziłem.
Przejrzałem wszystkie programy które kiedykolwiek napisałem. Wszystkie nawet najdziwniejsze mi działają bezproblemowo. Żaden natomiast związany z pogodą mi nie działa. Ani te co sam robiłem ani już gotowe przykłady z weather master. Jestem pewien że ten program działał, do nazwy każdego programu który zadziała dodaję dopisek -dziala- , a ten go miał. Chyba będzie najlepiej jak wyrzucę IDE i wszystkie biblioteki z dokumentów, zostawię tylko szkice i zacznę wszystko od nowa.
pozdrawiam, znośnego weekendu
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości