Arduino UNO + ESP8266 through the cloud server

Connecting through a cloud server RemoteXY allows you to manage the device from anywhere in the world where there is Internet.

The ESP8266 module will be configured as a client to connect to a WiFi access point. The access point must have an Internet connection. The RemoteXY library will ensure registration of the device on the cloud server.

The mobile application will connect to the cloud server, and not to the device directly. Thus, the device will be available from anywhere on the Internet.

Notice. At this tome, the connection through the cloud server passes the testing phase. This may result in server outages.

Step 1. Create a graphical user interface project

Enter the RemoteXY editor. Set one button in the smartphone field. Highlight this button, then select the "Snap to pin" property to 13 (LED) value in the right pane of the "Element" tab.


Step 2. Configure the project

In the right pane, select the following settings under the "Configuration" tab.


In the right pane, set the following settings under the "Module interface" tab.


The settings indicate that the ESP8266 connects to the Arduino via the hardware Serial (contacts 0 and 1) at 115200 speed.

In the settings, also specify the name and password of your access point, to which the module is to be connected. The access point must have an Internet connection.

Step 3. Create a device token

Press the button "My tokens". To register the device token, registration on the site is required.


Notice. Each device that is registered on the RemoteXY cloud server, must have a unique registered token. To connect to the device from a mobile application, you must also specify this token. Tokens are created in the personal cabinet of the RemoteXY site.

On the list of your tokens, press the "Create new token" button. In the window that opens, specify the name of the device for which the token is created, and select one of the available cloud servers. Then press the "Create" button.

A new token should appear in the list of tokens.


Notice. In the list of device tokens in your account, you can monitor the status of your device in the "Device Status"column. The status can be one of the three following:

  • disconnected - which means the device is not connected to the cloud server;
  • connected - which means the device has been registered on the cloud server and is ready to connect from the mobile application;
  • used - which means the fact that the device is used by the mobile application;
  • ? - which means the fact that the cloud server is not available.

Return to the editor and select your newly generated token in the "Token" field.

Step 4. Get the sketch for the Arduino

Press the “Get source code” button.

In the opened page with the source code of the sketch, download it to your computer (the link "Download code") and open it in the Arduino IDE.

Also, download the library RemoteXY (link "Download Library") from this page. The library being installed correctly, the source code for the sketch must be compiled without errors.

More information on installing the RemoteXY library for the Arduino IDE

Step 5. Configure the ESP8266

The ESP8266 module needs to be set up. Your module might already have the necessary default settings, but it is recommended to check it.

You need to check the following:

  • The module has a firmware supporting AT commands version no lower than v0.40;
  • The module is configured for a speed of 115200.

More information on configuring the ESP8266 to work with RemoteXY

Step 6. Connect the ESP8266 to the Arduino Uno

Connect the ESP8266 to the Arduino Uno according to the diagram below. Note that the RX-TX contacts are connected by a crosswire.

Since the signal levels of the ESP8266 module are 3.3V and in the Arduino they are 5V, it is necessary to use a resistive voltage divider to convert the signal level.


Step 7. Download the sketch in the Arduino

The sketch is loaded into the Arduino in the normal way. However, programming is not possible because the ESP8266 module is connected to terminals 0 and 1. The compiler will show an error.

Before programming, disconnect the wires going to the ESP8266 from pins 0 and 1. Fulfill programming. Then place the contacts back. Press the Arduino reset button.

Notice. Flickering of the blue LED on the ESP8266 module immediately after the reset is regarded to be the first sign confirming the fact that the programming was successful. The blinking of the blue LED means the data exchange between the Arduino and the ESP8266. In these half-seconds, the Arduino configures the ESP8266 to connect to the access point. After a while, the LED will blink again, which means its trying to be registered at the cloud-based RemoteXY server.

Step 8. Connect from the mobile application

Install theRemoteXY mobile application on your smartphone/tablet.

In the application, press the new connection button, select the "Cloud server" connection. In the window that opens, enter the device token that was registered in the previous step. Also, check that the cloud server URL and the connection port are correct.

Click the "Connect" button.


If there is no connection...

Check the connection of your device to the cloud server

Go to the list of tokens in the personal cabinet of the RemoteXY site. In the list of tokens, find the value in the "Device Status" column. If the device is connected to the cloud server, the value must be "Connected". Try refreshing the page.

