I get error. I want to make that showing logo and their value for every crypto. Please help me.
/*******************************************************************
A project to display crypto currency prices using an ESP8266
Main Hardware:
- NodeMCU Development Board (Any ESP8266 dev board will work)
- OLED I2C Display (SH1106)
Written by Brian Lough
https://www.youtube.com/channel/UCezJOfu7OtqGzd5xrP3q6WA
*******************************************************************/
// ----------------------------
// Standard Libraries - Already Installed if you have ESP8266 set up
// ----------------------------
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <Wire.h>
// ----------------------------
// Additional Libraries - each one of these will need to be installed.
// ----------------------------
#include <CoinMarketCapApi.h>
// For Integrating with the CoinMarketCap.com API
// Available on the library manager (Search for "CoinMarket")
// https://github.com/witnessmenow/arduino-coinmarketcap-api
#include "SH1106.h"
// The driver for the OLED display
// Available on the library manager (Search for "oled ssd1306")
// https://github.com/squix78/esp8266-oled-ssd1306
#include <ArduinoJson.h>
// !! NOTE !!: When installing this select an older version than V6 from the drop down
// Required by the CoinMarketCapApi Library for parsing the response
// Available on the library manager (Search for "arduino json")
// https://github.com/squix78/esp8266-oled-ssd1306
// ----------------------------
// Configurations - Update these
// ----------------------------
char ssid[] = "WiFiNetworkName"; // your network SSID (name)
char password[] = "password"; // your network key
// Pins based on your wiring
#define SCL_PIN D5
#define SDA_PIN D3
#define upLED 13
#define downLED 12
#define LOGO_GENISLIK 48
#define LOGO_YUKSEKLIK 48
// CoinMarketCap's limit is "no more than 10 per minute"
// Make sure to factor in if you are requesting more than one coin.
// We'll request a new value just before we change the screen so it's the most up to date
unsigned long screenChangeDelay = 10000; // Every 10 seconds
// Have tested up to 10, can probably do more
#define MAX_HOLDINGS 10
#define CURRENCY "eur" //See CoinMarketCap.com for currency options (usd, gbp etc)
#define CURRENCY_SYMBOL "E" // Euro doesn't seem to work, $ and £ do
// You also need to add your crypto currecnies in the setup function
// ----------------------------
// End of area you need to change
// ----------------------------
WiFiClientSecure client;
CoinMarketCapApi api(client);
SH1106 display(0x3c, SDA_PIN, SCL_PIN);
unsigned long screenChangeDue;
struct Holding {
String tickerId;
float amount;
bool inUse;
const unsigned char logo [288];
CMCTickerResponse lastResponse;
};
Holding holdings[MAX_HOLDINGS];
int currentIndex = -1;
String ipAddressString;
void addNewHolding(String tickerId, const unsigned char logo [288], float amount = 0) {
int index = getNextFreeHoldingIndex();
if (index > -1) {
holdings[index].tickerId = tickerId;
holdings[index].amount = amount;
holdings[index].inUse = true;
holdings[index].logo = logo;
}
}
void setup() {
Serial.begin(115200);
pinMode(upLED, OUTPUT); //Define the LED pin outputs
pinMode(downLED, OUTPUT);
// ----------------------------
// Holdings - Add your currencies here
// ----------------------------
// Go to the currencies coinmarketcap.com page
// and take the tickerId from the URL (use bitcoin or ethereum as an example)
addNewHolding("bitcoin", { 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff,
0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x7f,
0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80,
0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xfe, 0x3f, 0xff, 0xe0, 0x0f, 0xff, 0xfe, 0x73,
0xff, 0xf0, 0x0f, 0xff, 0xfc, 0x63, 0xff, 0xf0, 0x1f, 0xff, 0x0c, 0x63, 0xff, 0xf8, 0x1f, 0xff,
0x00, 0x63, 0xff, 0xfc, 0x3f, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x3f, 0xff, 0xe0, 0x01, 0xff, 0xfc,
0x7f, 0xff, 0xe0, 0x80, 0x7f, 0xfe, 0x7f, 0xff, 0xe0, 0xf0, 0x3f, 0xfe, 0x7f, 0xff, 0xe1, 0xf8,
0x3f, 0xfe, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff,
0xc1, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x7f, 0xff,
0xff, 0xff, 0x82, 0x00, 0xff, 0xff, 0xff, 0xff, 0x83, 0xc0, 0x7f, 0xff, 0xff, 0xff, 0x87, 0xf0,
0x3f, 0xff, 0xff, 0xff, 0x07, 0xf8, 0x3f, 0xff, 0xff, 0xfb, 0x07, 0xf8, 0x3f, 0xff, 0x7f, 0xf8,
0x07, 0xf0, 0x3f, 0xfe, 0x7f, 0xf0, 0x03, 0xf0, 0x3f, 0xfe, 0x7f, 0xf8, 0x00, 0x00, 0x7f, 0xfe,
0x3f, 0xff, 0x80, 0x00, 0x7f, 0xfc, 0x3f, 0xff, 0x88, 0x00, 0xff, 0xfc, 0x3f, 0xff, 0x9c, 0x43,
0xff, 0xfc, 0x1f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff,
0xf8, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xfd, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0,
0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff,
0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x07,
0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00
});
addNewHolding("dogecoin", { 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff,
0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x7f,
0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80,
0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xfe, 0x3f, 0xff, 0xe0, 0x0f, 0xff, 0xfe, 0x73,
0xff, 0xf0, 0x0f, 0xff, 0xfc, 0x63, 0xff, 0xf0, 0x1f, 0xff, 0x0c, 0x63, 0xff, 0xf8, 0x1f, 0xff,
0x00, 0x63, 0xff, 0xfc, 0x3f, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x3f, 0xff, 0xe0, 0x01, 0xff, 0xfc,
0x7f, 0xff, 0xe0, 0x80, 0x7f, 0xfe, 0x7f, 0xff, 0xe0, 0xf0, 0x3f, 0xfe, 0x7f, 0xff, 0xe1, 0xf8,
0x3f, 0xfe, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff,
0xc1, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x7f, 0xff,
0xff, 0xff, 0x82, 0x00, 0xff, 0xff, 0xff, 0xff, 0x83, 0xc0, 0x7f, 0xff, 0xff, 0xff, 0x87, 0xf0,
0x3f, 0xff, 0xff, 0xff, 0x07, 0xf8, 0x3f, 0xff, 0xff, 0xfb, 0x07, 0xf8, 0x3f, 0xff, 0x7f, 0xf8,
0x07, 0xf0, 0x3f, 0xfe, 0x7f, 0xf0, 0x03, 0xf0, 0x3f, 0xfe, 0x7f, 0xf8, 0x00, 0x00, 0x7f, 0xfe,
0x3f, 0xff, 0x80, 0x00, 0x7f, 0xfc, 0x3f, 0xff, 0x88, 0x00, 0xff, 0xfc, 0x3f, 0xff, 0x9c, 0x43,
0xff, 0xfc, 0x1f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff,
0xf8, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xfd, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0,
0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff,
0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x07,
0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00
});
addNewHolding("ethereum", { 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff,
0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x7f,
0xff, 0xff, 0xfe, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80,
0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x07, 0xff, 0xfe, 0x3f, 0xff, 0xe0, 0x0f, 0xff, 0xfe, 0x73,
0xff, 0xf0, 0x0f, 0xff, 0xfc, 0x63, 0xff, 0xf0, 0x1f, 0xff, 0x0c, 0x63, 0xff, 0xf8, 0x1f, 0xff,
0x00, 0x63, 0xff, 0xfc, 0x3f, 0xff, 0x80, 0x07, 0xff, 0xfc, 0x3f, 0xff, 0xe0, 0x01, 0xff, 0xfc,
0x7f, 0xff, 0xe0, 0x80, 0x7f, 0xfe, 0x7f, 0xff, 0xe0, 0xf0, 0x3f, 0xfe, 0x7f, 0xff, 0xe1, 0xf8,
0x3f, 0xfe, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xc1, 0xf8, 0x1f, 0xff, 0xff, 0xff,
0xc1, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xff, 0x80, 0x00, 0x7f, 0xff,
0xff, 0xff, 0x82, 0x00, 0xff, 0xff, 0xff, 0xff, 0x83, 0xc0, 0x7f, 0xff, 0xff, 0xff, 0x87, 0xf0,
0x3f, 0xff, 0xff, 0xff, 0x07, 0xf8, 0x3f, 0xff, 0xff, 0xfb, 0x07, 0xf8, 0x3f, 0xff, 0x7f, 0xf8,
0x07, 0xf0, 0x3f, 0xfe, 0x7f, 0xf0, 0x03, 0xf0, 0x3f, 0xfe, 0x7f, 0xf8, 0x00, 0x00, 0x7f, 0xfe,
0x3f, 0xff, 0x80, 0x00, 0x7f, 0xfc, 0x3f, 0xff, 0x88, 0x00, 0xff, 0xfc, 0x3f, 0xff, 0x9c, 0x43,
0xff, 0xfc, 0x1f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0x18, 0xff, 0xff, 0xf8, 0x0f, 0xff,
0xf8, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xfd, 0xff, 0xff, 0xe0, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0,
0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xff,
0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x07,
0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00
});
// ----------------------------
// Everything below can be thinkered with if you want but should work as is!
// ----------------------------
// Initialising the display
display.init();
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.setFont(ArialMT_Plain_16);
display.drawString(64, 0, F("HODL Display"));
display.setFont(ArialMT_Plain_10);
display.drawString(64, 18, F("By Brian Lough"));
display.display();
// Set WiFi to station mode and disconnect from an AP if it was Previously
// connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
// Attempt to connect to Wifi network:
Serial.print("Connecting Wifi: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
IPAddress ip = WiFi.localIP();
Serial.println(ip);
ipAddressString = ip.toString();
}
int getNextFreeHoldingIndex() {
for (int i = 0; i < MAX_HOLDINGS; i++) {
if (!holdings[i].inUse) {
return i;
}
}
return -1;
}
int getNextIndex() {
for (int i = currentIndex + 1; i < MAX_HOLDINGS; i++) {
if (holdings[i].inUse) {
return i;
}
}
for (int j = 0; j <= currentIndex; j++) {
if (holdings[j].inUse) {
return j;
}
}
return -1;
}
void displayHolding(int index) {
CMCTickerResponse response = holdings[index].lastResponse;
display.clear();
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.setFont(ArialMT_Plain_16);
display.drawString(64, 0, response.symbol);
display.setFont(ArialMT_Plain_24);
double price = response.price_currency;
if (price == 0) {
price = response.price_usd;
}
display.drawString(64, 20, formatCurrency(price));
display.setFont(ArialMT_Plain_16);
// display.setTextAlignment(TEXT_ALIGN_CENTER);
// display.drawString(64, 48, " 1h:" + String(response.percent_change_1h) + "%");
logoCizdir(logo);
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 48, "24h: " + String(response.percent_change_24h) + "%");
display.display();
if (response.percent_change_24h > 0) //If price has increased from yesterday
{
digitalWrite(upLED, HIGH);
digitalWrite(downLED, LOW);
}
else //If price has decreased from yesterday
{
digitalWrite(downLED, HIGH);
digitalWrite(upLED, LOW);
}
}
void logoCizdir(const unsigned char logo []) {
display.drawBitmap(0,
(display.height() + (display.height() / 4) - LOGO_YUKSEKLIK) / 2,
logo, LOGO_GENISLIK, LOGO_YUKSEKLIK, 1);
display.display();
}
void displayMessage(String message){
display.clear();
display.setFont(ArialMT_Plain_10);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawStringMaxWidth(0, 0, 128, message);
display.display();
}
String formatCurrency(float price) {
String formattedCurrency = CURRENCY_SYMBOL;
int pointsAfterDecimal = 6;
if (price > 100) {
pointsAfterDecimal = 2;
} else if (price > 1) {
pointsAfterDecimal = 4;
}
formattedCurrency.concat(String(price, pointsAfterDecimal));
return formattedCurrency;
}
bool loadDataForHolding(int index) {
int nextIndex = getNextIndex();
if (nextIndex > -1 ) {
holdings[index].lastResponse = api.GetTickerInfo(holdings[index].tickerId, CURRENCY);
return holdings[index].lastResponse.error == "";
}
return false;
}
void loop() {
unsigned long timeNow = millis();
if ((timeNow > screenChangeDue)) {
currentIndex = getNextIndex();
if (currentIndex > -1) {
if (loadDataForHolding(currentIndex)) {
displayHolding(currentIndex);
} else {
displayMessage(F("Error loading data."));
}
} else {
displayMessage(F("No funds to display. Edit the setup to add them"));
}
screenChangeDue = timeNow + screenChangeDelay;
}
}
My Fault Code:
SimpleCrypto:88:30: error: use of deleted function 'Holding::Holding()'
88 | Holding holdings[MAX_HOLDINGS];
| ^
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino:80:8: note: 'Holding::Holding()' is implicitly deleted because the default definition would be ill-formed:
80 | struct Holding {
| ^~~~~~~
SimpleCrypto:80:8: error: uninitialized const member in 'struct Holding'
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino:84:21: note: 'const unsigned char Holding::logo [288]' should be initialized
84 | const unsigned char logo [288];
| ^~~~
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino: In function 'void addNewHolding(String, const unsigned char*, float)':
SimpleCrypto:99:26: error: assignment of read-only member 'Holding::logo'
99 | holdings[index].logo = logo;
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino: In function 'void setup()':
SimpleCrypto:132:6: error: cannot convert '<brace-enclosed initializer list>' to 'const unsigned char*'
132 | });
| ^
| |
| <brace-enclosed initializer list>
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino:93:57: note: initializing argument 2 of 'void addNewHolding(String, const unsigned char*, float)'
93 | void addNewHolding(String tickerId, const unsigned char logo [288], float amount = 0) {
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
SimpleCrypto:151:6: error: cannot convert '<brace-enclosed initializer list>' to 'const unsigned char*'
151 | });
| ^
| |
| <brace-enclosed initializer list>
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino:93:57: note: initializing argument 2 of 'void addNewHolding(String, const unsigned char*, float)'
93 | void addNewHolding(String tickerId, const unsigned char logo [288], float amount = 0) {
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
SimpleCrypto:170:6: error: cannot convert '<brace-enclosed initializer list>' to 'const unsigned char*'
170 | });
| ^
| |
| <brace-enclosed initializer list>
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino:93:57: note: initializing argument 2 of 'void addNewHolding(String, const unsigned char*, float)'
93 | void addNewHolding(String tickerId, const unsigned char logo [288], float amount = 0) {
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino: In function 'void displayHolding(int)':
SimpleCrypto:252:16: error: 'logo' was not declared in this scope; did you mean 'logl'?
252 | logoCizdir(logo);
| ^~~~
| logl
D:\COD\BitcoinTicker\Den - Kopya\simple-arduino-crypto-display-master\simple-arduino-crypto-display-master\SimpleCrypto\SimpleCrypto.ino: In function 'void logoCizdir(const unsigned char*)':
SimpleCrypto:269:11: error: 'SH1106' {aka 'class SH1106Wire'} has no member named 'drawBitmap'
269 | display.drawBitmap(0,
| ^~~~~~~~~~
exit status 1
use of deleted function 'Holding::Holding()'