Connections

The communication between the WiFi module and your microcontroller is performed by means of a standard asynchronous serial protocol. Almost all microcontrollers are equipped with at least one Universal Asynchronous Receiver Transmitter interface (UART), thus, the establishment of the communication is usually straightforward.

The serial protocol

The serial protocol is asynchronous and the bus consists of just three wires, the receiver line, RX, the transmitter line, TX, and the reference GND, as depicted in the following picture:

The serial protocol is usually configurable, thus, it is important to make sure that both devices on the serial bus are configured to use the exact same settings. In particular, to communicate with WiFi module the micro-controller’s UART has to be set as follow:

  • Data bits: 8
  • Stop bits: 1
  • Parity bits: 0
  • Baud rate: 57600
  • Flux control: None

The default baud rate of the Wi-Fi module is 57600 baud, but it can be changed both from APP or through a serial command.

Logical Levels and Power Supply

Depending on the employed WiFi module, the power supply, and the electrical voltage on the bus, must be as follow:

  • ESP-01 without adapter: 3.3 V
  • ESP-01 with adapter ADP-01: 5 V

Please note that the power supply must be able to provide at least 300 mA

Getting started with the module

When you receive the WiFi module, you have to activate the product and enable your mobile phone to talk with the module. When the module is powered-up for the first time, the µPanel firmware will run and create a WiFi access point whose name is miuPanel. This access point represents the primary method for setting-up your module. In order to proceed with the following instructions you will have to install and launch the µPanel App on your mobile device.

The screen reported in the following picture should appear, indicating that you are ready to add your new module!

First of all, enable the WiFi of your mobile device and select the miuPanel from the list. Since the WiFi connection is protected, you will be asked for the password. The initial module’s password is uPanel11 (please note that the P is upper case). When connected, press on the Add New Module button. You will see the following message confirming that the App is actually trying to connect to your module

After a while your module should appear in your device’s screen as shown by the following picture. The header of the new product box shows the serial number that identifies your product. If you wish, you can assign a user friendly name to your module simply by clicking on its serial number and entering the name you like.

You are just a step away from your Panel! To activate your module, make sure your mobile device is actually connected to the Internet (disconnect your device from the miuPanel WiFi and connect to another WiFi or mobile data network which give an internet access) and click on your product box. The following message will appear:

In a while you should see your product with the message “click to connect“, as shown in the following picture, indicating that your product has been correctly registered and activated. In the bottom part of your product box the App also shows both the module local and public IP. You can find more information about these IP in the Router and Module configuration sections. Now press on your product box to connect to your module! (Remember that since you have not yet enabled the WiFi module to connect to any router, before press on “click to connect” you have to connect your mobile device directly to the miuPanel WiFi).

NOTE: if the app shows the message “your product can not be regitered!” this simply means that your miupanel vendor has not yet activated the module registration after the sales, so the registration fail. Usually the vendor activates the registration of your wi-fi module whithin 24 hours the sale. In this case, you can contact your vendor to request the activation.

You should obtain the screen reported in the following picture that shows the module has replied indicating that there is not yet a panel to show you. Congratulations! You are now ready to start with your µPanel!

Please note that the first LED (on the left) in the tool bar will stay steady ON, indicating that your mobile device is connected and communicating with the module. The second LED (on the right), instead will flash only when data and commands are successfully transmitted from your mobile device to your module.

Please go to the next section to know how to configure your module

Configure the module

The module can be configured using either the graphical interface on your mobile device or the module serial port. In this section we will present the former method. By clicking on the menu button, located on the right side of the tool bar, the following menu will appear.

The first menu item (Configure Module) allows you to access the page with the module configuration:

The presented form includes the following basic fields:

  • AP SSID: this field represents the name of the Access Point created by the module. Enter a new name if you wish to use another Access Point name
  • AP PWD: this is the password of the module Access Point. It is strongly recommended to change the initial password. Please note that the minimum allowed password length is 8 characters. If you leave this field empty, an open Access Point will be created
  • AP CH: this is the radio channel used by the Access Point. Despite this parameter is reported in the form, in most of the cases, you won’t be able to change this parameter while the WiFi is in use. It is therefore recommended to change this parameter through the Serial Interface
  • Conn. to SSID: this parameter indicates the name of the local existing WiFi that can be used to connect to Internet. This is usually your Home WiFi network name. Please note that, it is not required that this network is actually connected to the Internet, but it can just connects your local devices
  • Conn PWD: this field contains the password for connecting to your WiFi
  • Enable Connection: if this box is checked the module will actually connect to your WiFi network. Leave this box unchecked if you don’t wont to connect the module to Internet.

Please Note that, if you enable the connection to a WiFi network but the network can not be joined, the direct communication with the module through its WiFi access point will result intermittent. Therefore, it is strongly recommended disabling the Connection to a WiFi network if such a connection can not be established.

In order to be able to communicate with your module from the Internet (i.e. from everywhere in the world) you have to configure your router to allow incoming TCP connections to reach the module port 80 and 81. The µPanel firmware is able to automatically configure most of the routers so that they will accept and forward these incoming connections. The currently supported protocols are the NAT-PMP and UPnP. The former is adopted by Apple products, the latter by many home routers. The following three entries of the configuration module permit to set and enable the router auto-configurator function:

  • Router Port 1: this field allows you to select a free router public port. The router will be configured to forward incoming TCP connections from this port to the module port 80
  • Router Port 2: as above, the router will be configured to forward incoming TCP connections from this port to the module port 81
  • Enable Router Conf.: checking this box the router auto-configuration function will be actually activated. Please note that if you activate this function, the module may require about 1 minute to successfully connect to Internet after start-up

When you want to connect to your module through the Internet but your app does not know the public IP address of your router, you can use the IP discovery mechanism based on our cloud server, which is accessible with the button “locate in cloud” in the product folder. Please note that, the module checks for its public IP every 15 minutes and, if necessary, communicates it to our server. This means that if your router changes IP (for instance, due to a router reboot or ADSL problems), you need to wait up to 15 minutes to be able to reconnect to your module again.

The last module entries permit to configure and access the following features:

  • Serial Baud: this parameter permits to change the Serial Line speed. The default value is 57600 baud, but other standard values can be set, such as 115200 baud, for faster communication
  • AT-Firmware: the module will be shipped with actually two firmwares onboard: the µPanel and the legacy AT. This menu line shows you if the firmware is actually revertible to AT. If you click on Revert to AT the module will switch firmware and will reboot with the AT interpreter. If you revert to AT, the only way to return back to the µPanel firmware is to issue an AT+PANEL command on the serial line (at 115200 baud). More details about the AT reverting procedure can be found in its specific section
  • µPanel Ver.: this line shows the firmware version currently running on the module. Clicking on the upgrade button you can upgrade the firmware. The upgrade functions require internet connection. More details about the firmware upgrade can be found in the specific section

Some of the above discussed parameters and functions might be protected and locked by a controller connected to the serial port. Please refer to the serial section to know more about the protected commands.

How to run your first panel

The following step-by-step instructions will guide you through the creation of a simple panel containing a LED indicator.

Step 1 – Connect the WiFi module to your microcontroller UART as follow (see Module Oveview and its Serial Interface for details):

Step 2 – Configure the microcontroller UART to work asynchronously at 57600 baud, 8 data bit, 1 stop bit, parity none, flux control none.

Step 3 – Insert a delay of at least 3 s at start-up to let the WiFi module boot

Step 4 – Discharge any previous message by sending to the WiFi module a return carriage (\n or ascii code 10)

Step 5 – Define the panel by sending the following HCTML message to the WiFi module: $P:L1G:0:Test Led;

Step 6 – Turn the LED on by sending the following HCTML message to the WiFi module: #L11

Connect the APP to the module during any of the previous steps to see the result.

The following sections provide the details about the Panel Design and the supported Serial Commands.

You can also find the sketch of this example written for Arduino Uno in the Basic Example section