Syntax Highlighting
ESP8266 Usage Example
The ESP8266 has built-in wifi and can be used to trigger Alexa routines via LittleNodes.com. The setup is pretty straight forward because you can use the built in WIFI libraries to get the ESP8266 to visit a LittleNodes virtual button link.

Scenario:
The below example is used on a Solar powered LED lamp with a PIR sensor which only works at night and runs off an 18650 battery. When motion is detected the LED lamp will turn on and will light up for about 5 minutes. The ESP8266 is connected in paralell with the LED lamp. When the LED turns on the ESP8266 will connect to littlenodes.com's API link and will then immediatly go into deep sleep to save battery power whilst the LED is still running for a few more minutes.

//Sketch Example By Martin Viljoen 2021-08-07
//This sketch will trigger a LittleNodes.com Virtual button URL and then go to sleep untill its powerd up again.
#include "ESP8266WiFi.h"
#include "ESP8266HTTPClient.h"

const char* ssid     = "Accesspoint_SSIS";
const char* password = "Accesspoint_Password";

int ConnectAttemp=0;
void setup() {
  Serial.begin(115200);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    ConnectAttemp++;
    delay(500);
    Serial.print(".");
    if(ConnectAttemp>=50){break;}//Bailout if wifi is not available.
  }

  Serial.println("");
  Serial.println("WiFi connected");  
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

}

void loop() 
{
//Define virtual button link
const char* host = "https://www.littlenodes.com/api/alexa/triggeralexa.php?email=EMAIL@emailaddress.com&apikey=API_KEY_HERE";
HTTPClient http;            
WiFiClientSecure client;
client.setInsecure(); 
client.connect(host, 443);
  
http.begin(client, host);

String payload;
Serial.print("Fetching From: ");
Serial.println(host);
if (http.GET() == HTTP_CODE_OK)    
    payload = http.getString();     
    Serial.println(payload);    
    Serial.println("Entering infinite deep sleep");     
    ESP.deepSleep(0);
   
}