1

Topic: Multiple instances of RemoteXY

Here is an example code (for NodeMCU v3 or other ESP8266 dev boards) showing that it is possible to have two or more instances of RemoteXY in the same program smile

- Change "mySSID" and "myPassword" in the code for the values of your WiFi AP, and upload to your ESP8266 devboard.
- Connect your Smartphone to that WiFi AP.
- Open RemoteXY App, click "+" and add two Ethernet devices with hostname "rxy" and port 8266 and 8267.

char * ssid     = "mySSID";
char * password = "myPassword";
char * hostName = "rxy";

#include <ESP8266WiFi.h>

#define REMOTEXY_MODE__ESP8266WIFI_LIB
#include <RemoteXY.h> 



// Data for RemoteXY's instance 1
CRemoteXY *rxy1;

const uint16_t rxy1_port = 8266;

const uint8_t PROGMEM rxy1_config[] = { 0,0,12,0,6,5,1,129,0,2,2,4,6,9,65,0 };

struct {
  uint8_t connect_flag;  /* =1 if wire connected, else =0 */
} rxy1_struct;



// Data for RemoteXY's instance 2
CRemoteXY *rxy2;

const uint16_t rxy2_port = 8267;

const uint8_t PROGMEM rxy2_config[] = { 0,0,12,0,6,5,1,129,0,2,2,4,6,9,66,0 };
  
struct {
  uint8_t connect_flag;  /* =1 if wire connected, else =0 */
} rxy2_struct;



void setup()
{
  WiFi.hostname( hostName );
  
  rxy1 = new CRemoteXY( rxy1_config, &rxy1_struct, ssid, password, rxy1_port );
  rxy2 = new CRemoteXY( rxy2_config, &rxy2_struct, ssid, password, rxy2_port );
} 

void loop() 
{
  rxy1->handler();
  rxy2->handler();
}

2

Re: Multiple instances of RemoteXY

That´s fine.....
but this code have to be uploaded on the first ESP-device?
And what code should be uoloaded to the second device?

To which device have i to connected to with my mobile phone?

3

Re: Multiple instances of RemoteXY

There is no need for a second device... smile

4

Re: Multiple instances of RemoteXY

Guillaume wrote:

There is no need for a second device... smile

I don´t understand waht you mean.
There are two connections on two diffrent ports, that also means, they use 2 diffrent ESP to connect, or not?
or do they only use 1 ESP?
But why do i need both connections?

On the other way, im looking for a option, to connect one programm on my mobile phone to two diffrent ESP.
Is this possible?
There should be 4 buttons, two buttons for each ESP and the buttons only have to switch an output pin.

5 (edited by Guillaume 2017-01-28 23:50:56)

Re: Multiple instances of RemoteXY

This code is for one ESP8266. It allows to run multiple RemoteXY instances/interfaces/programs (whatever you call it) from one ESP8266.


What you want to do is like the opposite, I think you can easily do what you want if you can make the two ESP talk to each other... smile

6

Re: Multiple instances of RemoteXY

Guillaume wrote:

This code is for one ESP8266. It allows to run multiple RemoteXY instances/interfaces/programs (whatever you call it) from one ESP8266.


What you want to do is like the opposite, I think you can easily do what you want if you can make the two ESP talk to each other... smile

Okay, now i understand....to you have an example for 2 ESP talking each other?

7

Re: Multiple instances of RemoteXY

You have to describe your project, there are so many ways to use the ESP8266, I can't answer your question because I know nothing about your project. Please create a new topic wink

8

Re: Multiple instances of RemoteXY

Hello
I have a sketch. Look near. Please can wrtie me different

signed char slider_1; /* =-100..100 slider position */
unsigned char slider_1; /* =-100..100 slider position */


i am begginer but more things i do not understanding...
//////////////////////////////////////////////
//        RemoteXY include library          //
//     use  library  version 2.1.3 or up    //
//   use ANDROID app version 3.4.1 or up    //
//////////////////////////////////////////////

/* RemoteXY select connection mode and include library */
#define REMOTEXY_MODE__SERIAL

#include <RemoteXY_Base.h>
#include <RemoteXY_Serial.h>

#include <SoftwareSerial.h>
#include <RemoteXY.h>

/* RemoteXY connection settings */
#define REMOTEXY_SERIAL Serial
#define REMOTEXY_SERIAL_SPEED 9600


