160MHz
64K RAM Instruction
96K RAM Data
4MB FLASH
WIFI
11 GPIO pins
1 Analog Input pin 2, 10-bit, input range is 0 to 3.3V , sample rate 200Hz
ALSO SEE ESP8266 OLED WiFi Development Board
D1mini Development Board Pin Out
Programmed use the Arduino IDE and download add-on
http://ardunio.esp8266.com/stable/package_esp8266com_index.json
goto boards and download ESP8266
NOTE ARDUNIO uses different PINs so will need to change the oin numbers
External link to esp8266 gpio pin allocations
usb2.0-serial
Connecting the D1 Mini to a windows PC you will need a serial driver installed
Try CH341 USB to serial WINDOWS drivers and DLL dynamic library
The NodeMCU is an open-source firmware and development kit that helps you to prototype your IoT product within a few Lua script lines. Formore details, please visit
www.nodemcu.com, and https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en
Less than $2 WI-FI MCU ESP8266 integrated and esay to prototyping development kit.
The Development Kit based on ESP8266, integrates GPIO, PWM, IIC, 1-Wire and ADC all in one board.
USB-TTL included, plug&play
10 GPIO, every GPIO can be PWM, I2C, 1-wire
PCB antenna
Connect to the wireless network
print(wifi.sta.getip())
--nil
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","password")
print(wifi.sta.getip())
--192.168.18.110
Connect to the wireless network
print(wifi.sta.getip())--nil wifi.setmode(wifi.STATION) wifi.sta.config("SSID","password") print(wifi.sta.getip())--192.168.18.110
HTTP Client
-- A simple http client conn=net.createConnection(net.TCP, false) conn:on("receive", function(conn, pl) print(pl) end) conn:connect(80,"121.41.33.127") conn:send("GET / HTTP/1.1\r\nHost: www.nodemcu.com\r\n" .."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
http://arduino.esp8266.com/stable/package_esp8266com_index.json
NOTE if the above fails to load try this
https://github.com/esp8266/Arduino/releases/download/2.3.0/package_esp8266com_index.json
http://www.esp8266learning.com/wemos-webserver-example.php
Over The Air (OTA) WiFi updating
ONCE working Over The Air (OTA) reprogramming can be used to upload or change the program
Python 2.7 is needed
https://github.com/G6EJD/ESP8266-Over-The_air-OTA-Updating
NOTE 1: If you do not get a Tools Port network address it may be Win10 needs to enable Multicast
NOTE 2: If the Arduino will not load libraries; it may be Win10 needs to enabled by typing the following in a command prompt : setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true
OTA Boot loader sketch
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
// NOTES
// the D1 mini must have been programed to receive OTA (SEE D1_mini_OTA)
// To send OTA use Tools to select Port as used by ArduinoOTA.setHostname
// A password may have been set in the OTA code ArduinoOTA.setPassword
const char* ssid = "PLUSNET-X7XQ";
const char* password = "d35d396ea6";
const char* host = "esp8266-339f2a";
OTA example sketch
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
// NOTES
// the D1 mini must have been programed to receive OTA (SEE D1_mini_OTA)
// To send OTA use Tools to select Port as used by ArduinoOTA.setHostname
// A password may have been set in the OTA code ArduinoOTA.setPassword
const char* ssid = "PLUSNET-X7XQ";
const char* password = "d35d396ea6";
const char* host = "esp8266-339f2a";
int led_pin = 13; // GPIO13 D7
unsigned long previousMillis = 0; // will store last time LED was updated
long interval = 1000; // interval at which to blink (milliseconds)
int ledState = LOW; // ledState used to set the LED
const int analogInPin = A0; // ESP8266
int sensorValue;
#define N_DIMMERS 3
int dimmer_pin[] = {14, 5, 15}; // D5, D1, D8
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
/* switch on led */
pinMode(led_pin, OUTPUT);
digitalWrite(led_pin, LOW);
Serial.println("");
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED){
WiFi.begin(ssid, password);
Serial.println("Retrying connection...");
}
/* switch off led */
digitalWrite(led_pin, HIGH);
/* configure dimmers, and OTA server events */
analogWriteRange(1000);
analogWrite(led_pin,990);
for (int i=0; i<N_DIMMERS; i++)
{
pinMode(dimmer_pin[i], OUTPUT);
analogWrite(dimmer_pin[i],50);
}
ArduinoOTA.setHostname(host);
ArduinoOTA.onStart([]() { // switch off all the PWMs during upgrade
for(int i=0; i<N_DIMMERS;i++)
analogWrite(dimmer_pin[i], 0);
analogWrite(led_pin,0);
});
ArduinoOTA.onEnd([]() { // do a fancy thing with our board led at end
for (int i=0;i<30;i++)
{
analogWrite(led_pin,(i*100) % 1001);
delay(50);
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on noting the LED needs a pin to be low for it to illuminate
delay(100); // Wait for a time
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the pin HIGH
delay(100); // Wait for a time
}
});
// Add support for OTA
ArduinoOTA.onError([](ota_error_t error) { ESP.restart(); });
/* setup the OTA server */
ArduinoOTA.begin();
// ----- Sketch as normal from here -----
Serial.println("Ready");
}
void loop() {
ArduinoOTA.handle(); // Add support for OTA
// ----- Sketch as normal from here -----
// Try to avoid delays in code so OTA updates are received OK
//--- loop to blink without delay ---
// example code not using delay to flash an LED
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
ledState = not(ledState);
// set the LED with the ledState of the variable:
digitalWrite(LED_BUILTIN, ledState);
sensorValue = analogRead(analogInPin); // read the Pot connected to A0
interval = sensorValue +20; // set the LED flash rate from the Pot value
}
}