#ifdef ESP32 #include #include #include #else #include #include #include #endif #include #include #include #include #include int pinCS = D4; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI ) int numberOfHorizontalDisplays = 4; int numberOfVerticalDisplays = 1; DynamicJsonBuffer jsonBuffer; // LED Matrix Pin -> ESP8266 Pin // Vcc -> 3v (3V on NodeMCU 3V3 on WEMOS) // Gnd -> Gnd (G on NodeMCU) // DIN -> D7 (Same Pin for WEMOS) // CS -> D4 (Same Pin for WEMOS) // CLK -> D5 (Same Pin for WEMOS) Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays); int wait = 100; // In milliseconds int zaehler = -1; // https://www.finanzen.net/aktien/Tesla-Aktie char* coins[] = {"share:Tesla-Aktie", "share:BVB-Aktie", "bitcoin", "ethereum", "dash", "pivx", "verge"}; String text = "CONNECTING..."; String coin = ""; String coinText = ""; String coinSymbol = ""; int arraySize = 0; int spacer = 1; int width = 5 + spacer; // The font width is 5 pixels void setup() { Serial.begin(115200); WiFi_Setup(); matrix.setIntensity(0); // Use a value between 0 and 15 for brightness matrix.setRotation(0, 1); // The first display is position upside down matrix.setRotation(1, 1); // The first display is position upside down matrix.setRotation(2, 1); // The first display is position upside down matrix.setRotation(3, 1); // The first display is position upside down } void loop() { matrix.fillScreen(LOW); Serial.println(zaehler); if (zaehler == -1) { display_message(text); delay(2000); zaehler = 1; } else if (zaehler == 0) { zaehler = 10; if (WiFi.status() == WL_CONNECTED) { HTTPClient http; text = ""; arraySize = sizeof(coins) / sizeof(char *); for (int i = 0; i < arraySize; i++) { coin = String(coins[i]); coinText = ""; coinSymbol = ""; Serial.println(i); http.begin("http://coin.blessuren.de/get.php?coin=" + coin); int httpCode = http.GET(); if (httpCode > 0) { coinText = http.getString(); if(coin.indexOf(':') < 0) { JsonArray& array = jsonBuffer.parseArray(coinText); JsonObject& root = jsonBuffer.parseObject(array.get(0)); coinText = root["price_usd"].as(); // or price_eur coinSymbol = root["symbol"].as(); coinText = coinSymbol + ":$" + coinText.substring(0, coinText.indexOf('.') + 3); // 4 = 3 digits after . 3 = 2 digits after . jsonBuffer.clear(); } } else { text = "HTTPS Error"; } http.end(); text = text + ' ' + coinText; } } } zaehler--; display_message(text); } void display_message(String message) { for ( int i = 0 ; i < width * message.length() + matrix.width() - spacer; i++ ) { //matrix.fillScreen(LOW); int letter = i / width; int x = (matrix.width() - 1) - i % width; int y = (matrix.height() - 8) / 2; // center the text vertically while ( x + width - spacer >= 0 && letter >= 0 ) { if ( letter < message.length() ) { matrix.drawChar(x, y, message[letter], HIGH, LOW, 1); // HIGH LOW means foreground ON, background off, reverse to invert the image } letter--; x -= width; } matrix.write(); // Send bitmap to display delay(wait / 2); } } void WiFi_Setup() { WiFiManager wifiManager; // Connect to Wi-Fi // A new OOB ESP has no Wi-Fi credentials so will connect and not need the next command to be uncommented and compiled in, a used one with incorrect credentials will // so restart the ESP and connect your PC to the wireless access point called 'ESP_AP' or whatever you call it below in "" // wifiManager.resetSettings(); // Command to be included if needed, then connect to http://192.168.4.1/ and follow instructions to make the WiFi connection // Set a timeout until configuration is turned off, useful to retry or go to sleep in n-seconds wifiManager.setTimeout(180); //fetches ssid and password and tries to connect, if connections succeeds it starts an access point with the name called "ESP8266_AP" and waits in a blocking loop for configuration if (!wifiManager.autoConnect("ESP_AP")) { Serial.println(F("failed to connect and timeout occurred")); delay(6000); ESP.restart(); //reset and try again } // At this stage the WiFi manager will have successfully connected to a network, or if not will try again in 180-seconds Serial.println(F("WiFi connected...")); //---------------------------------------------------------------------- Serial.println(F("Use this URL to connect: http://")); Serial.println(WiFi.localIP().toString() + "/"); // Print the IP address }