Wifimcu Based On Emw3165 User Manual
Wifimcu Based On Emw3165 User Manual
Table of Contents
1. Introduction
2. Basic Application
i. Quickly Start with WiFiMCU STUDIO
ii. Use SecureCRT (Optional)
3. Adavanced Application
i. Flash LED -use TIMER module
ii. Breathing LED -use PWM module
iii. Socket programming –use Net module
iv. WiFi to Serial transparent transmission
v. Update Firmware
vi. Use SecureCRT to update firmware
vii. Use SWD to update firmware
4. Helpful Links
2
WiFiMCU Based on EMW3165 - User Manual
Introduction
This tutorial shows how to operate WiFiMCU dev board.
Introduction 3
WiFiMCU Based on EMW3165 - User Manual
Preparation
WiFiMCU uses CP2102 to converter USB data to UART TTL data. The USB to UART Bridge Virtual COM Port drivers are
required for device operation. The latest driver can be found at:
http://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx
The following instructions are made in Windows 7 OS. STEP 1 Install the USB Bridge VCP drivers. According to your
Windows OS, choose “CP210xVCPInstaller_x86.exe” for 32 bit OS or “CP210xVCPInstaller_x64.exe” for 64 bit OS.
Basic Application 4
WiFiMCU Based on EMW3165 - User Manual
Power up WiFiMCU with a Micro USB Cable. Go to “Start Memu”-> “Control Pannel”->”Device Manager”
If the Serial COM Port in “Ports(COM&LPT)” is shown as below, it means you have installed the driver successfully.
Otherwise, change a Micro USB cable or a WiFiMCU to retry.
Basic Application 5
WiFiMCU Based on EMW3165 - User Manual
After install the USB to UART Bridge VCP driver. You can use WiFiMCU STUDIO to test WiFiMCU simplily and quickly.
Here are the instructions to quickly start with WiFiMCU.
1 Prepare
WiFiMCU STUDIO is an open source develop tool for WiFiMCU. The latest executable program can be downloaded at:
https://github.com/SmartArduino/WiFiMCU-STUDIO/releases
https://github.com/SmartArduino/WiFiMCU-STUDIO
2 Power Up
Power up the WiFiMCU with a Micro USB Cable.
Press “Boot” button while power up or press “Reset” button to enter into bootloader mode.
Make sure choose the right serial port of WiFiMCU, then click “Open” to open the serial com port. The default serial com
parameters for WiFiMCU is 115200bps, 8 data bits, none check, one stop bit.
You can type a command in the right black textbox just like what your do in other serial tools such as “SecureCR”, “PuTTY”.
Type ”mcu.reboot()” in the command textbox and press enter, The commands are go into the Lua interpreter, and executed.
The results will be shown in the textbox.
You can also just click “Reboot” button to do the same thing. Other common commands:
“=mcu.tick()”, get the current time tick of the MCU (ms) since startup.
All the commands for WiFiMCU can be found in the reference book:
https://github.com/SmartArduino/WiFiMCU/tree/master/Document/
STEP2, Choose GPIO Pin “17 adc/led” in “GPIO” groupbox. Then choose “gpio.OUTPUT” in mode combox list.
STEP 3, click “Set mode”, command string “gpio.mode(17,gpio.OUTPUT)” will be sent to WiFiMCU and executed. The LED
on WiFiMCU board will be lighted on or off after you click“Toggle” button.
You can test the other gpio functions such as input/ interrup / pwm/ adc in the “Command” tabpage.
6 Start AP mode
The WiFi interface of WiFiMCU could work in either Access Point(AP), Station(STA), or AP+STA mode. The instructions
below will setup a WiFi interface in AP mode for example.
STEP 2, Choose “AP”, fill the SSID and PSW textbox. It will be “WiFiMCU_Wireless” for SSID and empty for PSW in
default. Click “Set” to send the command string.
STEP 4, You can connected to the Open sercurity WiFi. The default IP for WiFiMCU is “11.11.11.1”. The IP could be
customized, check WiFiMCU Reference Book for more details.
STEP 0, Make sure the WiFiMCU is running in AP mode or STA mode or AP+STA mode, if you are strange for this, follow
the instructions in 2.5 section.
1.skt = net.new(net.TCP,net.SERVER)
2.net.on(skt,"accept",function(clt,ip,port)
4.net.send(clt,[[HTTP/1.1 200 OK
5.Server: WiFiMCU
6.Content-Type:text/html
7.Content-Length: 28
8.Connection: close
9.
10.
12.end)
13.net.start(skt,80)
STEP 4, The uploading procedure will be started automatically. If uploading successfully, the files stored in WiFiMCU will be
listed in the listbox.
STEP 5, Choose “webserver.lua” in the listbox. Right Click the mouse, a submenu list will be shown. Click “Run” to run the
script. Command string “dofile('webserver.lua')” will be sent to Lua interpreter.
You can test the other operations for the selected file freely.
STEP 6, Use a PC or a smart Phone connect to the AP that WiFiMCU made. For example, such as “WiFiMCU_Wireless”
we made in above section.
STEP 7, Open a browser, and type ”11.11.11.1” in the address field. You will get:
You can use any serial port tools to interact with WiFiMCU. Here is a simply instruction to use SecureCRT for example.
STEP 2, Connect WiFiMCU with a Micro USB, then open the session.
Adavanced Application 17
WiFiMCU Based on EMW3165 - User Manual
1.print("---WiFiMCU Demo---")
2.print("Flash LED")
3.pin = 17
4.gpio.mode(pin,gpio.OUTPUT)
5.tmr.start(0,500,function()
6. gpio.toggle(pin)
7.end)
STEP2, Upload the scripts via WiFiMCU STUDIO, Run this script.
STEP 1, Find a LED with dupont lines. Connect the anode to D1(or whatever pin that supports PWM function) while the
cathnode to a GND pin on WiFiMCU board.
1.print("---WiFiMCU Demo---")
2.print("Breathing LED")
3.pin = 1
4.freq =10000
5.duty =0
6.dir = 1
7.tmr.start(1,50,function()
9. duty = duty + 5
12. dir = 0
13. end
14. else
17. duty = 0
18. dir = 1
19. end
20. end
21. pwm.start(pin,freq,duty)
22.end)
STEP 3, Upload the scripts via WiFiMCU STUDIO, Run this script.
5 Update Firmware
The firmware, bootloader, or the WLAN driver for WiFiMCU can be updated. There are two ways: Using a serial port with Y
modem protocols, Using SWD programmer.
You can get the latest firmware, bootloader, or WLAN driver at:
https://github.com/SmartArduino/WiFiMCU/releases
Otherwise, You can download the source code and recompile your own firmware:
https://github.com/SmartArduino/WiFiMCU
3, On the WiFiMCU board, Press”Boot” button while press “Reset” button in order to enter into bootloader mode.
Update Firmware 23
WiFiMCU Based on EMW3165 - User Manual
4, Choose upload type :“Firmware”, “Bootloader”, “Wlan Driver”, and click “Update” to choose a binary file. The update
procedure will started automatically.
Update Firmware 24
WiFiMCU Based on EMW3165 - User Manual
5, Wait for finishing. You can “Abort” the update. Be careful, if updating is failed or Abort by user, the WiFiMCU may fail to
startup.
Update Firmware 25
WiFiMCU Based on EMW3165 - User Manual
6, Click “Reboot” button in WiFiMCU STUDIO to activate new firmware. Type command string ”=mcu.ver()” to check the
firmware version.
Update Firmware 26
WiFiMCU Based on EMW3165 - User Manual
STEP 1, Setup a serial interface connection with WiFiMCU just as what we have done at “Basic”->”3,
UseSecureCRT(Optional)”.
STEP 2, On the WiFiMCU board, Press”Boot” button while press “Reset” button in order to enter into bootloader mode. The
same operations as STEP 2 in 5.2 section.
STEP 3, Use command string to update the firmware, bootloader, or WLAN driver follow the instructions.
3,Reboot WiFiMCU, type command string ”=mcu.ver()” to check the firmware version.
Helpful Links 31