Wemos D1 Mini ESP32 / ESP8266 compatibilty snippet

All that relates to the H/W
Post Reply
User avatar
Electroguard
Posts: 836
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 268 times
Been thanked: 317 times

Wemos D1 Mini ESP32 / ESP8266 compatibilty snippet

Post by Electroguard »

I often start my projects using a wemos D1 mini esp8266 which may subsequently get swapped out for an ESP32 if more resources are needed.
The inner rows of both are mostly hardware compatible (see below), so its mainly just the gpio pin-numbering which varies, not the pin hardware functionality.
So the same script can automatically cater for either esp8266 or esp32 by specifying the appropriate pin numbers for the device.
The snippet below automatically sets a variable depending on the device type found, allowing the script to subsequently designate the appropriate pins for the device, as shown by the lines following it (which are from my Sentry Alarm).

'ESP test snippet: annex32=0 for an esp8266, annex32=1 for an esp32
annex32=0
onerror skip
print adc(39): annex32=1 'or can use wlog instead of print
if annex32=1 then wlog "esp32" else wlog "esp8266"

if annex32=1 then i2c.setup 21,22 else i2c.setup 4,5 'i2c SDA and SCL pins need to be configured as appropriate
if annex32=0 then serial2.mode 9600,13,12 else serial2.mode 9600,33,34 'Software serial2 TX & RX
if annex32=1 then TM1637.SETUP 17,16,100 else TM1637.SETUP 0,2,100


I use long-pin headers on the inside rows of wemos D1 compatible ESP32's so they can take Wemos esp8266 footprint expansion modules.
For instance a wemos 8266 DC Module can supply the ESP32 from voltages ranging from 6v to over 20v using any handy DC mains adapter with DC Jack, or screw-terminal wires. Its also handy to be able to quickly plug in a relay module, or different sensors.
A wemos 'tripler' base can take a stacked ESP32 at one end, plus a stack of wemos modules at the other end, allowing quick prototyping without wires.
The ESP32 extra outer pins can still be accessed using pins below or headers above where convenient, without interfering with the inner rows esp8266 hardware compatibility.
D1_mini_ESP32_pinout.png
You do not have the required permissions to view the files attached to this post.
Post Reply