GithubHelp home page GithubHelp logo

tttapa / esp8266 Goto Github PK

View Code? Open in Web Editor NEW
641.0 71.0 283.0 25.82 MB

Documentation and help with the ESP8266 chip/boards/modules

License: GNU General Public License v3.0

HTML 99.32% CSS 0.40% Shell 0.28%

esp8266's Introduction

ESP8266

Documentation and help with the ESP8266 chip/boards/modules.

You can find the entire article here, or you can just download it.

esp8266's People

Contributors

tttapa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp8266's Issues

OTA and debugging question

Hello, in the OTA article, it is mentionned to use portmon for debugging,
I don't understand the sentence.
In the code when I write "Serial.print", and use OTA, can I see the debug text with portmon ?
Is the device a web server using tcp connection ? same port as OTA ?

Many thanks to help me understanding more...
Best regards,
Thierry Vorms, [email protected]

Problem with Led Control example

Many thanks for your great work and the examples. They was very helpful for me.

I have a problem with the Led Control example. I use an ESP-01. I have uploaded the Data Dir and the sketch (i use the arduino ide 1.8.2 (win7) for this) . The Server starts:
Station connected to ESP8266 AP
OTA ready

Spiffs all ok
WebSocket server started.
mDNS responder started: http://esp8266.local
HTTP server started.
handleFileRead: /
Sent file: /index.html
handleFileRead: /main.css
Sent file: /main.css
handleFileRead: /WebSocket.js
Sent file: /WebSocket.js

!!! and here is the Problem. It need 1 Minute an 20 seconds to go to the next step. Before and after this all runs fast.

[0] Connected from 192.168.4.2 url: /
handleFileRead: /favicon.ico
Sent file: /favicon.ico
[0] get Text: Connect Wed May 03 2017 15:21:11 GMT+0200 (CEST)
handleFileRead: /favicon-144x144.png
Sent file: /favicon-144x144.png

when i try 192.168.4.1/edit.html
is the same problem with the main.css it need over one minute to load.

there is no difference if i use the .js / .css or the .gz files.

i can't connect to http://esp8266.local I connect to 192.168.4.1

i try to connect with my android smartphone always. i tryed with a iphone but the problem is the same.

Please can you help me to solve the problem?
many thanks.

Updating contents of data folder

Fantastic guide, Peter. Very clear, and got my project going a lot quicker than planned. Thank you for putting the effort in to making this excellent resource revealing the power of this amazing board.

In the data logger section, I changed the graphing javascript file to show temperature and humidity on separate vertical axes. Also changed the data logger code itself to read from an Si7021 I2C module instead of DS18B20.

This leads to one suggestion for the guide: add a couple of sentences in the section where you first describe the data folder, saying that updates to a file just need to be reloaded, either from the Arduino IDE, or with the edit.html page you've created. I was seeing my changes NOT get in to SPIFF, so I removed the existing file. I'm not sure why, but they do overwrite if you try a couple of times.

Crash during obtaining data

My NodeMCU got crash while obtaining data. I try to use delay (500), but still problem. please kindly help.

Operation of Reset and Program switches

Thank you for the excellent neat guide, the scheme of how to pull up/ground some GPIOs is the first I found clear.
One request: could you specify the operation of the two switches located on reset and GPIO0 during power-on phase? Are they useful during any other phase?'
Thx and compliments again
Manlio

I can't change the name for mDNS !

Many thanks for your guideline. I learne at lot ...
1st time, I try A-mDNS sketch, all works perfectly after bonjour installation on W10.
After this trial, I change the name for the mDNS.begin, compileand reload the sketch. But I can't ping the new name with or without .local. I can ping the IP address (of course ...) and I can ping with the old "esp8266.local" name.
I restart the PC and the ESP8266, bonjour service without any impact.

How to reset the mDSN name of a ESP8266 ?

Thx

Using ESP as client to upload sensor data to a server through websocket (socket.io)

Hi Peter!

Thanks for this extensive write up on the ESP! I have a quick question: I'd like to take sensor data from a heart rate sensor and send that to a server through a websocket in order to generate audiovisuals on a second webpage. The ESP would be a client, and I ideally would like to utilize socket.io on the server side (and maybe on the ESP itself). My question is: how would I modify your websocket example so that instead of hosting the server on the ESP, it was sending sensor data to a server once it made a connection? What would need to be modified in order to get this to work?

Thanks for your help!

Sincerely,

Tony

Chapter 14 Websockets

Hi Pieter,
i just found your tutorial on the ESP and Websockets in special. Very nice work. Great entry for a quickstart.
I did not test your code yet, but while reading the example i saw some minor things in the code.
For the sakes of a tutorial the code is very readable. As a full time developer i am wondering

  • why the if condition? hue = ++hue % 360 would do the job (see later in your code hue %= 360)

if(++hue == 360) // Cycle through the color wheel (increment by one degree every 32 ms)
hue = 0;

  • function setHue: why the extra conditions in each if clause?

if(hue>=0 && hue<120)

In your code hue will never go below zero, so hue >= 0 will always be true in your example. In the wide wild world this might be another topic

else if(hue>=120 && hue<240)

when the code reaches this point, the hue value definitely is greater or equal to 120. hue >= 120 will always be true, so not needed.

else if(hue>=240 && hue<360)

No if needed at all. When the code reaches this point, the hue value allways will be greater or equal to 240 and allways below 360 (see the line hue %= 360 and the way you increment the hue value)

I do not want to criticise, just leaving my 2 cents

Awesome tutorial

GREAT TUTORIAL. I am a complete newbie to the ESP8266 or networks in general, the tutorials and theory was really comprehensive. Keep up the good work

websocket server to UART pass-trough

Hi Pieter, once again - excellent and clean work.
Thank you!
I believe your example 14 is perfect framework to deploy websocket server apps on ESP8266.
Could you help with a sketch that simplistically gets a clean raw web-based terminal pass through to UART? Like bi-directional IO window.
I've seen several alternatives like https://github.com/hallard/WebSocketToSerial , but mostly are overcrowded with other devices attached or heavy javascripts at web side,
Appreciated your time.

HUMBLE REQUEST

Hello sir,
Thanks for the Guide on ESP it's really helpful. Kindly assist me to Debug the code attached
despite my many attempts to get it working, i have been constantly getting the same error:-

Request page : /Sindex.html [Not Found]

I got the code from an online site and my attempts to reach the person who published it have all failed.
It is a persistence of vision code, am loading it to a Node MCU and connect to the esp as an Access Point. Whenever i type in the static ip to my web browser am receiving the Request page : /Sindex.html [Not Found] Error.

Kindly inform what am doing wrong missing.
Thanks

Pov_Display_Prjct.zip

Chapter 12 - A-Upload_files_to_server

At first i like to thank you for this great tutorial.
In chapter 12 is a reference to "/update.html", but there is no data folder nor a listing of the needed code.
Greetings Lena

Access Point Internet connection

I am making a GPS data logger to ThingSpeak via an ESP8266. You helped. :-) It works well but... I think where I have a problem now is where Wifimulti connects to an access point (or stays connected to the AP) e.g. my phone with a good signal strength, BUT currently, the phone is out of signal and a lower strength Access Point might offer a better Internet connection.
Is there a way programmatically to select an AP which will work best as an Internet access resource? Paul

HUMBLE REQUEST

Hello sir,
Thanks for the Guide on ESP it's really helpful. Kindly assist me to Debug the code attached
despite my many attempts to get it working, i have been constantly getting the same error:-

Request page : /Sindex.html [Not Found]

I got the code from an online site and my attempts to reach the person who published it have all failed.
It is a persistence of vision code, am loading it to a Node MCU and connect to the esp as an Access Point. Whenever i type in the static ip to my web browser am receiving the Request page : /Sindex.html [Not Found] Error.

Kindly inform what am doing wrong missing.
Thanks

``
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <EEPROM.h>

#include <ESP8266mDNS.h>
#include <FS.h>
#include <WebSocketsServer.h>
#include <Hash.h>

