ESP8266 WeMos D1 mini - MohanadSinan/IoT-Based-Healthcare-System GitHub Wiki

ESP8266 WeMos D1 mini ESP8266 WeMos D1 mini pins

Specifications

  • 11 digital input/output pins, all pins have interrupt/pwm/I2C/one-wire supported (except D0).
  • 1 analog input(3.3V max input).
  • A Micro USB connection.

Technical specs

Microcontroller ESP-8266EX
Operating Voltage 3.3V
Digital I/O Pins 11
Analog Input Pins 1
Clock Speed 80MHz/160MHz
FLash 4M bytes
Length 34.2mm
Width 25.6mm
Weight 10g

Pin Configuration

Pin Function ESP-8266 Pin
TX TXD TXD
RX RXD RXD
A0 Analog input, max 3.3V input A0
D0 IO GPIO16
D1 IO, SCL GPIO5
D2 IO, SDA GPIO4
D3 IO,10k Pull-up GPIO0
D4 IO, 10k pull-up, BUILTIN_LED GPIO2
D5 IO, SCK GPIO14
D6 IO, MISO GPIO12
D7 IO, MOSI GPIO13
D8 IO,10k pull-down, SS GPIO15
G Ground GND
5V 5V
3V3 3.3V 3.3V
RST Reset RST

All IO have interrupt/pwm/I2C/one-wire supported(except D0).

All of the IO pins run at 3.3V.

Pins definition for Arduino (pins_arduino.h):

#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#define PIN_WIRE_SDA (4)
#define PIN_WIRE_SCL (5)

static const uint8_t SDA = PIN_WIRE_SDA;
static const uint8_t SCL = PIN_WIRE_SCL;

#define LED_BUILTIN 2

static const uint8_t D0   = 16;
static const uint8_t D1   = 5;
static const uint8_t D2   = 4;
static const uint8_t D3   = 0;
static const uint8_t D4   = 2;
static const uint8_t D5   = 14;
static const uint8_t D6   = 12;
static const uint8_t D7   = 13;
static const uint8_t D8   = 15;
static const uint8_t RX   = 3;
static const uint8_t TX   = 1;

#include "../generic/common.h"

#endif

Schematic

Drivers

When you connect the WeMOS D1 mini board for the first time on your Windows computer through a USB cable, it might be the case to install a USB-to-SERIAL driver.

The board has a USB-to-SERIAL converter (CH340 chip).

The driver is available for download below:

Programming

Programming your D1mini ESP8266 in ArduinoIDE:

  • use Arduino IDE 1.6.5.
  • check your additional board URL from file->preferences.
http://arduino.esp8266.com/stable/package_esp8266com_index.json
  • check D1 mini board.
  • select the speed of communication between the WeMos-D1R2 and the computer. Go to Tools / Upload Speed: and select 115200.
  • We are ready to upload our first sketch.

Code

Blink example:

Turns on the onboard LED on for one second, then off for one second, repeatedly. This uses delay() to pause between LED toggles.

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);  // initialize onboard LED as output
}

void loop() {
  digitalWrite(BUILTIN_LED, HIGH);  // turn on LED with voltage HIGH
  delay(1000);                      // wait one second
  digitalWrite(BUILTIN_LED, LOW);   // turn off LED with voltage LOW
  delay(1000);                      // wait one second
}

scanning the available WiFi networks example:

#include "ESP8266WiFi.h"

void setup() {
  Serial.begin(115200);

  // Set WiFi to station mode and disconnect from an AP if it was previously connected
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  Serial.println("Setup done");
}

void loop() {
  Serial.println("scan start");

  // WiFi.scanNetworks will return the number of networks found
  int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0) {
    Serial.println("no networks found");
  } else {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i) {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
      delay(10);
    }
  }
  Serial.println("");

  // Wait a bit before scanning again
  delay(5000);
}