Skip to content

Template to build ESP8266 projects using OTA and Web config

Notifications You must be signed in to change notification settings

Pedroalbuquerque/template

Repository files navigation

Template to build ESP8266 projects using OTA and Web config

This sketch was created to be a framework or base sketch to create new projects for ESP8266.

Some basic functionalities are provided:

  • OTA (Over The Air) programing or wireless upload of code as an alternative to Serial upload
  • EEPROM saved configuration to allow the board to connect to your access point when booting
  • Web configuration page to allow changing the EEPROM saved configuration
  • AP (Access Point) boot when connection to your access point does not suceed
  • NTP to allow you to have a variable with current date and time loaded from internet

How to use it

Download all the files from this template to a folder on your environment and rename the folder "Template" to your sketch name. Rename also the Template.ino file acordingly.

For a brand new board you have to load this sketch using a serial port upload via an FTDI or other UBS to Serial interface.

Once loaded, the sketch will try to load configuration from EEPROM (nothing will be saved when loaded for the first time), and if no configuration is found, board will enter in AP mode. In this mode a new AP will be available for you to connect your PC or Mobile phone, with the name "ESP8266-xxxx" and no password. The board will be assigned the IP:192.168.4.1. Once you connect your PC or phone to this AP("ESP8266-xxxx"), you can open a browser and try to access the address 192.168.4.1, that will show you the main configuration page Choose "Network Configuration button" to define SSID and Password so the board can connect to your home Access point(router) and use the "Save" button to save it to the EEPROM. Board will reset and connect to your router acquiring a new IP address on your LAN network. On your Serial Monitor you can see what is the board new IP address assigned by your router and you can now connect to the board via this new IP. To do so now you have to reconnect your PC or phone to your home router.

You can test it by using a "ping" command from a command line on your PC or Terminal if on a MAC.

If you succeed, a new port should show up (may take a 1 to 3 minutes to show up) in your Arduino IDE environment to allow to OTA your next sketch to the board.

How to write your own code

Assuming you are familiar with the Arduino framework, you have the same two basic function setup() and loop(), that already have some basic code to implement this basic functionality of the template. you can find in this to function a place holder like //**** Normal Sketch code here...

  write you own setup code after this comment

You can naturally include your libraries in the sketch as necessary for your specific code.

Hope you can find this interesting and useful.

Pedro Albuquerque

About

Template to build ESP8266 projects using OTA and Web config

Resources

Stars

Watchers

Forks

Packages

No packages published