Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By plinioseniore
#17631 Hi,

we have just ported Souliss on ESP8266, see below the screenshot of the Android application SoulissApp.

Image

Here a sample sketch to run togheter with the Souliss library, I strongly suggest to download the whole IDE that contains the Arduino cores for ESP8266 that we have tested from this link.

Code: Select all /************************************************************************** 
   Souliss - Hello World for Expressif ESP8266 
   This is the basic example, create a software push-button on Android 
   using SoulissApp (get it from Play Store).   
   Load this code on ESP8266 board using the porting of the Arduino core 
   for this platform. 
 ***************************************************************************/ 
 // Configure the framework 
 #include "bconf/MCU_ESP8266.h"       // Load the code directly on the ESP8266 
 #include "conf/Gateway.h"          // The main node is the Gateway, we have just one node 
 #include "conf/DynamicAddressing.h"     // Use dynamic addressing 
 #include "conf/DisableEEPROM.h" 
 // Define the WiFi name and password 
 #define WIFICONF_INSKETCH 
 #define WiFi_SSID        "mywifi" 
 #define WiFi_Password      "mypassword"   
 // Include framework code and libraries 
 #include <ESP8266WiFi.h> 
 #include "Souliss.h" 
 // This identify the number of the LED logic 
 #define MYLEDLOGIC     0         
 void setup() 
 {   
   Initialize(); 
   // Connect to the WiFi network and get an address from DHCP 
   Setup_ESP8266();               
   SetAsGateway(myvNet_esp8266);    // Set this node as gateway for SoulissApp   
   // This node will serve all the others in the network providing an address 
   SetAddressingServer(); 
   Set_SimpleLight(MYLEDLOGIC);    // Define a simple LED light logic 
   pinMode(5, OUTPUT);         // Use pin 5 as output   
 } 
 void loop() 
 {   
   // Here we start to play 
   EXECUTEFAST() {             
     UPDATEFAST();   
     FAST_50ms() {  // We process the logic and relevant input and output every 50 milliseconds 
       Logic_SimpleLight(MYLEDLOGIC); 
       DigOut(5, Souliss_T1n_Coil,MYLEDLOGIC); 
     }   
     // Here we handle here the communication with Android 
     FAST_GatewayComms();                     
   } 
 } 


This tiny sketch handle the communication with SoulissApp and control a relay (we have tested on Olimex ESP8266-EVB) on GPIO5.

Is just the simplest example, you can mix multiple ESP and control them from a central point, either SoulissApp or openHAB and have a network that contains also Arduino based on ATmega AVR that use 2.4 GHz radio like nRF24L01 and RFM69 or RS485 communication.

Have a try, and share your ideas!