mercoledì 25 ottobre 2017

Remote Control a nodeMCU with RemoteXY - Led Control









In this post I describe a simple and intuitive way to remotely control a nodeMCU through a mobile application from iOS and Android devices.

More in detail I will show how to remotely pilot a led through the  RemoteXY application


RemoteXY

RemoteXY includes: 

  • a Web application to easily design and build a graphical interface and to generate the necessary source code for the controlling board (ESP8266, Arduino, ...)
  • a Mobile app for iOS and Android to remotely control over Bluetooth or WiFi the remote board


In order to create a complete application with RemoteXY it is necessary to follow 4 simple steps::

Step #1 : Graphical Interface

Building a graphical interface with a simple drag&drop editor available here








Step #2: Source Code Configuration

Configure and generate the sketch source code to be uploaded on the control board  (ESP8266, Arduino)




Step #3: Upload Sketch

Compile and upload of the generated sketch on the control board (ESP8266,Arduino) through the Arduino IDE (or other supported IDE)

Step #4: Download Mobile App

Download the mobile app and install it on your client device (iOS, Android)














Configuration

After the design of the graphical interface it is necessary to configure the tool in order to generate the proper source code.





There are 4 different aspects to configure:

  • Connection
Four (4) type of connections are supported


Note: the iOS app only supports Bluetooth Low Energy aka BLE

  • Device (the control board)

The following platforms are supported


  • Communication Module
The following communication modules, to be paired with the control board, are supported:



Here some example of supported scenarios: Arduino Uno with Bluetooth HC-05 module, Arduino with ESP8266 or  nodeMCU with ESP8266


  • IDE environment
Three (3) different development environment are supported:








LED control with nodeMCU

Let's now implement a simple use case: remotely control a LED through a mobile app and nodeMCU


GUI

Use the online editor to design a simple user interface by adding a label and a switch as depicted below






Now selecting the switch (ON/OFF) it is possible to configure some simple parameters in the  Element section



For the sake of simplicity let's stick to the default parameters


Configuration

Now let's configure the code generator in the following way






This way we are telling to RemoteXY that we want to use a nodeMCU board as controller and the on-board ESP8266 as communication module and that our programming environment is Arduino.

The Connection is set to WiFi Access Point (AP) hence we are telling to RemoteXY that we want our nodeMCU to behave as a WiFi Access Point.


In such case it is necessary to configure the Module Interface section by specifying the SSID which will be broadcasted by the nodeMCU AP.

Let's also specify the TCP port on which the nodeMCU server will be listening for incoming connections.


Again for sake of simplicity let's check Open point meaning that we want an open WiFi network with no authentication.







Source Code

Now press the following button




RemoteXY will redirect us to a new page in which the generated source code is available for the user.
The source code and the RemoteXY library are available for download as zip files.





Let's now download the RemoteXY library and install it on Arduino IDE through the proper menu.
The download the source code






As we can see in the generated code some information from the previous config phase are present:
  • SSID of AP WiFI
  • Listening port

The RemoteXY_CONF[] section contains a description of the graphic interface. It will be transfer to the requesting mobile app once a connection with the nodeMCU is established.



Circuits

Now let's build the simple circuit depicted below by connecting a LED on the D4 pin of nodeMCU. Let's not forget the 100-220 Ohm limiting resistor.






Testing

Now let's compile the code and upload the binary to nodeMCU through the Arduino IDE.






Now on your mobile device (smartphone o tablet) join the new WiFi network called LedWiFi





It is now time to run the RemoteXY app on mobile and then click on the top tight + sign






Now select the WiFi point option










Now press the Connect button and the app will connect to the nodeMCU and it will download the GUI description







Now you are all set to remotely control the LED wired to the nodeMCU control board















Controllo Remoto di NodeMCU con RemoteXY - Accensione Led










In questo post descrivo un modo semplice ed intuitivo per controllare un nodeMCU da un applicazione mobile per iOS ed Android.

In dettaglio faccio vedere come pilotare un led da remoto tramite l'applicazione RemoteXY


RemoteXY

RemoteXY e' composto da

  • un applicazione Web che permette di disegnare un interfaccia grafica e di generare il codice da far girare sulla scheda di controllo (ESP8266, Arduino, ...)
  • un applicazione mobile per iOS e Android che permette di controllare da remoto tramite bluetooth, wifi la scheda di controllo