int LineIntervalDelay;
#define HalSensor 2
#define NUM_LEDS 9
#define IMAGES_LINES 200
#define FASTLED_FORCE_SOFTWARE_SPI
#define FASTLED_ESP8266_RAW_PIN_ORDER
#include <FastLED.h>
#define SPI_FLASH_SEC_SIZE 4096
//#define HalSensor 14

#define DATA_PIN 13 // (8,15),( 4,2) (6,12) (7,13)
#define CLOCK_PIN 14 //
CRGB leds[NUM_LEDS];

const char configHtml[] PROGMEM = R"=====(

+ <title>Keyno Guidance & Control</title> <script> var MyIP=location.host; var _Connection; var link="ws://"+MyIP+":81"; window.onload = function () { setTimeout(ini_ws,1000); } function ini_ws() { // alert(link); _Connection = new WebSocket( link); //alert("status="+_Connection.readyState); _Connection.onerror = function (error) { document.getElementById('_link').style.backgroundColor ="#FFA500"; alert('Conection Error '+'\n'+link); } _Connection.close = function (error) { document.getElementById('_link').style.backgroundColor ="#FFE4E1";} //gray _Connection.onopen = function (evt) { var newdate=new Date(); var C_date=pad2(newdate.getFullYear())+pad2(newdate.getDay()) +pad2(newdate.getDate()) ; var C_sec=newdate.getSeconds()+ newdate.getMinutes()*60 + newdate.getHours()*3600; _Connection.send('SGT=' + C_date + C_sec); //15 document.getElementById('_link').style.backgroundColor ="#7FFF00"; // grenn document.getElementById('current_data').value=newdate; } _Connection.onmessage = function(INCOME){parsing(INCOME.data); }

}
function parsing(_income)
{// alert(_income)
document.getElementById('_content').value=_income;
}
function pad2(number) { return (number < 10 ? '0' : '') + number }
function createXHR(){
try{return new XMLHttpRequest();}catch (e){try {return new ActiveXObject("Microsoft.XMLHTTP");}
catch (e){return new ActiveXObject("Msxml2.XMLHTTP");}}
}
function updatePath() {
var command = "UPT="+document.getElementById('_newfile').value;
_Connection.send(command); }
function show_list_file() {
var _AJX=createXHR();
_AJX.onreadystatechange = function(){
if(_AJX.readyState == 4)
{ var div = document.getElementById('showfiles');
div.innerHTML = _AJX.responseText; // id of list box =listfile
var _listBox=document.getElementById('listfile');
_listBox.selectedIndex=_listBox.options.length-1;
}}
_AJX.open("GET","/process?code=SLF" , true);
_AJX.send(null);
}
function show_file_content(){
var patch= document.getElementById('_path').value ;
var file= document.getElementById('_file').value;
var _AJX=createXHR();
_AJX.onreadystatechange = function(){
if(_AJX.readyState == 4){
var recieved =_AJX.responseText;
document.getElementById('_content').value=recieved; }}
_AJX.open("GET","/process?code=SFC&patch=" + patch+ '&file='+file, true);
_AJX.send(null); }
function update_file_content(){
var patch= document.getElementById('_path').value ;
var file= document.getElementById('_file').value;
var content=(document.getElementById('_content').value);
_Connection.send("RUF=" + patch+ file+ "&" + content);
document.getElementById('_content').value="";}
function removefile(){
var path=document.getElementById("_path").value;
var file=document.getElementById("_file").value;
var _AJX=createXHR();
_AJX.onreadystatechange = function(){
if(_AJX.readyState == 4){
var recieved =_AJX.responseText; show_list_file();
}}
_AJX.open("GET","/process?code=RRF&patch=" + path+ '&file='+file, true);
_AJX.send(null);}
function CreateFile(){
var path=document.getElementById("_path").value;
var file=document.getElementById("_file").value;
var _AJX=createXHR();
_AJX.onreadystatechange = function(){
if(_AJX.readyState == 4){
var recieved =_AJX.responseText; show_list_file();}}
_AJX.open("GET","/process?code=CRF&patch=" + path+ '&file='+file, true);
_AJX.send(null);}
function renamefile(){
var path=document.getElementById("_path").value;
var oldfile=document.getElementById("_file").value;
var newfile=document.getElementById("_newfile").value;
var _AJX=createXHR();
_AJX.onreadystatechange = function(){
if(_AJX.readyState == 4){
var recieved =_AJX.responseText; show_list_file();}}
_AJX.open("GET","/process?code=RNF&patch=" + path+ '&oldfile='+oldfile + '&newfile='+newfile, true);
_AJX.send(null); }
function parse_line()
{
var e = document.getElementById("listfile");
var line = e.options[e.selectedIndex].text;
var myArray=line.split("/");
var num=myArray.length;
if(num>2){
document.getElementById("_path").value='/'+myArray[1];
document.getElementById("_file").value='/'+myArray[2]; }
else {
document.getElementById("_path").value='/';
document.getElementById("_file").value=myArray[1];}
}
</script>

<script type="text/javascript"> //window.onload = function (){setTimeout(Request_IP,1000);} </script> <script> function upload_file() { var file=document.getElementById("FileUpload1"); var path=document.getElementById("_path").value + document.getElementById("path").value; if(file.files.length === 0) return; var formData = new FormData(); formData.append("data", file.files[0], path); var _AJX = new XMLHttpRequest(); _AJX.onreadystatechange = function(){ if (_AJX.readyState == 4){ if(_AJX.status != 200) alert("ERROR["+_AJX.status+"]: "+_AJX.responseText); else show_list_file(); Show_Image_List();}}; _AJX.open("POST", "/upload"); _AJX.send(formData); } </script> <script> function check_validity() { var file=document.getElementById("FileUpload1"); var path=document.getElementById("path"); if(file.files.length === 0) return; var filename = file.files[0].name; var ext = /(?:\.([^.]+))?$/.exec(filename)[1]; var name = /(.*)\.[^.]+$/.exec(filename)[1]; if(typeof name !== undefined){ filename = name; } if(typeof ext !== undefined){ if(ext === "html") ext = "htm"; else if(ext === "jpeg") ext = "jpg"; filename = filename + "." + ext; } if(path.value === "/" || path.value.lastIndexOf("/") === 0) { path.value = "/"+filename; } else { path.value = path.value.substring(0, path.value.lastIndexOf("/")+1)+filename; } } </script>
<textarea name="TextArea1" id="_content" style="position:absolute;left:4px;top:42px;width:532px;height:387px;z-index:5;" rows="23" cols="86"></textarea>
patch
file
)=====";

String SSID="keyno"; //add 15-29
String SSIDPASS="09127163464";//add 30-44
String AP_SSID="Smart POV";//add 45-59
String AP_SSIDPASS="12345678";//add 60-74
bool ACCESS=false,STATIC=false;
unsigned long Ego_Seconds=27000;
byte client_num=0;

String MyMode=""; // add 0
String myHostname = ""; //add 1-14

byte reset_number=0;//add 76
String Server_IP="192.168."; // add 77-79
String Static_IP="192.168.";//81-83
String MyIP="";
String PerfixID="";
String license="Keyno";
String Software="KEASI Ver 0.7";
String uploadError="";
String PATH="/";
String preSetUser="";
String preSetPass="";
String STRING="",Last_store_time="",Last_store_date="";

bool StartUpShow=true,SHOW=false,TEST=false;
String IMAGES[30]={};
byte IMAGES_Prior[]={0,1,2,3,4};
byte IMAGE_NUM=0;
int DURATION[]={5,5,5,5,5};

static int image_index=0, Current_imageLine=0;

static volatile uint32_t t_start_round=0,t_stop_round=0,lastFrameShow=0;
static volatile uint32_t lineInterval=100,RPM=0;
static volatile bool Start_new_round=false;
uint32_t free_Space_location_start;
uint32_t start_address_of_imagefile[10];
static uint32_t current_raw_location;
//uint8_t * BUFFER;
uint8_t * LED_BUFFER;
byte number_of_file;
static uint32_t _memory_pointer=0,OpenlastTime=0,frame_time=0,lastLineShow=0;

WebSocketsServer webSocket = WebSocketsServer(81);
ESP8266WebServer server(80);

IPAddress apIP(192, 168, 4, 1),_ip;

File fsUploadFile;

