In this tutorial we see how to turn off ESP8266 WiFi, There are two methods to turn off wifi first is to use simple ESP8266WiFi.h Library and use WiFi.mode(WIFI_OFF); and another method to use WiFi.forceSleepBegin(); By turning wifi off you can save some power. or using only (WIFI_STA) station mode you can hide ESPs own Access point.
Tag Archives: ESP8266
Connecting ESP8266 to wifi router (HotSpot) Example
Connecting ESP8266 to WiFi is first step when using ESP8266. In all projects of ESP8266 Connecting to WiFi and then accessing other thing is must. ESP8266 can operate in three different modes: Wi-Fi station, Wi-Fi access point, and both at the same time. Let’s Connect ESP8266 NodeMCU to WiFi.
Things you’ll need
- A WiFi router/modem, or You can use your mobile hot spot.
- Your WiFi network name (SSID) and password (WPA). If you need to set up, check or change the WiFi network name or password, you’ll need to check your modem’s setup guide or user manual for instructions on how to do this.
- A computer, laptop or other device with a built-in WiFi adapter or a plugin USB WiFi adapter.
Continue reading Connecting ESP8266 to wifi router (HotSpot) Example
ESP8266 NodeMCU TCP Socket Server Arduino Example
In this tutorial we are making ESP8266 NodeMCU as TCP Socket Server for bidirectional communication. Before we start directly on Socket programming let’s have some understanding of what is TCP Socket.
Continue reading ESP8266 NodeMCU TCP Socket Server Arduino Example
Arduino reading and writing string to EEPROM
The arduino and ESP8266 EEPROM library only provides functions to read and write one byte at a time from the internal EEPROM. Note that EEPROM has limited number of writes.
In this tutorial I will provide some functions to store string to EEPROM and Read back to String variable. String is basically character array terminated with null (0x00).
Continue reading Arduino reading and writing string to EEPROM
Arduino NodeMCU (ESP8266) Spiffs File System Uploading and Reading
In this tutorial we upload a text file and read it in serial monitor.
Steps to Upload a file in NodeMCU SPIFFS file system
ESP8266FS is a tool which integrates into the Arduino IDE. It adds a menu item to Tools menu for uploading the contents of sketch data directory into ESP8266 flash file system.
-
Download the tool: https://github.com/esp8266/arduino-esp8266fs-plugin/releases/download/0.1.3/ESP8266FS-0.1.3.zip.
- In your Arduino sketchbook directory, create tools directory if it doesn’t exist yet
- Unpack the tool into tools directory (the path will look like <home_dir>/Arduino/tools/ESP8266FS/)
- Restart Arduino IDE
- Open a sketch (or create a new one and save it)
- Go to sketch directory (choose Sketch > Show Sketch Folder)
- data older next to your .ino file
- Create a directory named data and put your files you want in the file system there
- Make sure you have selected a board, port, and closed Serial Monitor
- Select Tools > ESP8266 Sketch Data Upload. This should start uploading the files into ESP8266 flash file system. When done, IDE status bar will display SPIFFS Image Uploaded message. Note during upload it takes longer time.
Reading Uploaded File
In above process we uploaded notes.txt file in ESP flash. In this program we read it and display its contents in serial monitor. Uploading of sketch will not affect sketch data. i.e. uploaded notes.txt file.
/* * ESP8266 Communication and Protocols * SPIFFS Direct File Upload Example * -Manoj R. Thkuar */ #include <ESP8266WiFi.h> #include <FS.h> //Include File System Headers const char* file = "/notes.txt"; //Enter your file name void setup() { delay(1000); Serial.begin(115200); Serial.println(); //Initialize File System SPIFFS.begin(); Serial.println("File System Initialized"); File dataFile = SPIFFS.open(file, "r"); //Open File for reading Serial.println("Reading Data from File:"); //Data from file for(int i=0;i<dataFile.size();i++) //Read upto complete file size { Serial.print((char)dataFile.read()); //Read file } dataFile.close(); } void loop() { }
Results
In serial monitor you will get File contents, you can upload images, html and javascript files. examples can be found here
- Image upload and display
- JavaScript Gauges