Topic: Physical button in addition to remotexy project
Hi there,
I want to have 2 physical buttons/switches in addition to the control via remotexy-app.
Could somebody maybe give a suggestion on how to implement this?
The buttons are on D5 and D6. But I haven't been able to implement them to work properly.
I'm using NodeMCU v2 (ESP 8266) with dual realy-module and two status-LEDs.
The RemoteXY-project is basicly just 2 switches.
Code and wiring below.
Thanks
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
#include <ESP8266WiFi.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "RemoteTest"
#define REMOTEXY_WIFI_PASSWORD "test1234"
#define REMOTEXY_SERVER_PORT 6377
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,2,0,0,0,69,0,10,13,1,
2,0,8,53,46,15,2,26,31,31,
65,78,0,65,85,83,0,2,0,8,
21,46,15,2,26,31,31,65,78,0,
65,85,83,0,129,0,20,14,23,6,
8,82,101,108,97,105,115,32,49,0,
129,0,20,46,23,6,8,82,101,108,
97,105,115,32,50,0 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
uint8_t relais_01; // =1 if switch ON and =0 if OFF
uint8_t relais_02; // =1 if switch ON and =0 if OFF
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#define PIN_RELAIS_01 D7
#define PIN_RELAIS_02 D3
#define LED_01 D1
#define LED_02 D2
#define BUTTON_01 D5
#define BUTTON_02 D6
void setup()
{
RemoteXY_Init ();
pinMode (PIN_RELAIS_01, OUTPUT);
pinMode (PIN_RELAIS_02, OUTPUT);
pinMode (LED_01, OUTPUT);
pinMode (LED_02, OUTPUT);
}
void loop()
{
RemoteXY_Handler ();
digitalWrite(PIN_RELAIS_01, (RemoteXY.relais_01!=0)?LOW:HIGH);
digitalWrite(PIN_RELAIS_02, (RemoteXY.relais_02!=0)?LOW:HIGH);
if (RemoteXY.relais_01!=0) digitalWrite(LED_01, HIGH);
else digitalWrite(LED_01, LOW);
if (RemoteXY.relais_02!=0) digitalWrite(LED_02, HIGH);
else digitalWrite(LED_02, LOW);
}