/* RemoteXY configurate  */
unsigned char RemoteXY_CONF[] =
   { 7,0,224,0,4,5,5,35,36,11
  ,32,32,1,2,0,45,48,15,6,1
  ,79,78,0,79,70,70,0,4,160,8
  ,3,84,5,2,4,160,6,56,84,5
  ,2,4,32,2,10,6,44,2,4,32
  ,90,10,6,45,2,130,0,32,10,37
  ,37,12,130,0,10,2,80,7,14,129
  ,0,11,6,10,3,0,83,101,114,118
  ,111,32,49,0,130,0,8,55,80,7
  ,14,129,0,9,55,10,3,0,83,101
  ,114,118,111,32,50,0,130,0,1,12
  ,8,40,14,129,0,6,49,10,3,0
  ,83,101,114,118,111,32,51,0,130,0
  ,1,48,18,5,14,130,0,89,12,8
  ,41,14,130,0,79,48,18,5,14,129
  ,0,80,49,10,3,0,83,101,114,118
  ,111,32,52,0,130,0,53,41,36,6
  ,12,129,0,58,42,30,4,0,65,100
  ,97,109,32,197,160,117,106,97,110,115
  ,107,195,189,0,130,0,69,30,20,11
  ,12,129,0,70,32,17,4,0,65,77
  ,65,86,69,84,0,129,0,73,36,11
  ,4,0,54,56,54,32,66,0 };
   
/* this structure defines all the variables of your control interface */
struct {

    /* input variable */
  signed char joystick_1_x; /* =-100..100 x-coordinate joystick position */
  signed char joystick_1_y; /* =-100..100 y-coordinate joystick position */
  unsigned char switch_1; /* =1 if switch ON and =0 if OFF */
  unsigned char slider_1; /* =-100..100 slider position */
  unsigned char slider_2; /* =-100..100 slider position */
  unsigned char slider_3; /* =-100..100 slider position */
  unsigned char slider_4; /* =-100..100 slider position */

    /* other variable */
  unsigned char connect_flag;  /* =1 if wire connected, else =0 */

} RemoteXY;

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

#include <Servo.h>

Servo prve_servo;
Servo druhe_servo;
Servo tretie_servo;
Servo stvrte_servo;


/* defined the right motor control pins */
#define PIN_MOTOR_RIGHT_UP 17
#define PIN_MOTOR_RIGHT_DN 18
#define PIN_MOTOR_RIGHT_SPEED 4

/* defined the left motor control pins */
#define PIN_MOTOR_LEFT_UP 7
#define PIN_MOTOR_LEFT_DN 8
#define PIN_MOTOR_LEFT_SPEED 12

/* defined the LED pin */
#define PIN_LED 13


/* defined two arrays with a list of pins for each motor */
unsigned char RightMotor[3] = 
  {PIN_MOTOR_RIGHT_UP, PIN_MOTOR_RIGHT_DN, PIN_MOTOR_RIGHT_SPEED};
unsigned char LeftMotor[3] = 
  {PIN_MOTOR_LEFT_UP, PIN_MOTOR_LEFT_DN, PIN_MOTOR_LEFT_SPEED};

/*
   speed control of the motor
   motor - pointer to an array of pins
   v - motor speed can be set from -100 to 100
*/
void Wheel (unsigned char * motor, int v)
{
  if (v>100) v=100;
  if (v<-100) v=-100;
  if (v>0) {
    digitalWrite(motor[0], HIGH);
    digitalWrite(motor[1], LOW);
    analogWrite(motor[2], v*2.55);
  }
  else if (v<0) {
    digitalWrite(motor[0], LOW);
    digitalWrite(motor[1], HIGH);
    analogWrite(motor[2], (-v)*2.55);
  }
  else {
    digitalWrite(motor[0], LOW);
    digitalWrite(motor[1], LOW);
    analogWrite(motor[2], 0);
  }
}

#define PIN_SWITCH_1 13


void setup() 
{
  RemoteXY_Init (); 
 
  pinMode (PIN_SWITCH_1, OUTPUT);
   
  /* initialization pins */
  pinMode (PIN_MOTOR_RIGHT_UP, OUTPUT);
  pinMode (PIN_MOTOR_RIGHT_DN, OUTPUT);
  pinMode (PIN_MOTOR_LEFT_UP, OUTPUT);
  pinMode (PIN_MOTOR_LEFT_DN, OUTPUT);
  pinMode (PIN_LED, OUTPUT);

  // TODO you setup code
  prve_servo.attach(9);
  druhe_servo.attach(10);
  tretie_servo.attach(11);
  stvrte_servo.attach(5);

  RemoteXY.slider_1=50;
  RemoteXY.slider_2=50;
  RemoteXY.slider_3=50;
  RemoteXY.slider_4=50;
   
   
}

void loop() 

  RemoteXY_Handler ();
   
      /* manage LED pin */
  digitalWrite(PIN_SWITCH_1, (RemoteXY.switch_1==0)?LOW:HIGH);
     
     /* manage the right motor */
  Wheel (RightMotor, RemoteXY.joystick_1_y - RemoteXY.joystick_1_x);
  /* manage the left motor */
  Wheel (LeftMotor, RemoteXY.joystick_1_y + RemoteXY.joystick_1_x);

  prve_servo.writeMicroseconds(RemoteXY.slider_1*20+500);
  druhe_servo.writeMicroseconds(RemoteXY.slider_2*20+500);
  tretie_servo.writeMicroseconds(RemoteXY.slider_3*20+500);
  stvrte_servo.writeMicroseconds(RemoteXY.slider_4*20+500);
   
 
}