<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — Make communication between Arduino Nano 33 BLE and RemoteXY]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1289&amp;type=atom" />
	<updated>2021-12-10T18:11:20Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=1289</id>
		<entry>
			<title type="html"><![CDATA[Re: Make communication between Arduino Nano 33 BLE and RemoteXY]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4393#p4393" />
			<content type="html"><![CDATA[<p>Hello ! </p><p>Badly no. <br />I didn’t have the time to finish the project, but hope I can get on it soon ! </p><p>If you have any clue, let’s talk about it <img src="https://forum.remotexy.com/img/smilies/wink.png" width="15" height="15" alt="wink" /></p>]]></content>
			<author>
				<name><![CDATA[Mdawaite]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1796</uri>
			</author>
			<updated>2021-12-10T18:11:20Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4393#p4393</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Make communication between Arduino Nano 33 BLE and RemoteXY]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4392#p4392" />
			<content type="html"><![CDATA[<p>Hi!</p><p>did you get it?<br />thanks!</p><br /><div class="quotebox"><cite>Mdawaite wrote:</cite><blockquote><p>Hello everybody,</p><p>I am coming to you because I am trying to run RemoteXY between my iOS phone and my Arduino 33 BLE board. The goal is to control the position of servomotor with my phone. </p><p>I tried a code gave me on the Arduino&#039;s forum, to make the communication by UART. That works (the board is recognize by RemoteXY app).<br />So I implement the source code getting after the edition of the RemoteXY interface. But the IDE tell me &quot;Error compiling for board Arduino 33 BLE&quot;</p><br /><p>Could you please help me to make those devices communicate ? <br />I hope it is possible...? </p><p>Here is the code I now have: </p><br /><div class="codebox"><pre><code>#include &lt;ArduinoBLE.h&gt;

const unsigned int tamponBluetooth = 244;
char receiveBluetooth[tamponBluetooth + 1] = {0,};


///////////////////////////////////////////CONFIG CONNEXION BLE - DEBUT//////////////////////////////////////

//Ne pas changer (tampon max de 20 octets pour une notification, restriction du bluetooth 4.0 et 4.1, 4.2 permettrait 244 octets normalement)
// pour les tests avec appli android, conserver la valeur de 20 ne donnera pas de surprise quand au résultat
const unsigned int tamponPortSerie = 20;
char receptionPortSerie[tamponPortSerie + 1] = {0,}; // + 1 pour le &#039;\0&#039; de fin de chaine

BLEService UARTService(&quot;0000ffe0-0000-1000-8000-00805f9b34fb&quot;);
BLECharacteristic TX_RX(&quot;0000ffe1-0000-1000-8000-00805f9b34fb&quot;, BLEWriteWithoutResponse | BLENotify, tamponBluetooth);

BLEDevice central;


//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library 
#define REMOTEXY_MODE__SOFTSERIAL
//#include &lt;SoftwareSerial.h&gt;

#include &lt;RemoteXY.h&gt;

// RemoteXY connection settings 
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,0,0,11,0,11,13,0,
  4,128,15,14,66,17,2,26 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  int8_t slider_1; // =0..100 slider position 

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

} RemoteXY;
#pragma pack(pop)

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


#include &lt;Servo.h&gt;  

Servo myservo; 

void setup() {
  Serial.begin(9600);
  while (!Serial);

  if (!BLE.begin()) {
    Serial.println(&quot;starting BLE failed!&quot;);
    while (1);
    
      RemoteXY_Init (); 
  
  // TODO you setup code
   myservo.attach(9); 
  RemoteXY.slider_1 = 50; 
  
  }

  // Nom lié au service GENERIC ACCESS 0x1800 (c&#039;est un service obligatoire)
  BLE.setDeviceName(&quot;UART Service&quot;);

  // Nom qui apparait lors d&#039;un scan
  BLE.setLocalName(&quot;UART BLE&quot;);

  // Déclaration du service que l&#039;on veut offrir
  //BLE.setAdvertisedServiceUuid(UARTService.uuid());
  BLE.setAdvertisedService(UARTService);

  UARTService.addCharacteristic(TX_RX);

  BLE.addService(UARTService);

  // Démarrer la publication du service
  BLE.advertise();

  Serial.println(&quot;UART Service&quot;);
  ///////////////////////////////////////////CONFIG CONNEXION BLE - END//////////////////////////////////////
}

 void loop() {
  int ret = 0;
  static int etat = 0, souscrit = 0;

  // Nous sommes un périphérique esclave (serveur)
  // et nous attendons une connexion centrale maitre (client)

  // En attente de connexion d&#039;un client
  central = BLE.central();

  // etat est utilisé pour éviter la répétition de l&#039;information
  if (etat == 0) {
    etat = 1;
    Serial.println(&quot;périphérique esclave (serveur), en attente de connexion d&#039;un client maitre&quot;);
    Serial.println(&quot;&quot;);
  }

  // Test si un appareil s&#039;est connecté
  if (central) {
    delay(500);
    Serial.print(&quot;Connecté à l&#039;appareil suivant: &quot;);
    Serial.println(central.address());
    Serial.println(&quot;&quot;);

    while (central.connected()) {
      if (TX_RX.subscribed()) {
        if (souscrit != 1) {
          souscrit = 1;
          Serial.println(&quot;Notification activée!&quot;);
        }
      } else {
        if (souscrit != 0) {
          souscrit = 0;
          Serial.println(&quot;Notification désactivée!&quot;);
        }
      }
      // ***********************************************************************
      // **** Lecture des données reçues du port série *************************
      if (Serial.available() &gt; 0) {
        memset(receptionPortSerie, 0, tamponPortSerie);
        for (unsigned int i = 0; i &lt; tamponPortSerie; ++i) { // lecture par bloc de 20 max
          receptionPortSerie[i] = Serial.read();
          if (receptionPortSerie[i] == &#039;\r&#039; || receptionPortSerie[i] == &#039;\n&#039; ) {
            break;
          }
        }
        // *********************************************************************
        // **** Envoie des données du port Série sur le module Bluetooth **
        if (writeBleUART(receptionPortSerie))
        {
          Serial.print(&quot;Longueur envoyées: &quot;);
          Serial.println(strlen(receptionPortSerie));
          Serial.print(&quot;Données envoyées: &quot;);
          Serial.println(receptionPortSerie);
        } else {
          Serial.print(&quot;Une erreur s&#039;est produite pour l&#039;envoie des données&quot;);
        }
        // *********************************************************************
      }

      //***********************************************************************
      //**** Lecture des données du module Bluetooth **************************
      ret = readBleUART();
      if (ret == -1) {                     // si retour = 0
        Serial.println(&quot;Une erreur s&#039;est produite!&quot;);
      }
      //*************************************************
      // ******* Votre code personnel ici ***************
      //*************************************************

 RemoteXY_Handler (); 

  // TODO you loop code 
  // use the RemoteXY structure for data transfer 

  int ms = RemoteXY.slider_1*20+500; 
  myservo.writeMicroseconds(ms);
      
    }

    Serial.print(&quot;Déconnecté du central: &quot;);
    Serial.println(central.address());
    Serial.println(&quot;&quot;);
    etat = 0;
  }
}


int writeBleUART(char text[]) {
  if (TX_RX.writeValue(text, strlen(text))) {
    Serial.print(&quot;Size: &quot;);
    Serial.println(strlen(text));
    Serial.print(&quot;  Données envoyées: &quot;);
    Serial.println(text);
    return 1;
  }
  return 0;
}

int readBleUART(void) {
  int ret = 0, lenData = 0;

  if (TX_RX.written()) {
    lenData = TX_RX.valueLength();
    if (lenData) {
      memset(receiveBluetooth, 0, tamponBluetooth);
      ret = TX_RX.readValue(receiveBluetooth, lenData);
      if (ret != lenData) {
        return -1;
      }
    }
  }
  return ret;
}</code></pre></div><p>Lot of thanks !</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[espon]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=2016</uri>
			</author>
			<updated>2021-12-10T15:28:26Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4392#p4392</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Make communication between Arduino Nano 33 BLE and RemoteXY]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=3755#p3755" />
			<content type="html"><![CDATA[<p>Hello everybody,</p><p>I am coming to you because I am trying to run RemoteXY between my iOS phone and my Arduino 33 BLE board. The goal is to control the position of servomotor with my phone. </p><p>I tried a code gave me on the Arduino&#039;s forum, to make the communication by UART. That works (the board is recognize by RemoteXY app).<br />So I implement the source code getting after the edition of the RemoteXY interface. But the IDE tell me &quot;Error compiling for board Arduino 33 BLE&quot;</p><br /><p>Could you please help me to make those devices communicate ? <br />I hope it is possible...? </p><p>Here is the code I now have: </p><br /><div class="codebox"><pre><code>#include &lt;ArduinoBLE.h&gt;

const unsigned int tamponBluetooth = 244;
char receiveBluetooth[tamponBluetooth + 1] = {0,};


///////////////////////////////////////////CONFIG CONNEXION BLE - DEBUT//////////////////////////////////////

//Ne pas changer (tampon max de 20 octets pour une notification, restriction du bluetooth 4.0 et 4.1, 4.2 permettrait 244 octets normalement)
// pour les tests avec appli android, conserver la valeur de 20 ne donnera pas de surprise quand au résultat
const unsigned int tamponPortSerie = 20;
char receptionPortSerie[tamponPortSerie + 1] = {0,}; // + 1 pour le &#039;\0&#039; de fin de chaine

BLEService UARTService(&quot;0000ffe0-0000-1000-8000-00805f9b34fb&quot;);
BLECharacteristic TX_RX(&quot;0000ffe1-0000-1000-8000-00805f9b34fb&quot;, BLEWriteWithoutResponse | BLENotify, tamponBluetooth);

BLEDevice central;


//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library 
#define REMOTEXY_MODE__SOFTSERIAL
//#include &lt;SoftwareSerial.h&gt;

#include &lt;RemoteXY.h&gt;

// RemoteXY connection settings 
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600


// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,0,0,11,0,11,13,0,
  4,128,15,14,66,17,2,26 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  int8_t slider_1; // =0..100 slider position 

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

} RemoteXY;
#pragma pack(pop)

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


#include &lt;Servo.h&gt;  

Servo myservo; 

void setup() {
  Serial.begin(9600);
  while (!Serial);

  if (!BLE.begin()) {
    Serial.println(&quot;starting BLE failed!&quot;);
    while (1);
    
      RemoteXY_Init (); 
  
  // TODO you setup code
   myservo.attach(9); 
  RemoteXY.slider_1 = 50; 
  
  }

  // Nom lié au service GENERIC ACCESS 0x1800 (c&#039;est un service obligatoire)
  BLE.setDeviceName(&quot;UART Service&quot;);

  // Nom qui apparait lors d&#039;un scan
  BLE.setLocalName(&quot;UART BLE&quot;);

  // Déclaration du service que l&#039;on veut offrir
  //BLE.setAdvertisedServiceUuid(UARTService.uuid());
  BLE.setAdvertisedService(UARTService);

  UARTService.addCharacteristic(TX_RX);

  BLE.addService(UARTService);

  // Démarrer la publication du service
  BLE.advertise();

  Serial.println(&quot;UART Service&quot;);
  ///////////////////////////////////////////CONFIG CONNEXION BLE - END//////////////////////////////////////
}

 void loop() {
  int ret = 0;
  static int etat = 0, souscrit = 0;

  // Nous sommes un périphérique esclave (serveur)
  // et nous attendons une connexion centrale maitre (client)

  // En attente de connexion d&#039;un client
  central = BLE.central();

  // etat est utilisé pour éviter la répétition de l&#039;information
  if (etat == 0) {
    etat = 1;
    Serial.println(&quot;périphérique esclave (serveur), en attente de connexion d&#039;un client maitre&quot;);
    Serial.println(&quot;&quot;);
  }

  // Test si un appareil s&#039;est connecté
  if (central) {
    delay(500);
    Serial.print(&quot;Connecté à l&#039;appareil suivant: &quot;);
    Serial.println(central.address());
    Serial.println(&quot;&quot;);

    while (central.connected()) {
      if (TX_RX.subscribed()) {
        if (souscrit != 1) {
          souscrit = 1;
          Serial.println(&quot;Notification activée!&quot;);
        }
      } else {
        if (souscrit != 0) {
          souscrit = 0;
          Serial.println(&quot;Notification désactivée!&quot;);
        }
      }
      // ***********************************************************************
      // **** Lecture des données reçues du port série *************************
      if (Serial.available() &gt; 0) {
        memset(receptionPortSerie, 0, tamponPortSerie);
        for (unsigned int i = 0; i &lt; tamponPortSerie; ++i) { // lecture par bloc de 20 max
          receptionPortSerie[i] = Serial.read();
          if (receptionPortSerie[i] == &#039;\r&#039; || receptionPortSerie[i] == &#039;\n&#039; ) {
            break;
          }
        }
        // *********************************************************************
        // **** Envoie des données du port Série sur le module Bluetooth **
        if (writeBleUART(receptionPortSerie))
        {
          Serial.print(&quot;Longueur envoyées: &quot;);
          Serial.println(strlen(receptionPortSerie));
          Serial.print(&quot;Données envoyées: &quot;);
          Serial.println(receptionPortSerie);
        } else {
          Serial.print(&quot;Une erreur s&#039;est produite pour l&#039;envoie des données&quot;);
        }
        // *********************************************************************
      }

      //***********************************************************************
      //**** Lecture des données du module Bluetooth **************************
      ret = readBleUART();
      if (ret == -1) {                     // si retour = 0
        Serial.println(&quot;Une erreur s&#039;est produite!&quot;);
      }
      //*************************************************
      // ******* Votre code personnel ici ***************
      //*************************************************

 RemoteXY_Handler (); 

  // TODO you loop code 
  // use the RemoteXY structure for data transfer 

  int ms = RemoteXY.slider_1*20+500; 
  myservo.writeMicroseconds(ms);
      
    }

    Serial.print(&quot;Déconnecté du central: &quot;);
    Serial.println(central.address());
    Serial.println(&quot;&quot;);
    etat = 0;
  }
}


int writeBleUART(char text[]) {
  if (TX_RX.writeValue(text, strlen(text))) {
    Serial.print(&quot;Size: &quot;);
    Serial.println(strlen(text));
    Serial.print(&quot;  Données envoyées: &quot;);
    Serial.println(text);
    return 1;
  }
  return 0;
}

int readBleUART(void) {
  int ret = 0, lenData = 0;

  if (TX_RX.written()) {
    lenData = TX_RX.valueLength();
    if (lenData) {
      memset(receiveBluetooth, 0, tamponBluetooth);
      ret = TX_RX.readValue(receiveBluetooth, lenData);
      if (ret != lenData) {
        return -1;
      }
    }
  }
  return ret;
}</code></pre></div><p>Lot of thanks !</p>]]></content>
			<author>
				<name><![CDATA[Mdawaite]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1796</uri>
			</author>
			<updated>2021-03-28T09:04:48Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=3755#p3755</id>
		</entry>
</feed>
