Misterious D1 Mini
Posted: Thu Apr 23, 2020 2:47 pm
Hello guys!
I have successfully coded two NodeMCU-12E with same code, with minor change in static IP and an AP running on ESP32 Wroover. But then decided to exchange the NodeMCU with Wemos D1 Mini Pro, for external antenna option availability only, the code compilation again successful, but the module actualy unable to get connected with AP. When I bypass to use WiFi.mode(WIFI_STA); command, the module brodcasts own firmware SSID, meaning that external antenna onboard switching has been done correctly.
I have successfully coded two NodeMCU-12E with same code, with minor change in static IP and an AP running on ESP32 Wroover. But then decided to exchange the NodeMCU with Wemos D1 Mini Pro, for external antenna option availability only, the code compilation again successful, but the module actualy unable to get connected with AP. When I bypass to use WiFi.mode(WIFI_STA); command, the module brodcasts own firmware SSID, meaning that external antenna onboard switching has been done correctly.
Code: Select all
#include <ESP8266WiFi.h> // Include the Wi-Fi library
#include <ESPAsyncWebServer.h>
const char* ssid = "BOMAG"; // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = "123456789"; // The password of the Wi-Fi network
IPAddress staticIP(192, 168, 4, 30); // Left IP: 192.168.4.20 COM:24 COM:8 Right IP: 192.168.4.30 COM:23 COM:9
IPAddress gateway(192, 168, 4, 1);
IPAddress subnet(255, 255, 255, 0);
int rr;
AsyncWebServer server(80);
String readTemp() {
rr = analogRead(A0);
Serial.println(rr);
return String(rr);
}
void setup() {
Serial.begin(74880); // Start the Serial communication to send messages to the computer
WiFi.config(staticIP, gateway, subnet);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password); // Connect to the network
delay(10);
/*
// *** DATA OF THE MAC (Access Point and Station) of the ESP *** //
Serial.print ("MAC Access Point of this ESP:"); Serial.println (WiFi.softAPmacAddress ());
Serial.print ("Station MAC of this ESP:"); Serial.println (WiFi.macAddress ());
WiFi.printDiag(Serial);
while (WiFi.status() != WL_CONNECTED) {
Serial.print('.');
delay(500);
}
Serial.println('Connected');
*/
server.on("/readsensor", HTTP_GET, [](AsyncWebServerRequest * request) {
request->send_P(200, "text/plain", readTemp().c_str());
});
// Start server
server.begin();
}
void loop() {}