// 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/IPBroadcast.h"
// **** Define the WiFi name and password ****
#define WIFICONF_INSKETCH
#define WiFi_SSID "ssid"
#define WiFi_Password "pass"
// Include framework code and libraries
#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include <ESP8266mDNS.h>
#include <CapacitiveSensor.h>
/*** All configuration includes should be above this line ***/
#include "Souliss.h"
// This identify the number of the LED logic
#define MYLED 0
// **** Define here the right pin for your ESP module ****
#define OUTPUTPIN 14
const int cap1 = 4; // 470k resistor between the pin 4 and 5
const int cap2 = 5; //Capacitive Sensor
const int sensibil = 100;
CapacitiveSensor csensy = CapacitiveSensor(cap1,cap2);
bool ligado = 0;
OTA_Setup();
void setup()
{
csensy.set_CS_AutocaL_Millis( 0xFFFFFFFF);
Initialize();
Serial.begin(115200);
// Connect to the WiFi network and get an address from DHCP
GetIPAddress();
SetAsGateway(myvNet_dhcp); // Set this node as gateway for SoulissApp
Set_SimpleLight(MYLED); // Define a simple LED light logic
pinMode(OUTPUTPIN, OUTPUT); // Use pin as output
OTA_Init();
}
void loop()
{
long cape = csensy.capacitiveSensor(30); //chama a funcao que le a capacitancia...
Serial.println(cape);
// Here we start to play
EXECUTEFAST() {
UPDATEFAST();
FAST_110ms() { // We process the logic and relevant input and output every 50 milliseconds
if (cape > sensibil )
{
ligado = !ligado;
mInput(MYLED) = Souliss_T1n_ToggleCmd ;
}
Logic_SimpleLight(MYLED);
DigOut(OUTPUTPIN, Souliss_T1n_Coil,MYLED);
}
}
FAST_GatewayComms();
EXECUTESLOW() {
UPDATESLOW();
SLOW_10s() {
Timer_SimpleLight(MYLED);
}
}
OTA_Process();
}