Skip to content

Arduino library to easy control the networks for the ESP8266 and ESP32

License

Notifications You must be signed in to change notification settings

AndresDuran53/zarus-network-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License GitHub release (latest SemVer) GitHub Tag (latest SemVer)

IoT Network Controller for ESP8266 and ESP32

Easy-To-Use library to implement just the code that you need.

Look at the Zarus IoT Hub to get an easy way to connect to the devices without an IP.

This library works with the ESP8266 and ESP32, and manages the connections of the device. This way the device can create an Access Point (AP mode) and connect to another Access Point (Station Mode) without re-writing again the code for each project.

It's able to manage:

  • AccesPoint and Stacion Mode simultaneously.
  • MQTT connection.
  • Local storage in EEPROM with indexing.
  • Loops async without delay().
  • Controls methods over a HTTP created with Bootstrap.
  • Modifies stored data like credentials over HTTP.
  • Adds device-type and an Unique identifier to avoid conflict.
  • Configures all this with almost no code and production-friendly

Quick Start

Libraries and tools needed

Tools for uploading files into the ESP device:

Libraries:

Code Diagram

Methods

  • Setup:

     static void setup(String deviceType,
           uint8_t consoleLevel = 0,
           String deviceToken = DEVICE_TOKEN);
    • Description: Setup the init values that we want to give it to the device, set the logger, data and timers
    • Parameters:
      • deviceType (String):
      • consoleLevel (Unsigned Integer 8 Bytes):
      • tokenDevice (String):
  • Init:

     static void init();
    • Description: Configure the connections with the data that we already passed on the setup.
  • Loop:

     static void loop();
    • Description: Use an internal loop to run the timers, receive data and check the connections,
  • createStoredData:

     static void createStoredData(String name, String commandName,
           int valueLenght, String defaultValue,
           String valueType, void (setFunction)(String value));
    • Description: Add data that we want to manipulate in the EEPROM and assing an internal index to be able to find it, also receive a method that is the one that we want to execute everytime that the values change.
    • Parameters:
      • name (String):
      • commandName (String):
      • valueLenght (Integer):
      • defaultValue (String):
      • valueType (String):
      • setFunction (Function Pointer):
  • changeStoredValue:

     static boolean changeStoredValue(String commandName, String value);
    • Description: Change/Update the value stored using his commandName assigned.
    • Parameters:
      • commandName (String):
      • value (String):
  • sendMqttMessage:

     static boolean sendMqttMessage(String message);
    • Description: Sends a message using MQTT if it is defined an connected.
    • Parameters:
      • message (String):
  • AddTimer:

     static void addTimer(int intervalInMillis, void (actionToExecute)());
    • Description: Add a timer to avoid using delay() in our code, every logic that we want to execute in the normal loop the arduino, we are going to create a method and pass it here with a interval in milliseconds.
    • Parameters:
      • intervalInMillis (Integer):
      • actionToExecute (Lambda):
  • Print:

     static void print(String message);
    • Description: Use it to print messages in the same format with the internal logger.
    • Parameters:
      • message (String):

Example Blink

#include "IoTController.h"

int ledPin = 0;
String deviceType = "blink-device";
String deviceToken = "zzz999";
uint8_t consoleLevel = 3;
boolean toggleStatus = false;

void makeItBlink() {
  digitalWrite(ledPin, toggleStatus);
  toggleStatus = !toggleStatus;
  IoTController::print("Blinking...");
}

void setup() {
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, false);
  IoTController::addTimer(1000,makeItBlink);
  IoTController::setup(deviceType,consoleLevel,deviceToken);
  IoTController::init();
}

void loop() {
  IoTController::loop();
}

Implementations

  • ESP8266 integration
  • Access Point at boot
  • Easy connections with others AP
  • EEPROM used to stored values
  • Allows to create custom EEPROM variables
  • Reconnections timers
  • Allows to add custom non-blocking timers
  • MQTT Integration
  • Logger integrated
  • Update SPIFF due is deprecated
  • Make it compatible with ESP32
  • Allows more types in EEPROM other than String

License

Zarus IoT Controller is an open source code. All files are licenced under Creative Commons Reconocimiento-NoComercial-CompartirIgual 4.0 Internacional