The WeMos D1 R2 Uno based ESP8266 a wireless 802.11 (Wifi) microcontroller development board compatible with the Arduino IDE. It turns the very popular ESP8266 wireless (WiFi) module into a fully fledged development board. The layout of this board is based on a standard Arduino hardware design with similar proportions to the Arduino Uno and Leonardo. It also includes a set of standard Arduino headers which means many existing Arduino shields can be plugged directly into the board (see note below).
The development board also includes a CH340 USB to serial interface giving it the ability to be connected and programmed directly from your computer and requiring only a common micro USB cable – no additional interface hardware or configuring is required. Once connected to the computer, and drivers have been installed, the WeMos D1 will appear as a standard serial COM port. The WeMos D1 can be programmed directly from the Arduino Integrated Development Environment (IDE) which is freely available for download from the Arduino website (arduino.cc).
Direct Arduino IDE support for this development board can be added with just a few mouse clicks via the built-in board manager feature. Programming the WeMos D1 via the IDE is then as straight-forward as programming any standard Arduino development board. Many of the default Arduino commands will work including digital and analogue pin functions and many examples are included in the IDE which demonstrate how to take advantage of the ESP8266s WiFi capabilities. These examples range from simply blinking an LED to turning the WeMos D1 into a stand-alone web server.
The pin mapping is different compared to standard Arduino Uno Board. Here are three basic examples to show you how to use WeMos's digital pins, analog pin as well as PWM feature.
Digital Pin
The Arduino-compatible pin is printed at the front of the board and the ESP8266 chip pins (GPIO) number is printed at the back of th board. In the Arduino IDE, you can refer the Arduino-compatible pins by using D0 to D15 or the ESP8266 GPIO pin's number directly.
- 11 digital input/output pins, all pins have interrupt/pwm/I2C/one-wire supported(except D0)
- Although there are total 16 pins from D0 to D15. some pins are the same. for example, For Pin D4 and D14, they are all connected to GPIO14.
Analog Pin
ESP8266 has one ADC pin (A0) that is easily accessible. This means that ESP8266 board can read analog signals. In this tutorial we’ll show you how to use analog reading with the ESP8266 using Arduino IDE.
The ADC pin has a 10-bit resolution, which means you’ll get values between 0 and 1024.
- 1 analog input (3.3V max input)
- 10-bit resolution, value from 0 - 1024
We are going to read the light sensor from analog pin and map the reading value to 0 to 255.