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