Wiki

VirginSoil-Basic

The VirginSoil-Basic example comes with the IOTAppStory library as explained here.

This example code is the bare minimum you need to get your apps working with the library and doing OTA updates from the IOTAppStory server. After compiling you will be able to press a button to check for updates or boot to configuration mode for setting up wifi credentials.

Having said that, you will be pretty blind when you turn off your serial monitor, as you will have no clue what your app is doing. This is why we talk about callbacks in the next pages. But for now let's have a look at the bare necessities.


Methods used

 

#define COMPDATE __DATE__ __TIME__
#define MODEBUTTON 0


#include <IOTAppStory.h>		// IOTAppStory.com library
IOTAppStory IAS(COMPDATE, MODEBUTTON);	// Initialize IotAppStory

The compile date is used by the library internally. More on that later.

When your app is running the mode button is used to check for updates or boot to configuration mode. You can select any input pin you want. But GPIO 0 (D3 for Wemos, NodeMCU etc.) is already on most esp boards for selecting upload(flash) mode during boot. So why not use it as it becomes useless after boot.

Include & initialize the library.

 

// ======================== SETUP ======================== 
void setup() {
  IAS.begin('P');
	

  //-------- Your Setup starts from here ---------------

}

All you have to do in the setup is begin IAS. The begin method has 1 optional parameter and is explained here.

If posible place your personal code after the begin method. This gives the library a better chance in having enough memory to setup HTTPS connections for OTA updates on boot. In some rare occasions you might run into compatibillity issue with other libraries forcing you to place it above begin. This is ok, just don't make it a habbit.

 

// ======================== LOOP ======================== 
void loop() {
  IAS.loop();

  //-------- Your Sketch starts from here ---------------

}

The loop method handles the reaction of the MODEBUTTON and call home interval when set.

Just like with the setup() please place your code below the loop.

VirginSoil-Full
VirginSoil examples

Post by

Onno Dirkzwager