void UpdateContent(String path, String income){ // general file
File f = SPIFFS.open(path, "w+");
if (!f) {
Serial.println("[F-w-"+path+"]");// now write two lines in key/value style with end-of-line characters
return;
}
else { // income.replace(";", "\n\r");
f.println(income); f.close(); }

}
String read_line(String _path,byte line_num){
File f = SPIFFS.open(_path, "r");
if (!f) return "" ;
byte counter=0;
String line="";
while(f.available())//1AAA@THAT54545646|1$15:
{
line = f.readStringUntil('\n');
line.trim();
//Serial.print("read line="); Serial.println(line);
if(line.length() >2 && counter==line_num) break;
counter++;
}
f.close();
return line;
}
void Restore_address(void){
String s=read_line("/data/address.inf",0);
byte As=0;
for(byte i=0;i<IMAGE_NUM;i++)
{
As=s.indexOf('@');
start_address_of_imagefile[i]=s.substring(0,As).toInt();
Serial.printf("Address of File %s=%u\n",IMAGES[i].c_str(),start_address_of_imagefile[i]);
s=s.substring(As+1);
}
}
void Store_address(void){
String s="";
for(byte i=0;i<IMAGE_NUM;i++) s+=String(start_address_of_imagefile[i])+"@";
Serial.println(s);
UpdateContent("/data/address.inf",s);
}
String compose(void){
//BYTES=compose_bytes();
String s="";
s=myHostname+"@"+SSID+"@"+SSIDPASS+"@"+AP_SSID+"@"+AP_SSIDPASS+"@"+Static_IP+"@"+Server_IP+"@";//+BYTES+"@";
return s;
}
void decompose(String s){
//A@myHostname@SSID@
byte As=0;

As=s.indexOf('@');
As=s.indexOf('@'); myHostname=s.substring(0,As); if(myHostname.length()<3) myHostname="KGC"; s=s.substring(As+1);
As=s.indexOf('@'); SSID=s.substring(0,As); if(SSID.length()<3) SSID="Unknown"; s=s.substring(As+1);
As=s.indexOf('@'); SSIDPASS=s.substring(0,As); if(SSIDPASS.length()<3) SSIDPASS="Unknown"; s=s.substring(As+1);
As=s.indexOf('@'); AP_SSID=s.substring(0,As); if(AP_SSID.length()<3) AP_SSID="Smart_Node_" +String(ESP.getChipId(), HEX); s=s.substring(As+1);
As=s.indexOf('@');AP_SSIDPASS=s.substring(0,As); if(AP_SSIDPASS.length()<3) AP_SSIDPASS="12345678"; s=s.substring(As+1);

As=s.indexOf('@'); Static_IP=s.substring(0,As); if(Static_IP.length()<3) Static_IP="192.168.1.11"; s=s.substring(As+1);
As=s.indexOf('@'); Server_IP=s.substring(0,As); if(Server_IP.length()<3) Server_IP="192.168.4.1";

}
void restore_setting(void) {
STRING=read_line("/data/mydevice.dat",0);
decompose(STRING);

preSetUser=String(ESP.getChipId());//
preSetPass=String(ESP.getChipId(), HEX);
preSetPass.toUpperCase();
}
void store_setting(void){
STRING=compose();
UpdateContent("/data/device.inf",STRING);
Serial.println("[Stored]");
}
String Retrive_file(String _File,String perfix){
File f = SPIFFS.open("/data/"+_File, "r");
if (!f) return "";
String content="";
while(f.available()) {
char c=f.read(); if(c=='\n') break;
content+=c;
}
content.trim();
return perfix+"$"+content;
}
void copy_file_from_SPIFF_to_Raw_Flash(String path, byte file_num){
uint32_t startTime = millis();
File f = SPIFFS.open(path, "r");
if(!f) { Serial.println("Could not open file for reading"); return; }
size_t i = f.size();
start_address_of_imagefile[file_num]=current_raw_location;
Serial.printf("File size is %u Bytes Start location =%u\n", i,start_address_of_imagefile[file_num]);
uint8_t* BUFFER = new uint8_t[SPI_FLASH_SEC_SIZE];
while(i > SPI_FLASH_SEC_SIZE){
f.read(BUFFER, SPI_FLASH_SEC_SIZE);
optimistic_yield(10000);
ESP.flashEraseSector(current_raw_location/FLASH_SECTOR_SIZE);
ESP.flashWrite(current_raw_location,(uint32_t *) BUFFER, SPI_FLASH_SEC_SIZE);
Serial.print("."); i -= SPI_FLASH_SEC_SIZE;
current_raw_location+=SPI_FLASH_SEC_SIZE;
}
f.read(BUFFER, i);
for(int n=0;n<i;n++){Serial.print((char)BUFFER[n]); Serial.print(",");}Serial.println();
optimistic_yield(10000);
ESP.flashEraseSector(current_raw_location/FLASH_SECTOR_SIZE);
ESP.flashWrite(current_raw_location,(uint32_t ) BUFFER, i);
current_raw_location+=i;
f.close();
delete [] BUFFER;
Serial.printf("copy took %u ms, memory end address=%u\n", millis() - startTime,current_raw_location);
}
///////////////////////////////// webSocket ///////////////////////////////////////
void parse_webSocket(String income, byte num){
byte eqI1 = income.indexOf('=');
String cammand = income.substring(0, eqI1);// Serial.print(" cammand=");Serial.println(cammand);
String value = income.substring(eqI1+1); //Serial.print(" value=");Serial.println(value);
if(cammand=="RST") { // [-Standalone-]
/

wifimode
hostID
localip
serverip
_SSID
AP_name
software
license

          EactuaterID
          EactuaterIP
          EsensorID
          Esensordescrip
          */
          String s="";
          if(MyMode=="A") s="Access Point"; 
          else            s="Station";
         // Serial.println("$D"+IDs[0]+"$"+DESCRIPT[0]+"$D"+IDs[1]+"$"+DESCRIPT[1]+"$D"+IDs[2]+"$"+DESCRIPT[2]);
         webSocket.sendTXT(num, "RST$"+
                                      s           +"$"+
                        myHostname  +"$"+
                        MyIP        +"$"+
                        Server_IP   +"$"+
                        SSID        +"$"+
                        AP_SSID     +"$"+
                        Software    +"$"+
                        license     +"$"
                           
                        );
        } 

//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
else if(cammand=="WFM") { lineInterval+=100; webSocket.sendTXT(client_num,"RPM$"+String(lineInterval));}//EEPROM.write(1, value[0]);EEPROM.commit(); } // Set Wifi Mode MyMode [-Standalone-]
else if(cammand=="SHN") {lineInterval-=10; webSocket.sendTXT(client_num,"RPM$"+String(lineInterval));}// myHostname=value; // Set Host Name myHostname [-Standalone-]
else if(cammand=="SNW") { // SSID SSIDPASS Select Network user&pass [-Standalone-]
eqI1 = value.indexOf('&');
SSID= value.substring(0, eqI1);// Serial.print(" SSID=");Serial.println(_ssid);
SSIDPASS= value.substring(eqI1+1); //Serial.print(" pass=");Serial.println(pass); Serial.println(lineInterval);
}
else if(cammand=="APN") {lineInterval+=1; webSocket.sendTXT(client_num,"RPM$"+String(lineInterval));}//AP_SSID=value; // Set AP Name AP_SSID [-Standalone-]
else if(cammand=="APP") {lineInterval-=1; webSocket.sendTXT(client_num,"RPM$"+String(lineInterval));}// AP_SSIDPASS=value; // Set AP Password AP_SSIDPASS [-Standalone-]
else if(cammand=="ESI") { EEPROM.write(2, value[0]);EEPROM.commit();(value[0]=='1')?STATIC=true:STATIC=false;} // [-Standalone-]
else if(cammand=="SIP") {lineInterval-=100; webSocket.sendTXT(client_num,"RPM$"+String(lineInterval));} //Server_IP=value;// Set Server IP Server_IP [-Standalone-]

else if(cammand=="STI") {lineInterval+=10; webSocket.sendTXT(client_num,"RPM$"+String(lineInterval));}// Static_IP=value;// Set Static_IP 81-82 [-Standalone-]

else if(cammand=="SGT") { //time of browser webSocket recieved: SGT=20160510 77666 119-133 [---SN---]
Last_store_date=value.substring(2,8); //
Last_store_time=value.substring(8);
Ego_Seconds=Last_store_time.toInt(); Serial.print(" Base second=");Serial.println(Ego_Seconds); //77666000
} // Set global date setting

else if(cammand=="SVE") {if(TEST) TEST=false; else TEST=true;Serial.println(TEST);}//webSocket.sendTXT(num,"SVE$");store_setting(); }

//''''''''''''''''''''''''''''''''''''' setting page ''''''''''''''''''''''''''''''''''''''''''''''
else if(cammand=="SHO") { //SHO=1 [-Standalone-]
(value[0]=='1')?SHOW=true:SHOW=false;
if(SHOW) _memory_pointer=start_address_of_imagefile[image_index];
Serial.print("SHOW=");Serial.println(SHOW);
}

else if(cammand=="CLR") ;//// clear store sensor data [-Standalone-]
else if(cammand=="SIM") // SIM=0#1@1 value.indexOf('#');
{
byte _index = value.substring(0, value.indexOf('#')).toInt(); // Serial.print(" _index");Serial.println(_index);
byte Priority=value.substring(value.indexOf('#')+1, value.indexOf('@')).toInt();// Serial.print(" Priority=");Serial.println(Priority);
byte duration=value.substring(value.indexOf('@')+1).toInt(); // Serial.print(" duration=");Serial.println(duration);
EEPROM.write(_index+20, Priority); EEPROM.commit();
EEPROM.write(_index+70, duration); EEPROM.commit();
}

//'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
else if(cammand=="RRE") ESP.restart();// restart [----SN---]
else if(cammand=="CSP") if(IMAGE_NUM) { for(byte i=0;i<IMAGE_NUM;i++) copy_file_from_SPIFF_to_Raw_Flash("/SHOW/"+IMAGES[i], i); Store_address(); } // [-Standalone-]
else if(cammand=="RUF") { // UpdateContent [-CONFIG-]
eqI1 = value.indexOf('&');
String filename = value.substring(0, eqI1); //Serial.print(" filename=");Serial.println(filename);
String content = value.substring(eqI1+1); //Serial.print(" content=");Serial.println(content);
UpdateContent(filename,content);
}
else if(cammand=="RUP") PATH=value;// EEPROM_Write(value,0,1); // Set AP IP [-CONFIG-]
}
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght) {
client_num=num;
switch(type) {
case WStype_DISCONNECTED:
Serial.printf("[WS:%u Disconnected!]\n", num);
ACCESS=false;
break;
case WStype_CONNECTED: {
IPAddress ip = webSocket.remoteIP(num);
ACCESS=true;
Serial.print("[WS:]Clinet "); Serial.print(num); Serial.print(" CONNECTED with IP: ");Serial.println(ip);

             } 
    break;
    case WStype_TEXT:    // this for  webSocket request          
            String text = String((char *) &payload[0]);
            Serial.print("[WS:"); Serial.print(num);Serial.print("]");Serial.println(text);
            parse_webSocket(text,num);
    break;
    
    
  }

}
///////////////////////////////// webSocket ///////////////////////////////////////
String formatBytes(size_t bytes){
if (bytes < 1024) return String(bytes)+"B";
else if(bytes < (1024 * 1024)) return String(bytes/1024.0)+"KB";
else if(bytes < (1024 * 1024 * 1024)) return String(bytes/1024.0/1024.0)+"MB";
else return String(bytes/1024.0/1024.0/1024.0)+"GB";
}
String getContentType(String filename){
if(server.hasArg("download")) return "application/octet-stream";
else if(filename.endsWith(".htm")) return "text/html";
else if(filename.endsWith(".html")) return "text/html";
else if(filename.endsWith(".css")) return "text/css";
else if(filename.endsWith(".js")) return "application/javascript";
else if(filename.endsWith(".png")) return "image/png";
else if(filename.endsWith(".gif")) return "image/gif";
else if(filename.endsWith(".jpg")) return "image/jpeg";
else if(filename.endsWith(".ico")) return "image/x-icon";
else if(filename.endsWith(".xml")) return "text/xml";
else if(filename.endsWith(".pdf")) return "application/x-pdf";
else if(filename.endsWith(".zip")) return "application/x-zip";
else if(filename.endsWith(".gz")) return "application/x-gzip";
return "text/plain";
}
void show_user_list(String path,String _ID,String parseFunction){
//"/data/user.dat","ListUserListBox","parse_line_and_put_inform"
String records="<select name="Combobox2" size="5" id=""+_ID+"" onChange=""+parseFunction+"();" >";
File f = SPIFFS.open(path, "a+"); ///a+ if not exist then create it
if (!f) return server.send(200, "text/plain", records);
byte line_num_count=0;
//String line="";
while(f.available()) {
String line = f.readStringUntil('\n');

            if(line.length() >2) {//Serial.print("line number:");Serial.print(line_num_count);Serial.println("="+line);
                       records+="<option value=\"" + String(line_num_count)+"\">" +line +"</option>";
                      line_num_count++; }
           
          } 

f.close();

records+="";
server.send(200, "text/plain", records);
}
void AddUser(String user,String pass,String scop){
String line="\n"+user+ "," + pass + "," + scop;
//Serial.println(line);
File f = SPIFFS.open("/data/user.dat", "a+");
if (!f) return ;
f.print(line);
f.close();
}
void RemoveUser(byte num){
//Serial.print("lndex number:");Serial.println(num);
String temp="";
File f = SPIFFS.open("/data/user.dat", "r");
byte num_count=0;
while(f.available()) {//Lets read line by line from the file
String line = f.readStringUntil('\n');
if(line.length() >2) {
//Serial.print("line number:");Serial.print(num_count);Serial.println("="+line);
if(num!=num_count)temp=temp+line+"\n\r";
num_count++;
}
}

f.close();
f = SPIFFS.open("/data/user.dat", "w+");
f.println(temp);
f.close();
}
void Createfile(String path, String filename){
if(SPIFFS.exists(path+filename)) return server.send(500, "text/plain", "FILE EXISTS");
File file = SPIFFS.open(path+filename, "w");
if(file) file.close();
else return server.send(500, "text/plain", "CREATE FAILED");
}
void removefile(String path, String filename){
if(!SPIFFS.exists(path+filename)) return server.send(404, "text/plain", "FileNotFound");
SPIFFS.remove(path+filename); server.send(200, "text/plain", "removed");
}
void RenameFile(String patch,String oldfilename,String newfilename){
String fold=patch+oldfilename;
String fnew=patch+newfilename;
if (SPIFFS.exists(fold))
{
SPIFFS.rename(fold,fnew);
server.send(200, "text/plain", "Renamed");
}

}
void show_listfile(void){ ///replace all item of list box
String records="<select name="Combobox1" size="20" id="listfile" onChange="parse_line();" >";
byte i=0;
Dir dir = SPIFFS.openDir("/");
while (dir.next()) {
String fileName = dir.fileName();
size_t fileSize = dir.fileSize();
records+="<option value="" + String(i)+"">" +fileName +"";
i++;
}
records+="";
server.send(200, "text/plain", records);
}
void show_file_content(String patch, String filename){ //show_file_content() _AJX RGP
String content="";
File f = SPIFFS.open(patch+filename, "r");
while(f.available()) {//Lets read line by line from the file
String line = f.readStringUntil('\n');

          if(line.length() >2) 
          { //Serial.print("line number:");Serial.print(line_num_count);Serial.println("="+line);
          content+=(line+"\n");
         
          }
        } 

f.close();
server.send(200, "text/plain", content);
}
void DIR(void){
uint32_t total=0;
Dir dir = SPIFFS.openDir("/");
while (dir.next()) {
String fileName = dir.fileName();
size_t fileSize = dir.fileSize();
total+=fileSize;
Serial.printf("FS File: %s, size: %s\n", fileName.c_str(), formatBytes(fileSize).c_str());
}
Serial.print("\t\t\tTotal:");Serial.println(total);

}
void handleFileUpload(){ // "/update"
if(server.uri() != "/upload" ) return;
HTTPUpload& upload = server.upload();
if(upload.status == UPLOAD_FILE_START){
String filename = upload.filename;
if(!filename.startsWith("/")) filename = "/"+filename;
if(PATH.length()>3) filename=PATH+filename;

                  if (SPIFFS.exists(filename) )    SPIFFS.rename(filename,(filename+".BAK"));
                  Serial.print("handleFileUpload Name: "); Serial.println(filename);
                  fsUploadFile = SPIFFS.open(filename, "w");
                  filename = String();
                  } 

else if(upload.status == UPLOAD_FILE_WRITE){
//Serial.print("handleFileUpload Data: "); Serial.println(upload.currentSize);
if(fsUploadFile) fsUploadFile.write(upload.buf, upload.currentSize);
}
else if(upload.status == UPLOAD_FILE_END){
if(fsUploadFile) fsUploadFile.close();
Serial.print("handleFileUpload Size: "); Serial.println(upload.totalSize);
}
}
byte list_images_filename(String _path){
Dir dir = SPIFFS.openDir(_path);
int j=0;
while (dir.next()) IMAGES[j++] = dir.fileName().substring(6);
for(int i=0;i<j;i++) Serial.printf("Image File=%s\n",IMAGES[i].c_str());
return j;
}
void sort_image(void){
String copy="";
byte due=0,pri=0;
for(int i=0;i<IMAGE_NUM;i++) IMAGES_Prior[i]=(byte)EEPROM.read(i+20);
for(int i=0;i<IMAGE_NUM;i++) DURATION[i]=(byte)EEPROM.read(i+70);
for(int i=0;i<IMAGE_NUM;i++){
for(int j=0;j<IMAGE_NUM-1;j++)
{
if(IMAGES_Prior[j]>IMAGES_Prior[j+1])
{

                                                copy=IMAGES[j+1];
                                                due=DURATION[j+1];
                                                pri=IMAGES_Prior[j+1];
                                                  IMAGES[j+1]=IMAGES[j];
                                                 DURATION[j+1]=DURATION[j];
                                                 IMAGES_Prior[j+1]=IMAGES_Prior[j];
                                               IMAGES[j]=copy;
                                               DURATION[j]=due;
                                               IMAGES_Prior[j]=pri;
                                              
                                              }
                           
                          }
          }

for(int i=0;i<IMAGE_NUM;i++) Serial.printf("IMAGES[%d]=%s , priority=%d, Duration=%d \n",i,IMAGES[i].c_str(),IMAGES_Prior[i],DURATION[i]);
}
void showActiveImage(void){
IMAGE_NUM=list_images_filename("/SHOW");
sort_image();

String records="<table style="position:absolute;color:#FFFFFF;width:400px;font-size:13px; border: 0px #000000 none;" id="mytable">";
records+="";
records+="Num:";
records+="Image Name";
records+="Priority ";
records+="Duration";
records+="<\tr>";
for(int i=0;i<IMAGE_NUM;i++)
{

                         records+="<tr>";   
             records+="<td>"+ String(i) +"</td>";                             
             records+="<td>"+IMAGES[i]+"</td>";
             records+="<td>"+  String(IMAGES_Prior[i]) +   "</td>";
             records+="<td>"+  String(DURATION[i]) +   "</td>";
                         records+="<\tr>";              
          }   

records+="";
server.send(200, "text/plain", records);
}
void Show_Image_List(void){
String records="<select name="Combobox1" width="340" size="20" id="listfile" onChange="parse_line();" >";
byte i=0;
Dir dir = SPIFFS.openDir("/SHOW");
while (dir.next()) {
String fileName = dir.fileName();
size_t fileSize = dir.fileSize();
records+="<option value="" + String(i)+"">" +fileName +"";
i++;
}
records+="";
server.send(200, "text/plain", records);

}
void update_show_list(void){
IMAGE_NUM=list_images_filename("/SHOW");
sort_image();
String records="<table style="position:absolute;color:#FFFFFF;width:600px;font-size:13px; border: 2px #000000 none;" id="mytable">";
records+="";
records+="Num:";
records+="Image Name";
records+="Priority ";
records+="Duration";
records+="Set";
records+="<\tr>";
for(int i=0;i<IMAGE_NUM;i++)
{

                         records+="<tr>";   
             records+="<td>"+ String(i) +"</td>";                             
             records+="<td>"+IMAGES[i]+"</td>";
             records+="<td> <input type=\"number\" id=\"PB_" + String(i )+"\" style=\"width:37px;height:18px;\" name=\"EBP\" value=\"" +IMAGES_Prior[i] +"\"> </td>";
             records+="<td> <input type=\"number\" id=\"DB_" + String(i) +"\" style=\"width:37px;height:18px;\" name=\"EBD\" value=\"" +DURATION[i] +"\"> </td>";
             records+="<td> <input type=\"button\"  id=\"B_" + String(i) +"\" style=\"width:59px;height:25px;\" onclick=\"SetConfig(this.id);return false;\" name=\"\" value=\"Set\"> </td>";                 
                         records+="<\tr>";              
          }   

records+="";
server.send(200, "text/plain", records);
}
////////////////////////////////////////////////////////////////
void process() // this for httml request
{
Serial.print("[HTML]"); Serial.print(server.arg(0)); Serial.print(" ACCESS="); Serial.println(ACCESS);
if(server.arg(0)=="IMG") Show_Image_List() ;// CONFIG
else if(server.arg(0)=="SLF") show_listfile() ;// CONFIG
else if(server.arg(0)=="RNF") RenameFile(server.arg(1),server.arg(2),server.arg(3));//http://192.168.4.1/process?code=RRN&patch=patch& [-CONFIG-]
else if(server.arg(0)=="CRF") Createfile(server.arg(1),server.arg(2)) ; //http://192.168.4.1/process?code=RCF&patch=patch&file=file [-CONFIG-]
else if(server.arg(0)=="RRF") removefile(server.arg(1),server.arg(2)) ; //http://192.168.4.1/process?code=RRF&patch=patch&file=file [-CONFIG-]
else if(server.arg(0)=="SFC") show_file_content(server.arg(1),server.arg(2)) ;//http://192.168.4.1/process?code=RGP&patch=patch&file=file [-CONFIG-]
else if(server.arg(0)=="USL") update_show_list(); //update_show_list()->_AJX-> _imageList [-CONFIG-]
else if(server.arg(0)=="RUL") show_user_list("/data/user.dat","ListUserListBox","parse_line_and_put_inform");
else if(server.arg(0)=="AUS") AddUser(server.arg(1),server.arg(2),server.arg(3));//http://192.168.4.1/process?code=RAU&user=user&pass=pass&scop=scop [-Standalone-]
else if(server.arg(0)=="RUS") RemoveUser(server.arg(1)[0]-'0');//http://192.168.4.1/process?code=RRU&index=index [-Standalone-]
}
bool handleFileRead(String path){///>>>>>>>>> Authentification before sending page
Serial.print(" Request page : " + path);
if(path.endsWith("/")) path += "index.html";
String contentType = getContentType(path);
String pathWithGz = path + ".gz";
if(SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)){
if(SPIFFS.exists(pathWithGz)) path += ".gz";
File file = SPIFFS.open(path, "r");
size_t sent = server.streamFile(file, contentType);///>>>>>>>>>
file.close();
Serial.println("\t[SENT]");
return true;
}
Serial.println("\t[Not Found]");
return false;
}
void handleFileUploadImage(){
if(server.uri() != "/updateImage" ) return;
HTTPUpload& upload = server.upload();
if(upload.status == UPLOAD_FILE_START){
String filename = upload.filename;
if(!filename.startsWith("/")) filename = "/SHOW/"+filename;
//if(PATH.length()>3) filename=PATH+filename;

                  if (SPIFFS.exists(filename) )    SPIFFS.rename(filename,(filename+".BAK"));
                  Serial.print("handleFileUpload Name: "); Serial.println(filename);
                  fsUploadFile = SPIFFS.open(filename, "w");
                  filename = String();
                  } 

else if(upload.status == UPLOAD_FILE_WRITE){
//Serial.print("handleFileUpload Data: "); Serial.println(upload.currentSize);
if(fsUploadFile) fsUploadFile.write(upload.buf, upload.currentSize);
}
else if(upload.status == UPLOAD_FILE_END){
if(fsUploadFile) fsUploadFile.close();
Serial.print("handleFileUpload Size: "); Serial.println(upload.totalSize);
}
}
void handleRoot() { handleFileRead("/Sindex.html"); }
void send_config_html(void){server.send ( 200, "text/html", configHtml ); }
void handleConfig(){ if(!server.authenticate(preSetUser.c_str(), preSetPass.c_str())) return server.requestAuthentication();
ACCESS=true;
send_config_html();}
void handleOther(){
if(!handleFileRead(server.uri()))
{
//Serial.println("Request other files");
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
}
}
void print_chip_info(void){
preSetUser=String(ESP.getChipId());//
preSetPass=String(ESP.getChipId(), HEX);
preSetPass.toUpperCase();
Serial.println("\n\nDevice ID=" + preSetPass +"(" + preSetUser + ")");
Serial.print("Slected FlashChipSize: ");Serial.println(formatBytes(ESP.getFlashChipSize()));
Serial.print("FlashChipRealSize: ");Serial.println(formatBytes(ESP.getFlashChipRealSize()));
Serial.print("SketchSize:");Serial.println(formatBytes(ESP.getSketchSize()));
Serial.print("FreeSketchSpace:");Serial.println(formatBytes(ESP.getFreeSketchSpace()));
Serial.print("FreeHeap:");Serial.println(formatBytes(ESP.getFreeHeap()));

//Serial.print("\nChipId: ");Serial.println(ESP.getChipId());
Serial.print("CpuFreqMHz: ");Serial.println(ESP.getCpuFreqMHz());
Serial.print("SdkVersion: ");Serial.println(ESP.getSdkVersion());
Serial.print("FlashChipSpeed: ");Serial.println(ESP.getFlashChipSpeed());
Serial.print("FlashChipMode: ");Serial.println(ESP.getFlashChipMode());
}
void Rotate_1_round(void){
t_stop_round=micros();
RPM=(t_stop_round-t_start_round)/(IMAGES_LINES);
lineInterval=(lineInterval+RPM)/2;
t_start_round=t_stop_round;
Start_new_round=true;
}

