auto connect to multiple wifi connections
Posted: Wed Mar 02, 2022 8:01 pm
Hi all i got some code and want the create a portable miner so when i get to a location my miner will automatically connect to the wifi. can anyone help.. i have downloaded the miner code just not sure how to create this. i have also looked at a repeater but thats another miner taken up. i was hoping todo this in the code.. if this is successful im looking at making 4 module system..
i will include my steps and progress on here
i will include my steps and progress on here
Code: Select all
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <ESP8266Ping.h>
const char *ssid1 = "candyxt";// X
const char *password1 = "candyxt123";
const char *ssid2 = "candyasus";
const char *password2 = "candyasus123";
//#define TCP_MSS whatever
//#define LWIP_IPV6 whatever
//#define LWIP_FEATURES whatever
//#define LWIP_OPEN_SRC whatever
#define led D1
const IPAddress remote_ip(208, 80, 153, 224);
//const IPAddress remote_ip(8, 8, 8, 8); //Google
void setup() {
Serial.begin(9600);
while (WiFi.status() == WL_DISCONNECTED) {
myNetwork();
}
Serial.println("Successfully Connected ");
}
void myNetwork() {
int flag = 1;
Serial.println("Searching Wifi......");
int network = WiFi.scanNetworks(); //5
for (int i = 0 ; i < network; i++) {
switch (flag) {
case 1:
flag =2;
if (WiFi.SSID(i) == ssid1) {
WiFi.begin(ssid1, password1);
Serial.println("/n Wifi Found");
delay(2000);
Serial.println("Connecting with candyxt Please Wait ");
delay(8000);
break;
}
case 2:
flag =1;
if (WiFi.SSID(i) == ssid2) {
WiFi.begin(ssid2, password2);
Serial.println("/n Wifi Found");
delay(2000);
Serial.println("Connecting with candyasus Please Wait ");
delay(8000);
break;
}
}
}
}
void loop() {
if (!Ping.ping(remote_ip)) {
Serial.println("No Internet");
myNetwork();
} else {
Serial.println("Internet Access");
}
}
//im wanting to add the mining code here. after the wifi connection is made.