Problem: I have been building the script using ChatGPT, at the beginning it works perfectly, it compiles well in the Arduino 2.0 IDE, it uploads the information to the esp32, it starts the code, it connects to my Wi-Fi network, It pings Google to check if the connection is stable and if there is an internet connection, but when the time comes to connect to any pool, be it Binance, Heromiers, or Unmineable, the problem is the same.
Script:
- #include <WiFi.h>
- #include <WiFiClient.h>
- #include "C:\\Users\\Admin\\Documents\\Arduino\\libraries\\ESPping\\src\\ESPPing.h"
- // WiFi credentials
- const char* WIFI_SSID = "XXX"; // I have put the Xs to hide my data.
- const char* WIFI_PASSWORD = "XXXXXXXXX"; // I have put the Xs to hide my data.
- // Mining pool information
- const char* POOL_ADDRESS = "stratum+tcp://rvn.poolbinance.com";
- const uint16_t PORT = 9000;
- // Wallet address
- const char* WALLET_ADDRESS = "RAcERdEbNAMZGLCegjEi1wJyqgpiEvjbs8";
- WiFiClient client;
- // LED pin
- const int LED_PIN = 2;
- // Connection timeout in milliseconds
- const unsigned long CONNECTION_TIMEOUT = 10000;
- // Task start time
- unsigned long taskStartTime = 0;
- void setup() {
- Serial.begin(115200);
- pinMode(LED_PIN, OUTPUT);
- Serial.println("Starting...");
- connectToWiFi();
- }
- void connectToWiFi() {
- Serial.print("Connecting to WiFi: ");
- WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
- unsigned long startTime = millis();
- while (WiFi.status() != WL_CONNECTED && millis() - startTime < CONNECTION_TIMEOUT) {
- Serial.print(".");
- delay(1000);
- }
- if (WiFi.status() == WL_CONNECTED) {
- Serial.println("\nWiFi connected.");
- if (checkInternetConnection()) {
- Serial.println("Internet connection established.");
- if (checkInternetConnection()) {
- Serial.println("Internet connection established after first verification.");
- mineRavencoin();
- } else {
- Serial.println("Failed to establish internet connection after first verification.");
- }
- } else {
- Serial.println("Failed to establish internet connection.");
- }
- } else {
- Serial.println("Failed to connect to WiFi.");
- }
- }
- bool checkInternetConnection() {
- Serial.print("Pinging google.com... ");
- digitalWrite(LED_PIN, HIGH);
- IPAddress googleDNS(8, 8, 8, 8);
- bool success = Ping.ping(googleDNS);
- digitalWrite(LED_PIN, LOW);
- return success;
- }
- void mineRavencoin() {
- Serial.println("Connecting to mining pool...");
- unsigned int connectionAttempts = 0;
- while (connectionAttempts < 3) {
- Serial.print("Connection attempt #");
- Serial.println(connectionAttempts + 1);
- unsigned long startTime = millis();
- while (!client.connect(POOL_ADDRESS, PORT) && millis() - startTime < CONNECTION_TIMEOUT) {
- Serial.println("Connecting...");
- delay(1000);
- blinkLED();
- }
- if (client.connected()) {
- Serial.println("Connected to mining pool.");
- client.println("mining.subscribe " + String(WALLET_ADDRESS));
- break;
- } else {
- Serial.println("Connection failed.");
- Serial.println("Server response:");
- while (client.available()) {
- String line = client.readStringUntil('\n');
- Serial.println(line);
- }
- connectionAttempts++;
- }
- }
- if (client.connected()) {
- digitalWrite(LED_PIN, HIGH);
- taskStartTime = millis();
- } else {
- Serial.println("Mining has ended.");
- }
- }
- void blinkLED() {
- digitalWrite(LED_PIN, HIGH);
- delay(100);
- digitalWrite(LED_PIN, LOW);
- delay(100);
- }
- void loop() {
- if (client.connected()) {
- if (millis() - taskStartTime >= 1000) {
- digitalWrite(LED_PIN, !digitalRead(LED_PIN));
- taskStartTime = millis();
- }
- // Adjust the blink rate based on the mining speed
- // Code to adjust blink rate based on mining speed
- } else {
- digitalWrite(LED_PIN, LOW);
- }
- // Add other tasks in the loop if necessary
- }
I have already checked that the pool data is correct, I have checked that my WiFi is working correctly, The ESP32 firmware is updated and compatible with the version of the Arduino IDE and the libraries that I am using.Trying to connect...
Trying to connect...
Trying to connect...
Trying to connect...
Connection failure
Server response:
Connection attempt #3
Trying to connect...
Trying to connect...
Trying to connect...
Trying to connect...
Trying to connect...
Trying to connect...
Trying to connect...
Trying to connect...
Connection failure
Server response:
Mining has ended
Can someone help me with this? I promise to send a photo when the MiniRig is lighting up more than a Christmas tree next to my PC xD.
Thank you and I hope for a prompt response, I have used Google Translator, my native language is Spanish.