static uint8_t tint_poz = 0;

void setup() {
Serial.begin(115200);
// Serial.begin(115200, SERIAL_8N1,SERIAL_TX_ONLY);
delay(500);
Serial.setDebugOutput(true);
Serial.println(F("\n \nStarting....."));

SPIFFS.begin();
EEPROM.begin(128);
FastLED.addLeds<APA102,DATA_PIN,CLOCK_PIN,RGB,DATA_RATE_MHZ(16)>(leds,NUM_LEDS);
FastLED.setBrightness(255);
FastLED.clear();
FastLED.show();
print_chip_info();

DIR();
IMAGE_NUM=list_images_filename("/SHOW");
sort_image();
Restore_address();
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP(AP_SSID.c_str(),AP_SSIDPASS.c_str());
delay(500); // Without delay I've seen the IP address blank

//MyIP=WiFi.softAPIP().toString();
Serial.print("AP IP address: ");Serial.println(WiFi.softAPIP());
server.on("/upload", HTTP_POST, { Serial.println("Upload post"); server.send(200, "text/plain", ""); /* Redirect("/setting.html");/ }, handleFileUpload);
server.on("/updateImage", HTTP_POST, { Serial.println("Upload post"); server.send(200, "text/plain", "Loaded"); /
Redirect("/setting.html");*/ }, handleFileUploadImage);
server.on("/", handleRoot);
server.on("/process", process);
server.on("/config.html", handleConfig);
server.onNotFound(handleOther);

server.begin(); Serial.println(F("\t\t\tHTTP server started"));

const char * headerkeys[] = {"User-Agent","Cookie"} ; //here the list of headers to be recorded
size_t hz = sizeof(headerkeys)/sizeof(char*);
server.collectHeaders(headerkeys, hz ); //ask server to track these headers

 current_raw_location=(ESP.getSketchSize() + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));

