MangoCube, HF-LPxx00, USR-WIFI232 How-to


This topic documents the procedure I followed to get a MangoCube WiFi, which incorporates a HF-LPT200 or USR-WIFI232S WiFi module, working with Blynk. The procedure should also apply to other Arduino based systems using one of these modules for the Wifi link.


The Shanghai High-Flying Electronics Technology Co. HF-LPxx00 series modules, also marketed as Jinan USR IOT Technology Ltd. USR-WIFI232 series modules, are small WiFi IP to serial converters similar to the ESP8266 modules.

The Megavizon MangoCube WiFi is essentially a miniaturised Arduino Leonardo with a HF-LPT200 (or USR-WIFI232S) based WiFi board attached to the Serial1 Tx and Rx pins. The MangoCube was developed through a Kickstarter campaign. The Wifi board was also available separately as a campaign reward. I’m not sure if any Megavizon products are currently available for sale.

Bhargav Mistry, the founder of Megavizon, stated in a Kickstarter comment that he intended to support Blynk on the MangoCube. I don’t think anything became of this so I decided to look into what it would take to do it.

Additional information on the modules can be found on the manufacturers’ web sites.


The HF-LPxx00 modules are similar to the ESP8266 in that they are configured and controlled using AT commands. However, the commands themselves are quite different, so ESP8266 libraries will not work.

It turns out that the module can be configured in a such way that it will automatically connect to a Wifi Access Point (AP) and open a TCP link. It will then go directly into a mode that transparently passes data, unaltered, between TCP and the serial port (called throughput mode, which the ESP8266 calls unvarnished mode).

Using this throughput mode configuration, no new libraries or module specific code is necessary to work with Blynk. After pre-configuring the module, just loading a sketch that uses the standard hardware or software serial connection code is all that’s needed. The module is first manually configured using AT commands in command mode. (This configuration is saved and retained in the module over subsequent power cycles). A sketch is then loaded to run Blynk as if connected by a serial link.

One drawback to using this technique is that whenever the WiFi connection parameters (such as SSID or passphrase), TCP parameters (such as host address or port) or other parameters need to be changed, a sketch must be loaded to allow manually changing the module settings and then the Blynk sketch must then be reloaded. An advantage is that by not needing Wifi configuration code in the Blynk sketch more code space will probably be available for user functionality.


Load a configuration sketch

If the module is in the default throughput mode it must be put into command mode so it can be configured. This is done by sending +++ then waiting for the letter a to be received then sending a letter a which is acknowledged by receiving +ok.

This could be done manually but to make it easier I wrote a sketch that will automatically try to enter command mode at either the 115200 (default) baud or 9600 baud. It will also try to determine if the module is already in command mode (it could possibly have been previously configured to come up in command mode).

If the sketch fails, the module may have been configured for a different baud rate. In this case, the sketch can be changed or extended to try different rates.

Once the module is in command mode, the sketch will echo data between the Arduino Serial1 port (the module) and the Serial port (the USB port on a Leonardo). The module can then be configured manually by entering commands from the Arduino IDE Serial Monitor (or other serial terminal program). The Serial Monitor should be configured for 9600 baud, regardless of the speed of the module, and should be set to send a carriage return as a line ending.

Here is the sketch (I know it’s not very elegant but it gets the job done):

// Put a HF-LPxx00 / USR-WIFI232 module on Serial1 into command mode
// and then echo data between Serial and Serial1

