- Fri Jun 16, 2023 6:40 am
#96535
Using same INO file with ESP8266.
LOLIN WEMOS D1 R1 ES8266 stong wifi.
Switching between ESP32 and ESP8266
I change includes, pinouts, chipID.
#ifdef ARDUINO_ARCH_ESP8266
#include <ESP8266WiFi.h>
#include <WebSocketsServer.h> //websockes by Markus Sattler ver2.36 & 2.14.2
#include <Time.h>
//#include <ESP_EEPROM.h>
//#include <uEEPROMLib.h>
#endif
#ifdef ARDUINO_ARCH_ESP32
#include <WiFi.h>
#include <WebServer.h>
#include <WebSocketsServer.h> //websockes by Markus Sattler ver2.36 & 2.14.2
#include <Time.h>
#endif
//=============================================================================
#ifdef ARDUINO_ARCH_ESP8266
static const uint8_t p7 = 13;
static const uint8_t p6 = 12;
static const uint8_t p5 = 14;
static const uint8_t p4 = 4;
static const uint8_t p3 = 5;
static const uint8_t p9 = 2;
void ChipID() {
SPn("==============< ESP8266 >================");
Serial.println("Check ID in:");
Serial.println("https://www.wemos.cc/verify_products");
Serial.printf("Chip ID = %08Xn", ESP.getChipId());
Serial.println(" ");
delay(500);
}
#endif
//===============================================================================
#ifdef ARDUINO_ARCH_ESP32
static const uint8_t p7 = 14; // D7
static const uint8_t p6 = 27; // D6
static const uint8_t p5 = 16; // D5
static const uint8_t p4 = 17; // D4
static const uint8_t p3 = 25; // D3
static const uint8_t p9 = 13; // D9
void ChipID() {
SPn("==============< ESP32 >=================");
uint32_t chipId = 0;
for(int i=0; i<17; i=i+8) { chipId = ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i; }
Serial.printf("ESP32 Chip model = %s Rev %d\n", ESP.getChipModel(), ESP.getChipRevision());
Serial.printf("This chip has %d cores\n", ESP.getChipCores());
Serial.print("Chip ID: "); Serial.println(chipId);
delay(500);
}
#endif