Serial.printf("New Start Address= %u\n",current_raw_location);
LED_BUFFER = (uint8_t )malloc(NUM_LEDS3);
Serial.print(F("Number of Image=")); Serial.println(IMAGE_NUM);
webSocket.begin();
webSocket.onEvent(webSocketEvent);
delay(500);
pinMode(HalSensor, INPUT);
attachInterrupt(digitalPinToInterrupt(HalSensor), Rotate_1_round, FALLING);
OpenlastTime=millis();
}

byte hue=0;

void loop() {
if(!SHOW && !TEST) server.handleClient();
if(SHOW)
{
if( (millis()- OpenlastTime) >DURATION[image_index]1000) {
if(image_index>=IMAGE_NUM) image_index=0;
_memory_pointer=start_address_of_imagefile[image_index];
Serial.printf("File number=%u name:%s address:%u duration:%u\n",
image_index,IMAGES[image_index].c_str(),start_address_of_imagefile[image_index],DURATION[image_index]);
Current_imageLine=0;
image_index++;
OpenlastTime=millis();
}
if((micros()-lastLineShow)> lineInterval)
{
lastLineShow=micros();
ESP.flashRead(_memory_pointer,(uint32_t )leds ,NUM_LEDS3 );
FastLED.show();
_memory_pointer+=(NUM_LEDS
3);
Current_imageLine++;
delay(LineIntervalDelay);
}
if(Current_imageLine>=IMAGES_LINES) {
Current_imageLine=0;
_memory_pointer=start_address_of_imagefile[image_index-1];
}

} 

optimistic_yield(1000);
}

