-->
Page 1 of 1

OmEspHelpers: a VERY easy way to bring up IoT toys

PostPosted: Thu Dec 01, 2016 7:13 pm
by David Van Brink
Just sharing a project I've developed. Work in progress, but definitely up and running. OmEspHelpers on github is a library that enables simple web guis with VERY few lines of code, on Arduino ESP8266. No, seriously, here's the canonical "web page to control LED" example. With the library linked in, this is the entire sketch.

Code: Select all#include "OmEspHelpers.h"
#include <ESP8266WebServer.h>
#include <ESP8266WiFi.h>

void buttonProc(const char *page, const char *item, int value, int ref1, void *ref2)
{
    digitalWrite(LED_BUILTIN, ref1);
}

void buttonMomentaryProc(const char *page, const char *item, int value, int ref1, void *ref2)
{
    digitalWrite(LED_BUILTIN, !value);
}

OmWebPages p;
OmWebServer s;

void setup()
{
  Serial.begin(115200);
  Serial.print("\n\nHello OmEspHelpers\n");

  p.beginPage("Home");
  p.addButton("ledOn", buttonProc, 0); // ref=0
  p.addButton("ledOff", buttonProc, 1); // ref=1
  p.addButton("ledMomentary", buttonMomentaryProc);

  s.addWifi("omino warp", ""); // my home network, no password
  s.setHandler(p);
  s.setStatusLedPin(-1); // tell the server not to blink the led; this app uses it.

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, 1); // off
}

void loop()
{
  s.tick(); // in turn calls OmWebPages
  delay(20);
}


And here's the web page it presents:

Image

The general idea is to generate the button and other page elements dynamically, and ensure the main loop is non-blocking, including the Wifi join up. It's built on top of ESP8266WebServer and -WiFi.

Enjoy. Feedback welcome. WIP.

Re: OmEspHelpers: a VERY easy way to bring up IoT toys

PostPosted: Sun Dec 04, 2016 8:59 am
by mrburnette
The general idea is to generate the button and other page elements dynamically, and ensure the main loop is non-blocking, including the Wifi join up. It's built on top of ESP8266WebServer and -WiFi.


Well done! ESP8266 newbies ... rejoyce!

Ray