void setup() {
  // initialize serial communication
  // wait for serial port to connect.
  while (!Serial);


  delay(7000); // wait 7 seconds to allow starting serial monitor
  if (enterCommandMode()) {
    Serial.println("Switched to command mode at 9600");

  if (inCommandMode()) {
    Serial.println("Already in command mode at 9600");


  if (enterCommandMode()) {
    Serial.println("Switched to command mode at 115200");

  if (inCommandMode()) {
    Serial.println("Already in command mode at 115200");

  Serial.println("Connection failed at 9600 and 115200");

void loop() {
  // read from port 1, send to port 0
  if (Serial1.available()) {
  // read from port 0, send to port 1
  if (Serial.available()) {

boolean enterCommandMode() {
  for (byte i = 0; i < 3; i++) {
    if (Serial1.find((char *)"a")) {
      if (Serial1.find((char *)"+ok")) {
        return true;
  return false;

boolean inCommandMode() {
  for (byte i = 0; i < 3; i++) {
    if (Serial1.find((char *)"+ok")) {
      return true;
  return false;

void flushRead() {
  while (Serial1.available()) {;

Configure the module

With the module I used to develop this procedure, at+ver reported V1.0.05 and at+lver reported 21 (2014-11-08 13:29 8B)

With the configuration sketch loaded and the Arduino IDE running on a PC, plug the Arduino into a USB port to power it up. Open the IDE Serial Monitor. Wait about 10 seconds for a message indicating success.

The following at+ commands are the ones required to configure for Blynk use. Most of the commands can be used to display their current setting by just entering the command without the = character or anything following it. Commands are case insensitive but some parameters (such as a passphrase) may be case sensitive.

Angle brackets are not entered or received. They indicate a variable value.

If you get a +ERR= error code, their meanings are:
-1 Invalid command format
-2 Invalid command
-3 Invalid operation symbol
-4 Invalid parameter
-5 Operation not permitted

I decided to run the module serial connection at 9600 baud, which seems to work fine. Other baud rates would likely also work, if desired.

Set UART to 9600 baud, 8 bit, no parity, no flow control.

Disable UART packet framing mode.

Set UART packet forwarding timing to normal.

Set for “throughput” (passthrough) mode on power up.

Set WiFi “station” (client) mode.

Set the SSID of the wireless router or access point.
Use the actual SSID in place of <ssid>.

Set the Wifi key or passphrase.
<auth>: open, shared (for WEP), wpapsk, wpa2psk.
    none (for open),
    wep-h (WEP key in hex), wep-a (WEP key in ASCII),
    tkip, aes.
E.g. at+wskey=wpa2psk,aes,This is my WiFi passphrase

Set the IP address configuration.
IPv4 addresses are in the form: x.x.x.x E.g.

If using a static IP address or if DHCP doesn’t provide a
Domain Name Server (DNS) address, set it.
<dns> format is: x.x.x.x

If you want to change the hostname (module id) used for DHCP.
(Use at+mid to query the name.)

If you want to reduce the transmitter power.
<pwr>: 0 to 24 (0.5dBm steps. 0 = 16dBm maximum, 24 = 4dBm minimum)

Disable switching to AP mode if the WiFi connection fails and
set the check interval from the default 10 minutes to 5 minutes.

Set the network parameters to connect to the Blynk server.
If using a local server or gateway, adjust the port and address to match.
The address can also be a x.x.x.x IPv4 address.

Reduce the TCP “no data” timeout from the default 5 minutes to 2 minutes.
Value is in seconds.

Disable socket B. It’s not used.

Disable the Network Time Protocol (NTP) client.

Verify the connection

Before loading the Blynk sketch, the connection can be verified using the following commands. The Serial Monitor should be closed, then the Arduino and module should be powered off and on and then re-connected to the Serial Monitor, to make sure automatic connection is working. The sketch should display Switched to command mode … not Already in command mode … indicating that the module came up in throughput mode.

If attempting to diagnose and fix connection problems, the command
at+wifi=down followed by at+wifi=up
can be used after changing values, instead of cycling power and restarting the Serial Monitor.

WiFi link status.
<AP’s SSID>(<AP’s MAC address>) - if link establised
Disconnected - if no link

Wifi link quality (receive signal strength).
<quality>, <signal strength> - if link established
Disconnected - if no link

TCP connection status.
on - if TCP connection established
off - if TCP not connected

Ping an IP location.
at+ping=<IP address or domain name>
Success - if ping response received
Timeout - if no reply
Unknown host - if DNS lookup failed

Get local MAC address for STA mode
<MAC address> - in hexadecimal without colons

Load a Blynk sketch

Once the module is automatically connecting in throughput mode, this is a basic skeleton sketch that can be loaded to work with Blynk.

 * Blynk basic hardware serial for
 * Megavizon MangoCube WiFi or other Arduino using:
 * High-Flying Electronics HF-LPxx00
 * Usr IOT USR-WIFI232

//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <BlynkApiArduino.h>
#include <Adapters/BlynkSerial.h>

typedef BlynkTransportSerial<HardwareSerial> ArduinoHwSerial;

static ArduinoHwSerial _blynkTransport(Serial1);
BlynkSerial<ArduinoHwSerial> Blynk(_blynkTransport);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

void setup() {
  Blynk.begin(auth, 9600);

void loop() {;

As usual, connecting the Serial Monitor will print some connection information. Uncommenting the //#define BLYNK_DEBUG statement will print lots of diagnostic information.


Wow, that’s a comprehensive post. Thanks for a great job. :clap:

We might need to contact Mango Cube creators and add their stuff to Blynk.

@vshymanskyy could you please lead here and contact them.

I pieced together the above sketch, to run Blynk on an Arduino hardware Serial1 port, using the library’s BoardsAndShields examples, without fully investigating or understanding what the functions do.

Would an expert please answer: Is my code doing it correctly or is there a more proper or better way to implement hardware serial? (It seems work OK.)

Hi, I have a troubleshooting when I try to upload the code to my Nano board. I need special libraries for upload the sketch? The error is on the line of “typedef BlynkTransportSerial ArduinoHwSerial;”. I hope you can help me, and sorry for my english, it is not my first language.

Libraries have changed since the last post in May 2016. Read the docs and look at Sketch Builder.