Per creare un'applicazione completa con RemoteXY bisogna eseguire 4 semplici passi:

Passo #1 : Interfaccia Grafica

Disegnare l'interfaccia grafica con una comodo editor drag&drop disponibile qui







Passo #2: Configurazione Codice Sorgente

Configurare e generare il codice sorgente da caricare sul modulo di controllo (ESP8266, Arduino)




Passo #3: Upload Sketch

Compilare e caricare il codice sulla scheda di controllo (ESP8266,Arduino) tramite l'IDE Arduino (o tramite gli altri IDE supportati)

Passo #4: Download App mobile

Scaricare l'applicazione mobile ed installarla sul dispositivo client (iOS, Android)














Configurazione

Dopo aver disegnato l'interfaccia grafica della propria applicazione e' necessario configurare il tool per generare il codice in maniera corretta




Ci sono 4 aspetti da configurare:

  • La Connessione (Connection)
Sono supportate 4 tipi diversi di connessioni

Nota: l'applicazione per iOS supporta solo Bluetooth a bassa energia (BLE)

  • Il Device (la scheda di controllo)

Sono supportate le seguenti piattaforme


  • Il Modulo di Comunicazione usato
Sono supportati i seguenti moduli di comunicazione da accoppiare con le piattaforme supportate


Quindi per esempio e' supportato Arduino Uno con Bluetooth HC-05, oppure Arduino con ESP8266, oppure nodeMCU con ESP8266


  • L'IDE che si utilizza
Sono supportati 3 diversi ambienti di sviluppo







Accensione LED con nodeMCU

Vediamo ora un semplice esempio di come controllare lo stato di un LED tramite una semplice applicazione mobile e nodeMCU

GUI

Disegniamo tramite l'editor online una semplicissima interfaccia con una label e con uno switch





Ora cliccando sullo switch (ON/OFF) e' possibile configurare alcuni semplici parametri ad esso correlati nella sezione Element



Per semplicita' lasciamo i valori di default che vanno benissimo

Configurazione

Configuriamo il codice nel seguente modo






In questo modo stiamo dicendo a RemoteXY che vogliamo usare una scheda nodeMCU con ESP8266 per controllare il nostro led e che la vogliamo programmare con l'IDE Arduino. 

La connessione e' di tipi Wi-Fi access point e quindi stiamo dicendo a RemoteXY che vogliamo che il nostro nodeMCU si comporti come un WiFi Access Point

Quindi e' necessario anche configurare la sezione Module Interface inserendo lo SSID  della rete WiFi che verra' implementata da nodeMCU

Specifichiamo anche la porta su cui il nostro server,1 che gira su nodeMCU, rimarra' in ascolto.

Infine per semplicita' impostiamo il tutto come un Open point cioe' senza autenticazione e senza password







Codice

Premendo ora il pulsante




siamo rediretti ad una pagina in cui e' visualizzato il codice per nodeMCU e dove e' possibile scaricare il codice come file zip e anche la libreria RemoteXY in formato zip





A questo punto scarichiamo la libreria ed installiamola nell'IDE Arduino tramite l'apposito menu'.
Poi scarichiamo il codice




Come possiamo vedere nel codice generato ci sono le informazioni che abbiamo inserito in fase di configurazione:
  • SSID del AP WiFI
  • Porta del server

La sezione RemoteXY_CONF[] contiene una descrizione dell'interfaccia grafica che verra' inviata all'applicazione mobile una volta stabilita la connessione tra device mobile ed il nodeMCU



Circuito

Ora creiamo il semplicissimo circuito andando ad connettere un LED sul pin D4 del nodeMCU tramite una resistenza da 100-220 Ohm





Test

Ora compiliamo e carichiamo lo sketch sul nodeMCU tramite l'IDE Arduino





Ora tramite il vostro dispositivo mobile (smartphone o tablet) collegatevi alla nuova rete WiFi chiamata LedWiFi




A questo punto lanciate l'app RemoteXY e cliccate sul segno + in alto a destra. 





Poi selezionate l'opzione WiFi point










Ora premete su Connect e l'applicazione si connettera' al vostro nodeMCU e scarichera' la definizione dell'interfaccia







Ora potete pilotare il led dal vostro telefono/tablet