Grazie!

Wonderful guide, I allowed myself to translate into Italian ... is at your disposal
Orfmia

Example - How to control Relays on multiple ESPs/nodemcu(s) ?

Hello Mr. tttapa.

Do you have an Example Sketches How to control multiple nodemcu(s) relays using a Ethernet Shield?

My plan is to using Ethernet shield to read inputs/buttons and send to 5 Nodemcu to control 10 relays via router (each node has a 2 relays).

Many Thanks for your Great Libraries...

A Beginner's Guide to the ESP8266 - NTP part

Hi,
Thank you very much for this so complete tutorial that deals with lot of useful concepts!
I fully implement this and have a question about NTP.
Somewhere in the code you write:

`if (time) { // If a new timestamp has been received
timeUNIX = time;
Serial.print("NTP response:\t");
Serial.println(timeUNIX);
lastNTPResponse = currentMillis; // <============
} else if ((currentMillis - lastNTPResponse) > 3600000) {
Serial.println("More than 1 hour since last NTP response. Rebooting.");
Serial.flush();
ESP.reset();
}

uint32_t actualTime = timeUNIX + (currentMillis - lastNTPResponse)/1000; // <========
if (actualTime != prevActualTime && timeUNIX != 0) { // If a second has passed since last print
prevActualTime = actualTime;
Serial.printf("\rUTC time:\t%d:%d:%d ", getHours(actualTime), getMinutes(actualTime), getSeconds(actualTime));
`

But lastNTPResponse = currentMillis; clearly means that currentMillis - lastNTPResponse will always be 0 when computing actualTime.
So, I'm a bit lost. What was your idea?

Auto-reset and auto-program on bare-bones ESP8266 using DTR only

Besides using DTR to perform auto-reset (page 14) it is also possible to use DTR for auto-program (without the use of RTS): connect DTR to GPIO0 with a small signal diode (1N4148) in series, anode to GPIO0. Add a 10k pull-up between anode and 3.3V.
Tested on 12E and 12F. Schematics added for adapter board (which also doubles as adapter for RF95/96 modules) where this modification is included.
ESP8266-12_auto-reset.pdf

use of deleted function 'ESP8266WebServer

just a small update for the WebSocket example
ESP8266/Examples/14. WebSocket/A-WebSocket_LED_control/A-WebSocket_LED_control.ino
fails to compile showing following errror in the arduino ide:

use of deleted function 'ESP8266WebServer::ESP8266WebServer(const ESP8266WebServer&)'

To fix, replace line 11
ESP8266WebServer server = ESP8266WebServer(80);
with
ESP8266WebServer server (80);
Thanks for the excellent tutorial
I made a PR but i'm not sure if it is appropriate: git is new for me.

