Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
revoxhere
GitHub Repository: revoxhere/duino-coin
Path: blob/master/ESP_Code/Settings.h
925 views
1
// Settings.h
2
#ifndef SETTINGS_H
3
#define SETTINGS_H
4
5
// ---------------------- General settings ---------------------- //
6
// Change the part in brackets to your Duino-Coin username
7
extern char *DUCO_USER = "my_cool_username";
8
// Change the part in brackets to your mining key (if you have set it in the wallet)
9
extern char *MINER_KEY = "mySecretPass";
10
// Change the part in brackets if you want to set a custom miner name
11
// Use Auto to autogenerate, None for no custom identifier
12
extern char *RIG_IDENTIFIER = "None";
13
// Change the part in brackets to your WiFi name
14
extern const char SSID[] = "SSID";
15
// Change the part in brackets to your WiFi password
16
extern const char PASSWORD[] = "PASSW0RD";
17
// -------------------------------------------------------------- //
18
19
// -------------------- Advanced options ------------------------ //
20
// Uncomment if you want to host the dashboard page (available on ESPs IP address and mDNS)
21
// #define WEB_DASHBOARD
22
23
// Comment out the line below if you wish to disable LED blinking
24
#define LED_BLINKING
25
26
// Uncomment if you want to use LAN8720. WLAN-credentials will be ignored using LAN
27
// Select correct Board in ArduinoIDE!!! Really!
28
// #define USE_LAN
29
30
// Comment out the line below if you wish to disable Serial printing
31
#define SERIAL_PRINTING
32
33
// Edit the line below if you wish to change the serial speed (low values may reduce performance but are less prone to interference)
34
#define SERIAL_BAUDRATE 500000
35
36
// ESP8266 WDT loop watchdog. Do not edit this value, but if you must - do not set it too low or it will falsely trigger during mining!
37
#define LWD_TIMEOUT 30000
38
39
// Uncomment to disable ESP32 brownout detector if you're suffering from faulty insufficient power detection
40
// #define DISABLE_BROWNOUT
41
42
// Uncomment to enable WiFiManager captive portal in AP mode
43
// The board will create its own network you connect to and change the settings
44
// REQUIRES WiFiManager library by tzapu (https://github.com/tzapu/WiFiManager)
45
// #define CAPTIVE_PORTAL
46
// -------------------------------------------------------------- //
47
48
// ------------------------ Displays ---------------------------- //
49
50
// Uncomment to enable a SSD1306 OLED screen on the I2C bus to display mining info in real time
51
// Default connections (can be overriden by using a different u8g2 initializer, see line 140):
52
// GND - GND
53
// VCC - 5V or 3.3V depending on display
54
// SCL - GPIO22 (ESP32) or GPIO5 (D2 on ESP8266) or GPIO35 (ESP32-S2)
55
// SDA - GPIO21 (ESP32) or GPIO4 (D1 on ESP8266) or GPIO33 (ESP32-S2)
56
// #define DISPLAY_SSD1306
57
58
// Uncomment to enable a 16x2 LCD screen on a direct bus to display mining info in real time
59
// See line 150 for connections and initializer
60
// #define DISPLAY_16X2
61
62
// Uncomment if your device is a Duino BlushyBox device
63
// #define BLUSHYBOX
64
// -------------------------------------------------------------- //
65
66
// ---------------------- IoT examples -------------------------- //
67
// https://github.com/revoxhere/duino-coin/wiki/Duino's-take-on-the-Internet-of-Things
68
69
// Uncomment the line below if you wish to use the internal temperature sensor (Duino IoT example)
70
// Only ESP32-S2, -S3, -H2, -C2, -C3, -C6 and some old models have one!
71
// More info: https://www.espboards.dev/blog/esp32-inbuilt-temperature-sensor/
72
// NOTE: Mining performance will decrease by about 20 kH/s!
73
// #define USE_INTERNAL_SENSOR
74
75
// Uncomment the line below if you wish to use a DS18B20 temperature sensor (Duino IoT example)
76
// NOTE: Mining performance should stay the same
77
// #define USE_DS18B20
78
79
// Uncomment the line below if you wish to use a DHT11/22 temperature and humidity sensor (Duino IoT example)
80
// NOTE: Mining performance should stay the same
81
// #define USE_DHT
82
83
// Uncomment the line below if you wish to use a HSU07M sensor (Duino IoT Example)
84
// NOTE: Untested as of right now
85
// #define USE_HSU07M
86
// -------------------------------------------------------------- //
87
88
// ---------------- Variables and definitions ------------------- //
89
// You generally do not need to edit stuff below this line
90
// unless you're know what you're doing.
91
92
#if defined(ESP8266)
93
// ESP8266
94
#define LED_BUILTIN 2
95
#elif defined(CONFIG_FREERTOS_UNICORE)
96
#if defined(CONFIG_IDF_TARGET_ESP32C3)
97
// ESP32-C3
98
#define LED_BUILTIN 8
99
#else
100
// ESP32-S2
101
#define LED_BUILTIN 15
102
#endif
103
#else
104
// ESP32
105
#ifndef LED_BUILTIN
106
#define LED_BUILTIN 2
107
#endif
108
#if defined(BLUSHYBOX)
109
#define LED_BUILTIN 4
110
#endif
111
#endif
112
113
#define BLINK_SETUP_COMPLETE 2
114
#define BLINK_CLIENT_CONNECT 5
115
116
#define SOFTWARE_VERSION "4.3"
117
extern unsigned int hashrate = 0;
118
extern unsigned int hashrate_core_two = 0;
119
extern unsigned int difficulty = 0;
120
extern unsigned long share_count = 0;
121
extern unsigned long accepted_share_count = 0;
122
extern String node_id = "";
123
extern String WALLET_ID = "";
124
extern unsigned int ping = 0;
125
126
#if defined(USE_INTERNAL_SENSOR)
127
#include "driver/temp_sensor.h"
128
#endif
129
130
#if defined(USE_DS18B20)
131
// Install OneWire and DallasTemperature libraries if you get an error
132
#include <OneWire.h>
133
#include <DallasTemperature.h>
134
// Change 12 to the pin you've connected your sensor to
135
const int DSPIN = 12;
136
137
OneWire oneWire(DSPIN);
138
DallasTemperature extern sensors(&oneWire);
139
#endif
140
141
#if defined(USE_DHT)
142
// Install "DHT sensor library" if you get an error
143
#include <DHT.h>
144
// Change 12 to the pin you've connected your sensor to
145
#define DHTPIN 12
146
// Set DHT11 or DHT22 type accordingly
147
#define DHTTYPE DHT11
148
149
DHT extern dht(DHTPIN, DHTTYPE);
150
#endif
151
152
#if defined(DISPLAY_SSD1306)
153
// Install "u8g2" if you get an error
154
#include <U8g2lib.h>
155
#include <Wire.h>
156
// Display definition from the U8G2 library. Edit if you use a different display
157
// For software I2C, use ..._F_SW_I2C and define the pins in the initializer
158
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
159
#endif
160
161
#if defined(DISPLAY_16X2)
162
#include "Wire.h"
163
// Install "Adafruit_LiquidCrystal" if you get an error
164
#include "Adafruit_LiquidCrystal.h"
165
166
// initialize the library with the numbers of the interface pins
167
// RS E D4 D5 D6 D7
168
Adafruit_LiquidCrystal lcd(1, 2, 3, 4, 5, 6);
169
#endif
170
171
#if defined(USE_HSU07M)
172
#include "Wire.h"
173
#define HSU07M_ADDRESS 0x4B // Change this if your sensor has a different address
174
175
float read_hsu07m() {
176
Wire.beginTransmission(HSU07M_ADDRESS);
177
Wire.write(0x00);
178
Wire.endTransmission();
179
delay(100);
180
Wire.requestFrom(HSU07M_ADDRESS, 2);
181
if(Wire.available() >= 2) {
182
byte tempMSB = Wire.read();
183
byte tempLSB = Wire.read();
184
int tempRaw = (tempMSB << 8) | tempLSB;
185
float tempC = (tempRaw / 16.0) - 40.0;
186
return tempC;
187
}
188
return -1.0;
189
}
190
#endif
191
192
#if defined(BLUSHYBOX)
193
#define GAUGE_PIN 5
194
#define GAUGE_MAX 190
195
#define GAUGE_MIN 0
196
#if defined(ESP8266)
197
#define GAUGE_MAX_HR 80000
198
#else
199
#define GAUGE_MAX_HR 200000
200
#endif
201
extern float hashrate_old = 0.0;
202
203
void gauge_set(float hashrate) {
204
float old = hashrate_old;
205
float new_val = hashrate;
206
207
if (hashrate_old == 0) {
208
float delta = (new_val - old) / 50;
209
for (int x=0; x < 50; x++) {
210
analogWrite(5, map(old + x*delta, 0, GAUGE_MAX_HR, GAUGE_MIN, GAUGE_MAX) + random(0, 10));
211
delay(20);
212
}
213
} else {
214
float delta = (new_val - old) / 10;
215
for (int x=0; x < 10; x++) {
216
analogWrite(5, map(old + x*delta, 0, GAUGE_MAX_HR, GAUGE_MIN, GAUGE_MAX) + random(0, 10));
217
delay(10);
218
}
219
}
220
hashrate_old = hashrate;
221
}
222
#endif
223
224
IPAddress DNS_SERVER(1, 1, 1, 1); // Cloudflare DNS server
225
226
#endif // End of SETTINGS_H
227
228