Skip to content

This is my playground code for ESP8266. The attempt was to make a simple Arduino / ESP8266 based IoT device which receive the Over the air updates and perform actions on the commands received from server

License

geekvikas/esp8266-iot-device

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IO LED

A simple Single LED based device that display different pattern of LED depending upon the command received from central server

Directory Structure

Firmware

Contains the entire Arduino Project. Firmware.ino is the main file.

Compiling the code from VS Code

I have used https://github.com/fabienroyer/VisualStudioCodeArduino to help me compile / upload the sketch directly from VSCode. You can compile it manually and update using Arduino IDE as well.

Web

This is the source code for NodeJs / MEAN app for managing / viewing the registered devices. Web server manage the registration and can be used to send commands to each device as response to heartbeat event. This allow for completely disconnected and one way traffic, also known as "Push initiated by Pull"

Current supported Tasks are

enum TASK{
      NOP,            // No operation is required
      REG_OK,         // Valid Registration received from server, update the local device Id and registration check skip limit
      REG_INVALID,    // Invalid Registration - Potentially forced re-registration check from server, device lost mode
      SLEEP,          // Sleep the device for a certain period, save battery
      LED,            // LED operation
      CONFIG_UPDATE,  // Update the local Configuration file from a Server URL
      FACTORY_RESET,  // Remove the local config file and revert back to Default configurations, drop the Network connections
      FW_UPDATE,      // Update the local FW from a Server URL
      REBOOT,         // Reboot the device
      SHUTDOWN        // Turn Off / Shutdown the device. Forced re-registration by server, or device BLACKLIST mode
    };

Boot Process

  1. Look for default.config and connect to WiFi
  2. If no default.config is present then boot up and try to connect to default WiFi
    • SSID : $DEVICE_DISCOVERY$
    • Pass : admin@12345
  3. Go to http://dev.idnno.com/api/v1/device to download default.config
  4. default.config contains following information
{
	"AP_NAME":"SSID_HERE",
	"AP_KEY":"Super_Secret_Password_Here",
	"EP_URL":"http://XXX.YYY.ZZZ.AAA:3000/"
}
  1. Connect to WiFi from the Config file
  2. Update the device Time from the epochUtc
  3. Send a heartbeat and update the status of device in Dashboard
  4. Check for FW Update
  5. If required, update the FW and reboot, go to Step 1 again
  6. Call the lightStatus and change the light accordingly, sleep for the interval in heartbeat
  7. go to Step 6

About

This is my playground code for ESP8266. The attempt was to make a simple Arduino / ESP8266 based IoT device which receive the Over the air updates and perform actions on the commands received from server

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published