Add mqtt

Please add info on how to implement MQTT with configuration via wifimanager.

Possible creating multiple charts?

I loved too much this data logging but I would need to have around 3 different charts on the screen for my purpose project. Is it hard to add more charts in these current project? I am trying to play inside the .js files but not having lucky.

Thanks

how to test esp8266

I've read your Beginner's Guide but still face this ... how to test if the esp8266 is working (not dead)?

Just got one (nodemcu 12E), when I plug it to the usb port, the blue led blinks twice. Installed Arduino IDE on win10 (I have issues with the serial ports on Linux Mint), loaded the ESP addl libraries (.json), tried the basic blink code, getting error "espcomm upload mem failed."

It would be great if there are some steps I can try, to make sure my esp8266 is not dead.

Beginner's 8266 Guide - mDNS

Pieter,
First, thank you very much for your detailed explanation of the ESP8266 module, its capabilities and functions. I have successfully worked through each 'tutorial up to and including the Turning On & Off an LED over WiFi. Everything worked perfectly EXCEPT the mDNS function. While the sketches verified and uploaded fine through my FTDI and ESP8266 ESP-01 and I received via serial that 'mDNS responder started' and 'HTTP Server Started' I could not receive a response when typing in http://esp8266.local. Ping to esp8266.local did not respond. HOWEVER, if I typed in the local IP, I could PING and receive "Hello world" and TOGGLE LED worked fine. Can you advise solution? Thank you in advance.

Excellent work

Excellent work, Pieter. It is an article very well explained, very complete and with clear examples. An excellent help for those of us who are starting in the ESP8266. Thank you for your effort..

Websocket client

Hi,

Thank you for your tutorial. It is very well written and really gives a good overview. I would like to recommend one item to be added, and that is how to code a WebSocket client on the ESP8266 to a server. WIth NAT and firewall, it is usually not easy to configure the ESP8266 to be a server, but easy for it to be a client and connect to a server. So even if we are trying to send commands to the ESP8266, it would be easier for the ESP8266 to connect to a server with WebSocket, and receive commands. Do you think you can add this to your tutorial?

Thanks,
James

Clearer structure in WebSockets example

Hi Peter, excellent guide, I'm a real beginner and most of it is crystal clear explained and well commented in the code.
Only the sample concerning WebSockets is a bit fuzzy, what has to stay in void setup, what in void loop, which code at the very beginning of the sketch, what has to be uploaded into SPIFFS isn't clear to me, a few added words to explain this in this regard would be helpful.
Great job anyway, heartfelt thanks for the knowledge you're sharing.
Manlio

google graph

Hey
Could you plz set a like to your google graph code, since i could find it :)

I like your guide alot, its a really well done beginner guide

OTA Update password not working

In chapter 13 the code snippet explaining how to setup OTA updates states:

  Serial.println(WiFi.localIP());           // Send the IP address of the ESP8266 to the computer
  
  ArduinoOTA.setHostname("ESP8266");
  ArduinoOTA.setPassword("esp8266");

  ArduinoOTA.onStart([]() {
    Serial.println("Start");
  });

The problem I seem to be facing is that without adding the (const char*) casting to the password line:

  ArduinoOTA.setPassword((const char *)"esp8266");

whenever I try to upload a new sketch over OTA, the ESP will always refuse the password. I took a look at the official ESP8266 documentation and all the examples I could find have the type casting when using setPassword with an inline string.

in case it helps, I'm using Arduino IDE 1.8.7, ESP8266 2.4.2 and running Ubuntu 18.10.

Issue with logger JavaScript

Pieter,

Thanks for the excellent guide and examples.

I have a question regarding the A-Temperature_logger example. I got it working and am developing an application where the actual temperature reading is plotted against the Wunderground forecast. The 'previous' button called by < does not work in Chrome, Firefox or Safari (on my phone). I took a look at the code in temperatureGraph.js and it looks pretty reasonable but I really don't understand how this function works.

document.getElementById("prev").onclick = function() {
maxDate = new Date(maxDate.getTime() - getZoomTime()/3);
setRange();
}

Can you direct me to a resource that would help explain it? I just can not spot what's wrong. Can you help with the immediate problem at hand, getting the function to work?

Data logging - sudden restart when webpage loaded - panic DataSource.h

Hi,
thank you for this tutorial, which I found very useful when starting with ESP as a beginner. I've already made some simple sensor projects, but now I'm having something I cannot solve.

I’m working on the data logging part with an ESP8266-01, and somehow I cannot succeed, because I have the following issue.
Problem is that when I load the webpage, the ESP restarts. All other things work fine, right until I load the web page. It’s showing the index file (Loading…) only, and simultaneously it makes the ESP restart.
The crash is at Arduino15\packages\esp8266\hardware\esp8266\2.4.2\libraries\ESP8266WiFi\src\include/DataSource.h.

Here you find what I have on the terminal:
"
Connecting
.........

Connected to name
IP address: 192.168.1.108

OTA ready

SPIFFS started. Contents:
FS File: /edit.html.gz, size: 700B
FS File: /favicon-144x144.png, size: 2.81KB
FS File: /favicon.ico.gz, size: 1.91KB
FS File: /index.html.gz, size: 841B
FS File: /main.css.gz, size: 349B
FS File: /manifest.json, size: 169B
FS File: /success.html.gz, size: 456B
FS File: /temperatureGraph.js.gz, size: 1.71KB
FS File: /temp.csv, size: 18B

mDNS responder started: http://esp8266.local
HTTP server started.
Starting UDP
Local port: 123
Time server IP: 132.163.96.2
Sending NTP request
Sending NTP request
NTP response: 1540569686
Temperature requested
Appending temperature to file: 1540569742,24.44
Temperature requested
Appending temperature to file: 1540569802,24.44

// AT THIS POINT I STARTED THE WEBPAGE//

handleFileRead: /
Sent file: /index.html.gz
handleFileRead: /temperatureGraph.js
Sent file: /temperatureGraph.js.gz
handleFileRead: /temp.csv

Panic C:\Users\LotusH-4\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.2\libraries\ESP8266WiFi\src\include/DataSource.h:93 const uint8_t* BufferedStreamDataSource::get_buffer(size_t) [with TStream = Stream; uint8_t = unsigned char; size_t = unsigned int]: Assertion 'cb == stream_rem' failed.

ctx: cont
sp: 3ffffba0 end: 3fffffd0 offset: 01b0

stack>>>
3ffffd50: 3fff1abc 00000012 3fff0618 40202e0d
3ffffd60: 3fff12fc 00000000 3fff1bf4 4020a765
3ffffd70: 3ffef418 00000419 00000419 00000012
3ffffd80: 00000012 00000000 3fff1a9c 40212281
3ffffd90: 00000012 00000000 00000012 402132d8
3ffffda0: 00000000 4bc6a7f0 00000012 4020ff00
3ffffdb0: 00000000 00000000 3fff1a9c 4020a3ee
3ffffdc0: 3fff12fc 3ffef1a0 401064d4 00000000
3ffffdd0: 00000012 00000012 3fff1bf4 4020a671
3ffffde0: 026ed49b 3ffef1a0 3ffffe7c 00000012
3ffffdf0: 3fff1bf4 3ffffe40 0000001c 00000012
3ffffe00: 3fff1bf4 3ffffe40 3fff1bf4 4020a72c
3ffffe10: 00000012 3ffffe40 00000000 4020aab4
3ffffe20: 00000000 3ffef440 3ffffeb0 00000001
3ffffe30: 00000012 3ffef440 3ffffeb0 40207f85
3ffffe40: 40213828 00000000 000003e8 3ffef11c
3ffffe50: 3fff0d54 3fff0d1c 00000000 00000000
3ffffe60: 00000000 00000009 3ffffeb0 4021122f
3ffffe70: 3fff1bd4 0000000f 0000000c 3fff1bbc
3ffffe80: 0000000f 0000000a 3ffffeb0 40211364
3ffffe90: 00000000 00000000 3ffef1a0 3ffef11c
3ffffea0: 00000000 3ffef1e4 3ffef1a0 40208046
3ffffeb0: 3fff0774 0000000f 00000009 00000000
3ffffec0: 00000000 00000000 3ffef1a0 40212d12
3ffffed0: 00000000 00000000 00000000 4020b846
3ffffee0: 00000000 00000000 00000000 4020ce42
3ffffef0: 00000000 00000000 00000000 00000000
3fffff00: 00000000 00000000 401064d4 00021a9f
3fffff10: 3ffef1e4 00000001 50e56041 00000000
3fffff20: 00000000 00000000 4020c244 0000000f
3fffff30: 00000000 3fff1bf4 401064d4 3ffef11c
3fffff40: 00000001 3ffef1c8 3ffef1a0 4020cfec
3fffff50: 026ec835 00000000 3fff1a34 4020b113
3fffff60: 3fffdad0 3ffef164 00021a9f 3ffef518
3fffff70: 3ffef124 3ffef118 00021a9f 40208506
3fffff80: 40213828 00000000 000003e8 3fffefb0
3fffff90: 00000000 00000000 000001f4 4020151f
3fffffa0: 00000000 00000000 00000001 3ffef518
3fffffb0: 3fffdad0 00000000 3ffef510 40211de0
3fffffc0: feefeffe feefeffe 3ffe8514 40100739
<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
vbb28d4a3
~ld