It might take up to one minute to connect to a cloud server after starting the device.

If the device is connected to a cloud server but the mobile application does not connect, check if the token in the mobile application is correct.

If the device does not connect to the cloud server, the error is to be searched in the device itself or its settings.

Notice. If the mobile application fails to connect to the cloud server, a dialog box with a description of the error is displayed. The main errors are as follows:
  • The token is not registered on the server - which most likely means you specified the token incorrectly.
  • The device is not connected to the server - for some reason the device does not connect, there may be an error in the device configuration settings.

Check for the availability of a properly loaded program

Open the Serial Monitor and set the speed to 115200. Press the reset button on the Arduino board.

If there are no messages after the Arduino reset in the Serial Monitor, this probably means that the Arduino will not execute your program. Possibly:

  • the needed sketch was not downloaded;
  • your Arduino is not on;
  • the Serial Monitor is not connected to the Arduino;
  • there is something wrong with your Arduino.

Check the connection between the Arduino and the ESP8266

If after the Arduino reset in the Serial Monitor you see the following sequence of commands, this means that the ESP8266 initialization is successful and there is a connection between the Arduino and the ESP8266, the device has been registered on the server.


AT
AT+RST
ATE0
AT+CWMODE=1
AT+CWQAP
AT+CWDHCP=1,1
AT+CWJAP="MySSID","MyPassword"
AT+CIPMODE=0
AT+CIPMUX=1
AT+CIPSTART=0,"TCP","cloud.remotexy.com",6376
AT+CIPSEND=0,44
UxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxAT+CIPSEND=0,6
Uxxxxxx 

If you only see repeating "AT" commands, this means that there is no connection between the Arduino and the ESP8266.


AT 
AT 
AT 
AT 

There might be several reasons for the connection error. The main ones are listed below:

  • RX and TX contacts are not connected correctly, the contacts are reversed, or not connected to the right contacts, or not connected at all;
  • there is no power supply to the ESP8266, when the power is supplied to the ESP8266, the red LED must be lit;
  • there is not enough 3.3 V power supply for the ESP8266;
  • the ESP8266 module is defective.

Check if the ESP8266 is connected to the access point

If after the Arduino reset in the Serial Monitor you see a sequence of commands, but the last command is AT+CWJAP and then nothing happens, it means that the module can not be registered in your WiFi network with the specified SSID and password:


AT
AT+RST
ATE0
AT+CWMODE=1
AT+CWQAP
AT+CWDHCP=1,1AT+CWJAP="MySSID","MyPassword"

Check if the ESP8266 is connected to the cloud server

If after the Arduino reset in the Serial Monitor you see a sequence of commands, but the last command you see is AT+CIPSTART and then it repeats periodically about once a minute, it means that the cloud server is not available. The URL of the server or the port may be incorrect. Possibly your WiFi access point is not connected to the Internet.


AT
AT+RST
ATE0
AT+CWMODE=1
AT+CWQAP
AT+CWDHCP=1,1
AT+CWJAP="MySSID","MyPassword"
AT+CIPMODE=0
AT+CIPMUX=1
AT+CIPSTART=0,"TCP","cloud.remotexy.com",6376
AT+CIPSTART=0,"TCP","cloud.remotexy.com",6376
AT+CIPSTART=0,"TCP","cloud.remotexy.com",6376

If two AT+CIPSTART and AT+CIPSEND commands are repeated at least once a minute, this means that the server is available, but the token was rejected by the server as an unregistered one.


...
AT+CIPSTART=0,"TCP","cloud.remotexy.com",6376
AT+CIPSEND=0,44 
AT+CIPSTART=0,"TCP","cloud.remotexy.com",6376
AT+CIPSEND=0,44 
AT+CIPSTART=0,"TCP","cloud.remotexy.com",6376
AT+CIPSEND=0,44 

Check the ESP8266 firmware

If, after resetting the Arduino to the Serial Monitor, you see only the beginning of the command sequence, it could also mean that the ESP8266 module has an obsolete firmware. Firmware upgrade is required.

More information on updating the ESP8266 firmware.

Check the power supply for the ESP8266

It is possible that your ESP8266 does not have enough power supply. Some Arduino cards have a weak 3.3V voltage regulator, which is not capable of delivering 200-300mA in peak modes. In this case, you will also see a break in the command sequence in the Serial Monitor. It is possible that the power connection cables are too long or too thin.