1

Topic: Remotexy will not connect to cloud server

I have written a small bit of test code for testing purposes below.
I have an Arduino Mega with onboard wifi via the ESP8266 chip. The Arduino and the ESP8266 communicate via the serail 3 port.
The test code works fine via the remotexy app on my Android smartphone.
Whne i cut and paste my test code and place it into my irrigation system code the app fails to connect to the server. I am not sure why this occurs, can you please assist.

I'm not sure how to upload an image of the server error codes. I have a jpg file i can share, just dont know how to upload it here.

I can not upload my irrigation system code as it exceeds the number of allowable bytes. How else can I uplaod my irrigation code?






This is the test code:

// RemoteXY select connection mode and include library 
#define REMOTEXY_MODE__ESP8266_HARDSERIAL_CLOUD

#include <RemoteXY.h>

// RemoteXY connection settings 
#define REMOTEXY_SERIAL Serial3
#define REMOTEXY_SERIAL_SPEED 115200
#define REMOTEXY_WIFI_SSID "intentionally left blank"
#define REMOTEXY_WIFI_PASSWORD "intentionally left blank"
#define REMOTEXY_CLOUD_SERVER "cloud.remotexy.com"
#define REMOTEXY_CLOUD_PORT 6376
#define REMOTEXY_CLOUD_TOKEN "intentionally left blank"

int led = 13;
int ledstate = 0;


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,0,0,16,0,10,13,0,
  1,9,8,13,26,7,2,37,116,101,
  115,116,0 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  uint8_t button_1; // =1 if button pressed, else =0 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////



void setup() 
{
  RemoteXY_Init (); 

pinMode(led, OUTPUT);
  digitalWrite(led, LOW);
  
  // TODO you setup code
  
}

void loop() 
{ 
  RemoteXY_Handler ();
  
    if (RemoteXY.button_1!=0) 
    {
     if (ledstate == 0)
     {
     digitalWrite(led, HIGH);
     ledstate = 1;
       RemoteXY.button_1 = 0;
     }
     else
     {
     digitalWrite(led, LOW);
     ledstate = 0;
     RemoteXY.button_1 = 0;
     }
    }
    

2

Re: Remotexy will not connect to cloud server

Most likely your code is blocking the main loop() cycle. RemoteXY_Handler () is not called

3

Re: Remotexy will not connect to cloud server

Most likely your code is blocking the main loop() cycle. Not sure how this could happen.


RemoteXY_Handler () is not called
This handler is called in my void loop.

4

Re: Remotexy will not connect to cloud server

For example bad code:

void loop () {
  RemoteXY_Handler ();

  if (RemoteXY.button_1 == 1) {  
    // if the button is pressed, the code is blocked for 5 seconds and RemoteXY Handler () is not called
    for (int i=0; i<5; i++) {
      digitalWrite(LED_BUILTIN, HIGH );
      delay (500);
      digitalWrite(LED_BUILTIN, LOW);
      delay (500);
    }
  }

}

5

Re: Remotexy will not connect to cloud server

Hi,

Thanks for feedback.
I thought that's what you may have meant by blocking code. I never use the delay() function in my code, I always use the millis() function to create a timer.
I have done some more testing, and you may be able to confirm my conclusion.
At present I have an Arduino Uno connected to a 4D Systems LCD screen acting as the user interface. This is connected via the serial port of the Uno, this has been working reliably for the past 6 months.
I want to introduce remote access to the Uno via RemoteXY.
For testing purposes of RemoteXY I have an Arduino Mega with onboard ESP8266 connected via the serial 3 port.
I have not physically connected the LCD screen to serial port 0 of the Mega.
As part of testing I have strategically cut and paste code from my irrigation system into the Mega in stages until I notice a drop in performance of the RemoteXY connection from my smartphone.
Everything has gone well until I pasted this code in:

genie.WriteObject(GENIE_OBJ_USER_LED, 27, -1);       // Turn off Test LED showing START has been selected
genie.WriteObject(GENIE_OBJ_USER_LED, 29, -1);      // Turn off Test LED showing START water sequence bit has been selected 
genie.WriteObject(GENIE_OBJ_USER_LED, 30, -1);     // Turn off Test LED showing Water Cycle Selected bit has been selected

This code is used to write to objects on the LCD screen.
Once this code is pasted in I notice the response time from my smartphone drops from 1 second to 4-5 seconds.
When I comment out this code the response time improves again.

These genie.writeobject instructions are numerous throughout my code, so I can see the delay becoming much longer if I pasted in all of my code, to the point where RemoteXY will not connect.

I am assuming that since the LCD screen is physically not connected to the Mega that perhaps the serial communications is hanging up and creating the blocking delays I do not need.

The next step of my test is to connect the LCD screen to the Mega via serial 0 and I hope this solves my problem.

I will let you know how I go.

6

Re: Remotexy will not connect to cloud server

Maybe function genie.WriteObject() waits for a response from the display and then exits on timeout, but the timeout is large enough for RemoteXY. Most likely you just need to connect the display.