Skip to content

Instantly share code, notes, and snippets.

// CPU 80MHZ, FLASH 4M/1M
/*
*** Sample using esp-01, D16 is connected to RST
*** If DHT22 is powered by a gpio( VCC of DHT22 is connected to a gpio) and OUTPUT of DHT22 is connected to D2, boot will fail.
*** Power off ----> D2 is in LOW( == DHT22 is in LOW) ==> SDIO boot mode.
Temperature and humidity values are each read out the results of the last measurement.
For real-time data that need continuous read twice, we recommend repeatedly to read sensors,
and each read sensor interval is greater than 2 seconds to obtain accuratethe data.
#include <ESP8266WiFi.h>
//this sketch duplicated the flow that WiFIManager or any other connection manager would take
//first try to connect, if it fails spin up an AP, get some credentials from user, connect again
//then spin everything down
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println();
#include <FS.h> //this needs to be first, or it all crashes and burns...
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
//needed for library
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
#include <ArduinoJson.h> //https://github.com/bblanchon/ArduinoJson
@tzapu
tzapu / AutoConnectWithHTTPServer
Created February 8, 2016 07:25
WiFiManager auto connect and start a http web server
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
//needed for library
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include "WiFiManager.h" //https://github.com/tzapu/WiFiManager
std::unique_ptr<ESP8266WebServer> server;
void handleRoot() {