Connecting
.........

Connected to name
IP address: 192.168.1.108
"

It's the same each every time.

What I’ve tried, but haven’t gained success:
I found something similar here: esp8266/Arduino#2504
but after checking the code, I realised I already have the improved DataSource.h.
I tried it with SPIFFS size 512K (64K SPIFFS) and 512K (128K SPIFFS) options as well.

It would be very much appreciated if you could spend some time with it, and give a hint, what I’m doing wrong, what should I improve to make it working!

Thank you,
Blas

Backward slash meaning

Hi
I wanted to know what is the significance of having ** (backward slash) in the following line of code-

server.send(200, "text/html", "<form action="/LED" method="POST"><input type="submit" value="Toggle LED">")

pdf margins (A Beginner's guide..)

Hi Pieter, you did a fantastic job with this manual! Thank you very much!
May I kindly ask you to use a bit bigger margins for the pdf pages? Some pages miss part of top and/or bottom when printed (for example top of page 3).
Also: can you please add page numbes?

Add LLMNR next to mDNS

Hi tttapa,
first of all - great work with the beginner's guide, it's awesome, thank you.

I have a small improvement proposal - I was trying the mDNS and I realized that Windows machines are not compatible with this standard out of the box, it works only if some third party software is installed on windows machine. This is a little unfortunate, but I found it is possible to add LLMNR responder to the esp8266, which is compatible with Windows. There's even a library for that: https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266LLMNR

I would propose to add to your mDNS section also a note about LLMNR - its usage is as simple as importing the library and then calling one function in the setup:

#include <esp8266LLMNR.h>
void setup() {
  // when the network connection is estabilished:
  LLMNR.begin("esp8266");
}

I tried it and both mDNS and LLMNR can coexist together, so it might be good to have both of them to support wider range of devices:

  const char* DOMAIN_NAME = "esp8266";
  MDNS.begin(DOMAIN_NAME);
  LLMNR.begin(DOMAIN_NAME);

Data logging temperature

Hello

I like this A Beginner's Guide to the ESP8266.
Can not find description of how it works with the web page.
How is the website intended to work?
Should I run a local web server on my PC?
Should I upload the files to esp8266 (index.html)?

It looks like this

Connecting
.........

Connected to Eskilstorp
IP address: 192.168.15.48

OTA ready

SPIFFS started. Contents:
FS File: /temp.csv, size: 2.41KB

mDNS responder started: http://esp8266.local
HTTP server started.
Starting UDP
Local port: 123
Time server IP: 132.163.96.2
Sending NTP request
NTP response: 1508680734
Temperature requested
Appending temperature to file: 1508680789,26.50
Temperature requested
Appending temperature to file: 1508680849,26.50
Temperature requested

Sincerely
P-G Åström

websockets example not working

I am trying the websockets example for the first time. I saved all 9 files in the data directory to SPIFFS. When I open http://esp8266.local or the IP listed in the serial monitor I get in Chrome:

This site can’t be reached The webpage at http://192.168.0.10/ might be temporarily down or it may have moved permanently to a new web address. ERR_CONTENT_DECODING_FAILED

On the serial monitor I get:

`Opening port
Port open

Access Point "WOW!3630" started

Connecting
.........

Connected to WOW!3630
IP address: 192.168.0.10

OTA ready

SPIFFS started. Contents:
FS File: /apple-touch-icon-180x180.png, size: 45.39KB
FS File: /edit.html.gz, size: 45.17KB
FS File: /favicon-144x144.png, size: 45.29KB
FS File: /favicon.ico.gz, size: 45.19KB
FS File: /index.html.gz, size: 45.18KB
FS File: /main.css.gz, size: 45.04KB
FS File: /manifest.json, size: 50.78KB
FS File: /success.html.gz, size: 45.20KB
FS File: /WebSocket.js.gz, size: 45.09KB

WebSocket server started.
mDNS responder started: http://esp8266.local
HTTP server started.
handleFileRead: /
Sent file: /index.html.gz`

and a similar response for /edit.html.

Can you give me some suggestions to get it to work? BTW I had to change lines 11-12 in A-WebSocket_LED_control.ino for it to compile without errors with VisualMicro IDE. I changed them to:

`ESP8266WebServer server(80); // create a web server on port 80

WebSocketsServer webSocket(81); // create a websocket server on port 81
`
instead of:

`ESP8266WebServer server = ESP8266WebServer(80); // create a web server on port 80

WebSocketsServer webSocket = WebSocketsServer(81); // create a websocket server on port 81
`

Thank you very much!

I've read an unknown number of tutorials over the years but this one told what I wanted to know without me having to squeeze. Great work, should you decide to write more tutorials I'll surely will read them.

Can I run ESP8266 ESP12E using smartphone USB power adapter?

Thank you for the article. I am thinking of buying ESP8266 ESP12E (something like https://www.amazon.com/Temperature-Humidity-Atmosphetic-BH1750FVI-YellowBlue/dp/B07GPBBY7F). Once the development is over, can I power the board using a regular Smartphone 1A power adapter connecting to microusb port and run independent without connecting to computer in a room as a weather display monitor? If not, any suggestions on using a power supply to achieve the same.

ESP8266FS Plugin Requirement

The ESP8266FS plugin is required to use the 'Sketch Data Upload' tool.

Propose adding it to the tutorial including how to install it etc. Happy to submit a pull request to implement this if desired.

Accessing SPIFFS file to connect to thingSpeak

This is an AWESOME tutorial, thank you. Could you help me? I am using wifiManager and FS.h and ArduinoJson with ESP8266-01 to enter new IP address and Password. This works great. I also create a custom parameter (thingSpeak Write API, apiKey[20]="";) which is entered on the same page as the IP and Password and it is supposedly saved to a SPIFFS file. Once my upload is finished everything connects to the wifi and thingSpeak and uploads my sensor info. However if the power to the ESP is interrupted then I can get the ESP to reconnect but it doesn't upload sensor data anymore. How do I access the SPIFFS data and copy the (thingSpeak Write API) to char apiKey[20]=""; so it can continue uploading information.

Broken ESP afterwards running example 14-

Hello tttapa,

I've uploaded both sketch and data of Websocket example to ESP8266 nodeMCU .

It worked well for about 3 hours, Then something inside the program crashes and ESP keeps restarting twice a second!

What makes it terrible that i can't even upload another code to it!

Can you provide a solution please ?

Thanks
Hamza Hajeir

============= Update : =============
I've found the solution of uploading, I've uploaded another working sketch to esp,
But I am wondering of the cause of the (repeatedly restarting problem) ! That takes out guarantee of the code.

It can be used in both Slave and Master mode (in software).

I think this phrase is very vague. What does "(in software)" mean here? Does it mean that SPI is bit-banged (the paragraph about I2C above used "in software" in this meaning but is clear there), or is only one of the two modes bit-banged, or does it just refer to the fact that SPI is exposed to the user?

Fantastic guide BTW, thank you so much for putting it together!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.