Skip to content

Introduction to Micropython on Air602 (W600 family) WLAN enabled module board

Jürgen edited this page May 5, 2020 · 17 revisions

Welcome to the W600_Tcp_To_Serial_Bridge wiki!

W600_Tcp_To_Serial_Bridge

TCP-Server for serial bridging over WLAN for WEMOS W600

Some infos to W600-Processor and AirW602-Board

Module Air602

Development-Board and Pin-Reference

Specs and documents and manufacturer overview/documents SoC-MCUs: W600, W601, W500

Micropyhon-Ports and very useful 3rd party introduction

SECBOOT-Bootloader and persistence

logging

usocket

Usage in Fhem-forum (german, Home-Automation)

This module uses: W60X_MicroPython_1.10_B1.5_img\1M_Flash

How-To:

The Module Air602 will be delivered with a AT-command firmware, which in my opinion is completly waste of time using it. ;-(

Micropython image from Winner

Micropython Image sources

Manual "Micropython-User Guide"

Micropython_Lib

Get started with Wemos W600 and w600-micropython get startet

Bootloader+AT-Firmware

Tutorial Blink

Tutorial Weatherstation

VSCode Development with pymakr

There would be two modes on programming Micropython to the board:

So, first action would be to reprogram the board's firmware using this pyton-upload-script from here

Usage:

python3 "D:\Air602\_software\w600tool-0.1\w600tool.py" -p COM15 --upload-baud 115200 --upload "D:\Air602\_firmware\W60x_MicroPython_1.10_B1.5_img\W60X_MicroPython_1.10_B1.5_img\1M_Flash\wm_w600_gz.img"`code`

This will erase the AT-Firmware install the Micropython not persistent on the board. Bootloader is not touched.. After Reset there will be only SECBOOT-Boatloader present and printints via connected serial adapter "

This Sample shows upload from an Arduino build inside Arduino-IDE via "Upload"-process: See boadmanager-workaround and upload workaround to circumvent buggy implementation.

C:\Users\js\AppData\Local\Temp\arduino_build_131628>python3 “D:\Air602_software\w600tool-0.1\w600tool.py” -p COM15 --upload C:\Users\js\AppData\Local\Temp\arduino_build_131628/sketch_apr16a.ino.gz.img --upload-baud 115200
Opening device: COM15
Uploading C:\Users\js\AppData\Local\Temp\arduino_build_131628/sketch_apr16a.ino.gz.img
0% [##############################] 100% | ETA: 00:00:00
Total time elapsed: 00:00:27
Reset board to run user code…

If Arduino is your preferred programming tool (C/C++):

if you want to download and install the board definition of W600.

Add W600 board manager URL from File -> Preference
Copy and paste the link https://raw.githubusercontent.com/salmanfarisvp/snippet/master/package_wmcom_index.json
Open Board Manager Tools -> Board -> Board Manager
search for W600 and click install.

Second method: make Micropython-Image with Bootloader (.fls) persistent, by switching the board, holding PA_0 low, on! The developers had forgotten to add an extra pad exactly for that requirement. So you will have to target directly pin 13 on the cpu-chip!

Using download.py instead of w600tool.py!

*REM python3 "D:\Work_STM32\_Hardware\Air602\_software\w600tool-0.1\w600tool.py" -p COM15 --upload-baud 115200 --upload "D:\Work_Air602\_firmware\W60x_MicroPython_1.10_B1.5_img\W60X_MicroPython_1.10_B1.5_img\1M_Flash\wm_w600.fls"*
REM remember to push PA0 constantly to GND during update-process
REM using download.py instead of w600tool.py! 
cd D:\Work_Air602_software\w600tool-0.1
python .\download.py -p COM15 -b 115200 --upload D:\Work_Air602_firmware\W60x_MicroPython_1.10_B1.5_img\W60X_MicroPython_1.10_B1.5_img\1M_Flash\wm_w600.fls
pause*

Upload source code

This script WLAN Connect with FTP-Server manages the Ethernet connection to the board. Enabling a ftp-server for code download.

I prefer Teraterm with serial connections. Enter Python-code easyly via copy&paste onto the board: *Copy source to clipboard enter CTRL-E in terminal and right-click mouse-button to upload code in raw-REPL-mode. *

Upload w600_net2ser.py via FTP to board.

You can persist this script, starting after Reset by adding this to main.py:

import w600_net2ser

w600_net2ser.main()

Room for improvements:

Yes, resolve blocking socket.recv()-method ...

non blocking

convert-bytes-to-a-string

esp8266

Socket@Micropython

Development

via RAW-REPL-MODE:

by pressing CTRL-D in terminal and right mouse-button-click:

clipboard

Check implemented modules by entering in terminal-console:

>>> help()

or list intrinsic modules

>>> help("modules")

>>> help("modules")
__main__          machine           uctypes           uselect
_boot             math              uerrno            usocket
_onewire          micropython       uhashlib          ustruct
_thread           network           uheapq            utime
builtins          ntptime           uio               utimeq
cmath             sys               ujson             uwebsocket
easyw600          uarray            uos               uzlib
framebuf          ubinascii         urandom           w600
gc                ucollections      ure
Plus any modules on the filesystem

and via code.completion (!):

>>> import machine
>>> machine.
__class__       __name__        ADC             DEEPSLEEP_RESET
 GPIO_WAKUP      I2C             PSLEEP          PSWAKEUP
 PWM             PWRON_RESET     Pin             RTC
 SPI             Signal          TIMER_WAKUP     Timer
 UART            WDT             deepsleep       disable_irq
 enable_irq      freq            idle            reset
 reset_cause     sleep           time_pulse_us   unique_id
 wake_reason
>>> machine.

>>> import socket
>>> socket.
__class__       __init__        __name__        AF_INET
AF_INET6        IPPROTO_IP      IPPROTO_TCP     IPPROTO_UDP
IP_ADD_MEMBERSHIP               SOCK_DGRAM      SOCK_RAW
SOCK_STREAM     SOL_SOCKET      SO_REUSEADDR    getaddrinfo
socket
>>> socket.

Specific method-implementation may vary heavily from MP-version to board-type! And even to their documentation ;-(

socket_module prototypes