Yes. I'm trying to build it for the Arduino Mega because I've already got the code for collecting the sensor data and sending it to the Remotexy app done.
This is the code that I've got so far:
#define REMOTEXY_MODE__ESP8266_HARDSERIAL_CLOUD
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_SERIAL Serial1
#define REMOTEXY_SERIAL_SPEED 115200
#define REMOTEXY_WIFI_SSID "xxx"
#define REMOTEXY_WIFI_PASSWORD "xxx"
#define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com"
#define REMOTEXY_CLOUD_PORT 6376
#define REMOTEXY_CLOUD_TOKEN "xxx"
//Temperatura
const double VCC = 3.3;
const double R1 = 9850; // 10k ohm series resistor
const double adc_resolution = 4096;
const double A = 0.001129148;
const double B = 0.000234125;
const double C = 0.0000000876741;
int TempS1 = 99;
//Reflectoare
int LightS = A0; // Fotorezistor
int LightR = 7; // Releu reflectoare
int MotionSensor1 = 8;
int MotionSensor2 = 9;
int MotionSensor3 = 10;
int MotionSensor4 = 11;
int LightStat;
int LightV;
int LightM;
unsigned long onDuration = 90000;// OFF time for LED
unsigned long offDuration = 10000;// ON time for LED
unsigned long rememberTime=0;// this is used by the code
int LEDState = HIGH;
unsigned long secunda = 1000;
unsigned long timp = 0;
int contor = 0;
//Vant
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 1000; // the debounce time; increase if the output flickers
int pinInterrupt = 2; //senzor vant
int Count = 0;
int Vant;
int VantMax = 0;
//Alarma
int MotionSensor = 4; // Senzor miscare
int MotionSignal = 5; // Semnal sirena
//Apa
int ReleuApaGeneralSemnal = 12;
int ReleuApaGeneralStat;
//Ploaie
#define CALC_INTERVAL 1000
#define DEBOUNCE_TIME 15*1000
const int RainSensor = 3;
float TotalVolume = 0;
long NrTips = 0;
long last_micros_rg;
long nextCalc;
long Cronometru;
int PloaieReset;
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] = // 418 bytes
{ 255,5,0,27,0,155,1,16,30,5,130,1,255,2,65,96,0,31,129,0,
4,251,53,6,0,13,65,117,116,111,109,97,116,105,122,97,114,101,32,99,
117,114,116,101,0,131,1,1,99,21,7,1,13,31,71,101,110,101,114,97,
108,0,130,0,0,2,16,18,1,31,67,6,1,7,7,4,1,135,31,4,
129,0,8,7,4,2,1,135,75,77,47,72,0,129,0,1,3,13,3,1,
8,86,195,162,110,116,32,77,97,120,0,129,0,1,11,13,3,1,8,86,
195,162,110,116,32,76,105,118,101,0,67,6,1,15,7,4,1,135,31,4,
129,0,8,15,4,2,1,135,75,77,47,72,0,130,0,16,2,23,11,1,
31,70,16,17,6,6,6,1,16,135,0,10,50,24,6,14,6,1,0,31,
31,79,78,0,0,79,70,70,0,129,0,19,3,16,3,1,8,82,101,102,
108,101,99,116,111,97,114,101,0,130,0,16,13,23,18,1,31,129,0,22,
14,10,3,1,8,65,108,97,114,109,196,131,0,10,50,25,24,12,6,1,
1,31,31,79,78,0,1,79,70,70,0,70,16,18,24,6,6,1,16,37,
0,130,0,0,20,16,14,1,31,1,2,2,29,11,4,0,31,164,82,101,
115,101,116,0,129,0,3,21,8,3,1,8,80,108,111,97,105,101,0,67,
2,0,25,9,4,0,164,31,6,129,0,9,24,5,3,0,164,76,105,116,
114,105,0,130,0,16,31,23,10,1,31,129,0,25,32,5,3,1,8,65,
112,196,131,0,10,50,18,17,19,6,1,1,31,31,65,114,109,97,116,196,
131,0,1,68,101,122,97,114,109,97,116,196,131,0,10,50,27,36,10,4,
1,6,31,31,79,78,0,6,79,70,70,0,129,0,18,37,7,2,1,8,
71,101,110,101,114,97,108,0,67,6,16,41,23,6,0,135,26,11 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
uint8_t Reflectoare_B; // =1 if state is ON, else =0
uint8_t Alarma; // =1 if state is ON, else =0
uint8_t PloaieReset; // =1 if button pressed, else =0
uint8_t Alarma_A; // =1 if state is ON, else =0
uint8_t ApaGeneral; // =1 if state is ON, else =0
// output variables
char Vant_Max[4]; // string UTF8 end zero
char Vant_Live[4]; // string UTF8 end zero
uint8_t Reflectoare_L; // led state 0 .. 1
uint8_t Alarma_L; // led state 0 .. 1
char Litri[6]; // string UTF8 end zero
char text_1[11]; // string UTF8 end zero
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
void setup() {
Serial.begin(115200);
delay(2000);
RemoteXY_Init ();
delay(1000);
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,INPUT);
pinMode(5,OUTPUT);
pinMode(A0,INPUT);
pinMode(7,OUTPUT);
pinMode(8,INPUT);
pinMode(9,INPUT);
pinMode(10,INPUT);
pinMode(11,INPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
//Pini de la 14-19 pt Serial comunication. 18, 19 conectat esp-ul
digitalWrite(LightR,HIGH);
digitalWrite(ReleuApaGeneralSemnal,HIGH);
//timer.setInterval(1000L, sendSensor);
//interrupt vant
pinMode( pinInterrupt, INPUT_PULLUP);// set the interrupt pin
attachInterrupt( digitalPinToInterrupt(pinInterrupt), CounterVant, FALLING);
//interrupt ploaie
attachInterrupt(digitalPinToInterrupt(RainSensor), Ploaie, RISING);
}
void loop() {
RemoteXY_Handler ();
//START Vant
if ((millis() - lastDebounceTime) > debounceDelay)
{
lastDebounceTime = millis();
Vant=((Count * 8.75)/100)*3.6;
Count = 0;
itoa (Vant, RemoteXY.Vant_Live, 10);
if (Vant > VantMax) {
VantMax = Vant;
itoa (VantMax, RemoteXY.Vant_Max, 10);
}
}
//STOP Vant
//START Reflectoare
LightV = analogRead(LightS);
//itoa (LightV, RemoteXY.Senzor_Lumina, 10);
if (RemoteXY.Reflectoare_B == 1) {
digitalWrite(LightR, LOW);
} else {
if (LightV > 900) {
RemoteXY.Reflectoare_L = 1;
if( LEDState == HIGH ){
if( (millis()- rememberTime) >= onDuration){
LEDState = LOW;// change the state of LED
rememberTime=millis();// remember Current millis() time
}
} else {
if( (millis()- rememberTime) >= offDuration){
LEDState = HIGH;// change the state of LED
rememberTime=millis();// remember Current millis() time
}
}
digitalWrite(LightR, LEDState);// turn the LED ON or OFF
/*
if (digitalRead(MotionSensor1) == HIGH){
digitalWrite(LightR,LOW);
RemoteXY.Reflectoare_L = 1;
} else {
if (digitalRead(MotionSensor2) == HIGH){
digitalWrite(LightR,LOW);
RemoteXY.Reflectoare_L = 1;
} else {
if (digitalRead(MotionSensor3) == HIGH){
digitalWrite(LightR,LOW);
RemoteXY.Reflectoare_L = 1;
} else {
if (digitalRead(MotionSensor4) == HIGH){
digitalWrite(LightR,LOW);
RemoteXY.Reflectoare_L = 1;
} else {
digitalWrite(LightR,HIGH);
RemoteXY.Reflectoare_L = 0;
}
}
}
}
*/
} else {
digitalWrite(LightR,HIGH);
RemoteXY.Reflectoare_L = 0;
}
if (LightV > 900) {
if( (millis() - timp) >= secunda){
timp = millis();
if (digitalRead(MotionSensor1) == HIGH){
contor = contor + 1;
itoa (contor, RemoteXY.text_1, 10);
Serial.println(contor);
}
}
}
}
//STOP Reflectoare
//START Alarma
if (RemoteXY.Alarma_A == 1) {
if (RemoteXY.Alarma == 1) {
digitalWrite(MotionSignal,HIGH);
RemoteXY.Alarma_L = 1;
} else {
if (digitalRead(MotionSensor) == 1) {
digitalWrite(MotionSignal,HIGH);
RemoteXY.Alarma_L = 1;
} else {
digitalWrite(MotionSignal,LOW);
RemoteXY.Alarma_L = 0;
}
}
} else {
RemoteXY.Alarma = 0;
digitalWrite(MotionSignal,LOW);
RemoteXY.Alarma_L = 0;
}
//STOP Alarma
//START Ploaie
Cronometru = millis();
if(Cronometru > nextCalc) {
nextCalc = Cronometru + CALC_INTERVAL;
itoa (TotalVolume, RemoteXY.Litri, 10);
}
if (RemoteXY.PloaieReset == 1){
NrTips = 0;
TotalVolume = 0;
}
//STOP Ploaie
//START Apa
if (RemoteXY.ApaGeneral == 1) {
digitalWrite(ReleuApaGeneralSemnal,LOW);
} else {
digitalWrite(ReleuApaGeneralSemnal,HIGH);
}
//STOP Apa
} // END LOOP
void CounterVant()
{
if ( digitalRead(pinInterrupt) == LOW )
Count++;
}
void Ploaie() {
if((long)(micros() - last_micros_rg) >= DEBOUNCE_TIME) {
NrTips += 1;
TotalVolume = NrTips*(0.00165/0.0055);
last_micros_rg = micros();
}
}