May 17, 2015

HLK-RM04 Wifi Module Setup


HLK-RM04 is one of those cheap Wifi <-> UART modules which started to appear in the market. This kind of module basically abstracts all the TCP/IP and Wifi stuff, enabling use it as an easy web socket to/from serial port solution. Here you can see how to use it.

In brief, send bytes through the module TX pin and receive them in the socket client, then the socket client sends data back and receive them in the UART RX pin. The pins that matters are listed below:

pin 1 - 5 V In, module power supply 
pin 2 - 0V / GND 
pin 4 - 3.3 V Out
*pin 10 - ES/RST, keep with 3.3v (you can connect to pin 4)
pin 20 - UART RX, used to receive AT commands too
pin 21 - UART TX, used to send AT commands too

* Put 0v between 100 ms and 6000 ms to reset the factory settings

Now connect the module to your PC USB (you can use any USB <-> Serial cable), open the manufacturer configuration software, connect to the COM port and you will be able to configure it:


The module supports two wifi modes: client, that connects to an existing Access Point (AP), like your home/internet AP or Android HotSpot, and server, which creates an AP, with the chosen name (SSID) and password (Key). 

Although this is the configuration software, it's just an interface that sends (under the hood) AT commands to the module, which is how you can program your wifi module using a microcontroller in some real application, because of course, you will not be able to use this software!

The AT commands are all in the module datasheet, the default serial connection baud rate is 115200 8N1. For example, this command will get the current module's IP:

at+remoteip=?

Now the trick part, you MUST send in the end a carrier return (\r) and line feed (\n) ASCII commands, they are not ASCII visible, so configure your serial terminal software to send them. I like to use the "HTerm" terminal software for Windows, and this is how you can configure it:


Ok, now you know how to configure it by the Windows interface and AT commands, get the module IP and access it using your browser, then go to the Serial2Net settings page:


Here let's create a TCP/IP <-> UART server in the wifi module, just configure it like the fields in the above image, but pay attention, here is another trick! the web page has a bug, so to unlock the IP field select "Client" first, then "Server". 

Now the module is ready! just use any TCP/IP socket client like netcat for Linux users or putty for Windows, connect to the module address, send/receive data and look them in the terminal software  being received by the UART, then do the opposite way, send through the terminal software and look in the client software!

Resources:

6 comments :

  1. Can HLK RM04 WiFi module detect and get signal strength of other routers in its vicinity?

    ReplyDelete
    Replies
    1. you need check its datasheet, I got one of the firsts modules, so the firmware now may have more features, like this

      Delete
  2. I had done what you said above! but after changing the settings my device wifi network gets automatically off and i,m unable to connect. Again I can connect only after device reset. Please help out



    Thanks/Regards

    Trilok

    ReplyDelete
    Replies
    1. Hello Trilok, unfortunately I don't have the module anymore, but I got one of the firsts, so maybe now the configurations and/or firmware have changed, try to find a newer tutorial or read the newer datasheet version. Good luck!

      Delete
  3. Thanks for the post - saved me from never ending issues with module and rightly pointed me to software bugs and way ahead. Observed in my case that if you do not have 2 or more wifi networks in close range, after scanning network, the web page simply does nothing after clicking apply button - I started my mobile's WIFI-hotspot and then it worked (i.e. selecting and applying my home wifi network) just fine.

    ReplyDelete