Modtronix ESP32 Ethernet Gateway

This was spotted by Jean-Luc, over at CNX Software.  It turns out that Modtronix are not only still around, but they’re getting into the ESP world now, too (and I count both of those as being good news …I still keep a functioning Modtronix SBC45ECR1 board in my spares box).

Modtronix are currently running a crowdfunding campaign for an Ethernet-enabled ESP32 gateway board over on Crowd Supply (which has already reached its target).  The board is interesting in that it not only has Ethernet, but also a micro-SD card slot for extra storage, an additional STM32F030F4 ARM Cortex-M0 processor which, by default, is configured as an i2c expansion, a type-C USB port for power and data and a barrel-jack as an alternate power input (up to 16v).

The STM32F030F4 is the baby in that processor range, with only 16k of flash and 4k of RAM, but still makes this an interesting combination.  Unfortunately, at the time of writing, the GitHub repository doesn’t have any code posted, so we’re going to have to wait and see just how many of the little ARM chip’s peripherals are available to the ESP32.

One tip for navigating the Modtronix GitHub is that the schematics for the main board are actually there, but just not in the “pcb” directory …they’re in the “images” directory (and also linked from the in the “docs” directory).

Flashing the Sonoff TX/T0 US Version

The latest version of the Sonoff “smart” light-switch, the TX, is significantly different from the older ones. For a start, Itead have taken notice and created the front-panel for the US version in portrait, rather than landscape orientation. However, as one of the other changes was to remove all of the graphics (barring a small “Sonoff” label along the bottom), the orientation hardly matters now, anyway.  There’s also a black version available (and the Itead  site photo of the new, graphics-free front panel with blue, LED backlighting shows this version).Black version showing switch back-light

The new, plain white (or black)  front panel is fairly thick, with a single slot on the bottom edge for levering it open from the main body of the switch  —  which is required before you can fit it in the wall. The thickness of the front panel means that removing it from the body before it is fitted into the wall is a little difficult; while the front panel doesn’t flex, the thinner plastic of the body twists alarmingly. The best way to overcome this seems to be to lay the whole device on a flat surface, face down, then firmly press down with one thumb on the screw mounting hole (on the back-plate, just above the slot) before using a large, flat-bladed screwdriver to lever the back-plate away from the front panel. It does take quite a bit of force to open it.Press firmly & lever open

Removing the front panel allows you to screw the main body into the wall cavity, but also gives us access to the PCB so that we can flash TASMOTA onto the ESP8285 controller before fixing it into its permanent home.

The top PCB (with the switches and the ESP8285) needs to be disconnected from the main body of the device before programming and pulls off fairly easily (the design is asymmetric, so the PCB can only be inserted back into the body in one way).  The PCB layout also seems to have changed quite a bit since the previous version and there’s no “TP2/GPIO0” test point on the reverse side of this board.  Luckily, the other common connection point, the pad on R19, is still available, but in a different position on the PCB.Position of GPIO0 on R19

GPIO0 is on the end of R19 which is closest to the ESP8285 chip (the larger of the two chips, on the R/H side of the photo).

The contacts for a (3.3 volt) USB adapter are visible on the bottom, R/H side of the PCB photo (click to enlarge) and, as usual, GPIO0 needs to be briefly connected to ground when powering up the device to put it into programming mode.  I just used a flying lead clipped to ground at one end, touching the other end against the resistor pad while connecting the 3v3 supply.  Programming instructions for the “T1” version of the switch still work for this version.

Version 7 of TASMOTA is now available and the template for the T1/TX is also available from GitHub,  simply choose the correct template for your specific device and copy the string from the web page, then select Configure->Configure Other from the main menu on your newly installed device, paste the text into the Template input section, tick the Activate box and hit save.  Once the ESP has rebooted you will see the toggle boxes for each of the individual switches at the top of the main menu.

ESP12 — Bad batch out there

Just in case you haven’t seen it yet, GeekEnArgentina has reported on a bad batch of ESP12 boards which he received.  The symptoms were an endless boot loop when trying to program the device, with the problem being temporarily (and mysteriously) suppressed when a finger was touched to the upper, L/H corner of the ESP’s RF shield.

After two days of hectic troubleshooting (GeekEnArgentina was trying to ship out an order of 50 units to a customer), he eventually isolated the problem to a capacitor in the antenna circuit (which is assumed to be the wrong value, similar to the !470Ω LED resistor issue from a couple of years back).

His descriptions of the issue and the troubleshooting process are well worth a read.


There be bees here…

If you’ve never sat close to a bee hive and watched the little ladies going about their business, you’ve missed one of natures treats.  They are fascinating creatures on their own and the social cohesion and workings of the hive make them doubly so.  Bee keepers have always had to tread the delicate line between upsetting the balance of daily life in the hive against it’s internal state and the general welfare of the bees, though.  We have traditionally had to open the hives on a regular basis to check on the health of the bees themselves, as well as the state of honey and food stores.  While we still need to keep a careful eye on the health of the bees, IoT and ingenuity are making it easier to look after the bees without having to disrupt the hive with such frequent openings and I was very pleasantly surprised to come across the OpenHiveScale project a couple of days ago.

This is a new and ingenious take on a perennial favourite; a method of monitoring the weight of a beehive and thus being able to judge the amount of stored honey (summer) or food supplies (winter), without having to open the top of the hive and pull out individual frames of comb to inspect them (which always disrupts the hive, no matter how careful the beekeeper is).

The problem initially looks easy to techies.  Just pop a digital scale under the hive and automate sampling of the weight reading to have it delivered directly to your smart-phone.  Unfortunately, if you’ve tried going down this route, you will have discovered for yourself that it’s not quite that simple.  Digital scales (and load sensors in general) don’t deal well with being in a loaded condition for long periods of time (they tend to drift in a non-linear manner) and even if they did, there is still the problem of constantly supplying power to the scale at some remote (sometimes -very- remote) site.  One of the other options is to use a mechanical scale and somehow collect the data (the common low-tech version of this has a cheap, mechanical bathroom scale in a wooden housing under the beehive with some sort of mirror arrangement to allow the beekeeper to monitor the weight on his visits to the apiary).

OpenHiveScale mechanismThe OpenHiveScale project overcomes these problems by using a design based on the ancient “Steelyard” balance, with its sliding weight mechanism.  The fulcrum is folded within the frame to provide a wide load capability in a compact package.  The sliding counterbalance weight is driven by a stepper-motor and belt combination, with the “smarts” for the whole system provided by an ESP8266.  

The whole of this project (electronics, PCB, mechanical build and firmware) are all available from the OpenHiveScale GitHub repository.  Unfortunately, comments in the code are few and far between and there are no real build instructions on the site (there is an assembly_manual.pdf in the “mechanical” directory of the repository, but it is limited to diagrams, without any narrative), so you might have a difficult job duplicating their original work.  The good news is that they do sell kits.  The bad news is that they’re currently out of stock (and the price, including postage, is over €200).

The controller is modular, so if the hive is outside of WiFi coverage, an optional GSM, LoRa or SigFox card can be added (for an extra €30 to €40) to increase the range.

Power consumption is kept to a minimum by using an RTC chip to gate the enable signal on an LM3671 (low quiescent current) regulator and the recommended power source is a pack of 3 x AA alkaline batteries.

Unfortunately, the price (and lack of specific build details) make this a non-starter for all but the most well-heeled beekeepers, which is a shame.  We can only hope that this unique design will become popular enough to make it into mass production (with, hopefully,  a resulting drop in price).  It’s easy to imagine other applications for this scale, too.  Anyone who relies on tanked propane gas, for instance, would welcome the convenience of knowing just when the tanks need to be switched over (instead of having to go out at 10:30 at night, still wet and soapy from an interrupted shower).



Something new from Seeed…

…but we’re not quite sure what.

Seeed Wio_Lite_RISC-V_front

This morning I received an update from Seeed Studio with, among others, news of a new product in their “Wio” range, the “Wio Lite RISC-V (GD32VF103) – With ESP8266”.

It is attractively priced, at only $6.90 (plus shipping), but whether it’s actually worth ordering is a bit of a mystery.  Unusually for Seeed, there are no documents of any sort on the product page and the available description leaves a lot to be desired.  Basically we know that it’s a “GD32VF103CBT6 Bumblebee core” main processor with power consumption of  “only 1/3 of that of traditional Cortex-M3”.

Seeed Wio_Lite_RISC-V_back

The ESP8266 appears to be a standard, Espressif-produced WROOM-02 model, so nothing too exciting there, but there’s no obvious indication on either the front, or the back of the PCB of any interconnects between it and the GD32VF103 (the vias visible on the back of the board appear to connect the pull-up/down resistors on the front side to the ESP GPIOs).

Update  —  It turns out that a zip file in the “res” sub-dir on GitHub contains the Eagle PCB files for the board and a quick look at those confirm that the WiFi_TX, WiFi_RX and WiFi_RST pins are all directly connected between the ESP8266 and the GD32VF103.  It’ll be interesting to see what firmware the board ships with; the availability of full GPIO headers for the ESP hint that it won’t be using just the standard AT command set.

The GD32VF103 side of the board has a USB-C connector and an SD-card slot (the latter on the back of the board), as well as a LIPO battery connector and on-board charging circuitry, so it’s a useful looking board on it’s own.  It still remains to be seen whether the ESP adds any value to the package, though.

TASMOTA now supports the A4988 stepper-motor controller

As of a couple of days ago,  courtesy of Tim Leuschner, TASMOTA now supports the A4988 stepper-motor controller board.  Here are Tim’s instructions for getting it going:-

How to use:-

1. Physically connect at least Dir-&STP-Pin of the A4988 to 2 free GPIO’s of the ESP.
2. Allocate those GPIOS in settings to “A4988 pins” (#170ff).
3. In console type MOTOR {“setMIS”:1,”setRPM”:60,”setSPR”:200,”doTurn”:1.5} (sets microstepping to 1/1, StepsPerRevolution to 200, RevolutionsPerMinute to 60 and commands the motor to turn one and a half rotations).
MOTOR {“doMove”:100} commands the motor to step 100 times.
MOTOR {“doRotate”:360} commands the motor to rotate 360 degrees.
4. REST-Calls work with : http:///cm?user=aName&password=aPW&cmnd=MOTOR%20{%22setSPR%22:200,%22setRPM%22:60,%22doMove%22:360}

Command list:-

setMIS — Sets the micro-stepping (1,2,4,8,16 stand for a full step, or one-half, one-quarter, one-eighth or one-sixteenth of a step).
setSPR — Sets the number of steps the motor requires for one full rotation (depends on micro-stepping).
setRPM — Sets the number of revolutions per minute (roughly – not precise) – if too high, motor will not turn – test out an appropriate number for your use case.
doMove — Commands the motor to step the given number of times.
doRotate — Commands the motor rotate the given number of degrees.
doTurn — Commands the motor to spin the given number of rotations.

Tim is also looking for a little help with the MQTT implementation of the command set:-

Can someone plz take care to enable the MQTT-way to send this commands?Cheers Tim

Any takers?

A more detailed instruction sheet on how to set up the A4988 (with power switching and control of micro-stepping using additional GPIOs) has already been added to the Wiki by the hard-working maintainers (I don’t know how they keep up with all of the updates).

First steps with the W600 (on Linux)

I ordered a couple of these W600 dev boards a few weeks ago, as they were reported to be the easiest ones to use when introducing yourself to the ThingsTurn Dev BoardW600 chip (these “ThingsTurn” boards don’t have any second processor to grapple with, but do have a UART chip and USB connector for easy power/comms).

It turned out that while the power connection was easy, the comms were anything but and I wasted far too much time messing around trying to get it to accept an upload or even just a terminal connection.  So today’s post mainly consists of a series of short tips on how to get started with the W600 “ThingsTurn” dev board without pulling out all of your hair.  Tips 1 through 4 deal with getting MicroPython onto your W600, while those from #5 onwards are examples of what you can do with the board from the MicroPython REPL (command line).

For my purposes, I just wanted to upload MicroPython as a quick, functional test, without having to download and install a toolchain and/or SDK, or really do anything at all that took more than a couple of lines of typing or 5 minutes of my time.  Two days later, I was -still- getting nowhere very fast; my blood pressure was rising and I was itching to use my magic, solves-everything tool  …the 1.5kg lump hammer.

So, tip #1 is  —  Don’t believe everything you read (including this!).  The W600 firmware and applications are still under heavy development.  Most (but not all, see tip #2) of that work is taking place in China.  The translation and maintenance of the manuals seems to be quite well down the TODO stack (something that most of us are guilty of).  Specifically, don’t bother trying to use their “” (if you can find it) for anything, most especially not for uploading to ThingsTurn boards.

Tip #2  —  Volodymyr Shymanskyy has recently posted a great tool for uploading to the W600.  It knows about the two available bootloader methods and will try to do the right thing, depending upon which type of file you’re attempting to upload.  Don’t bother with anything else; go straight to his repository and start using it now.

Tip #3  —  Don’t assume that your favourite terminal program(s) will work with the ThingsTurn boards, even if it has worked with everything else you’ve ever tried it with.  It turns out the the the ThingsTurn boards (note that I’m being very specific here, as I don’t believe that any of the other W600 modules suffer from this issue) have a requirement for the RTS signal to be held at “0” when connecting, otherwise the W600 will be forced into a permanent reset condition.  I was unable to get either “screen” or “minicom” (my usual goto choices for comms terminals) to play with the ThingsTurn boards.

By this time I knew that the boards worked, as they communicated with “w600tool” easily and loaded MicroPython (to displace the simple, one-second flash on/off program which comes as default on the boards).  Connecting with either screen or minicom would very occasionally produce a random, brief flash from one of the blue LEDs, but there was never any further indication of life and definitely nothing coming from the boards.  A major step forward was finding that sending a “Hang-Up” request (CTRL-A H) from Minicom produced the MicroPython header and a REPL prompt from the board, before it lapsed back into its previous, comatose state.  This confirmed that the upload had indeed worked and that, given the right conditions, MicroPython would run.  At this point I reverted back to my 1980’s RS232 self and started writing a simple C program to toggle the control lines…  before remembering that this was the glorious future and somebody else on the ‘net had undoubtedly already done it (and undoubtedly made a far better job of it than I ever did).  So I knuckled myself on the side of the head a couple of times and turned back to Volodymyr Shymanskyy, as he’d already helped me out once and seemed to have already cracked this particular problem.  That particular rabbit-hole led me, in very short order, to Python.

Tip #4  —  Use the force, Luke!  Or at least, don’t be as stupid as me and refuse to see what’s right under your nose.  You wanted to get running with something quickly:-  MicroPython.  MicroPython =~ Python.  W600tool =~ Python.  There’s a bit of a pattern emerging here.  Yup, those clever Python dev guys have already written the solution to our problem and it is called “miniterm”.  A quick check of the on-line manual pages showed that it was quite capable of toggling selected hardware control lines and holding them in the selected state, as well as all of the normal port and baud selection stuff.  So here’s the command line to get you connected, up and running using miniterm:-

python3 -m --rts 0 /dev/ttyUSB0 115200

[…and just a reminder here that this is from Linux, you’ll likely have to change at least the device name if you’re using a different OS].

Once you’ve typed that in you’ll see something like:-

— forcing RTS inactive
— Miniterm on /dev/ttyUSB0 115200,8,N,1 —
— Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H —

…followed by an ASCII-art representation of the Winner-Micro (stacked “W” and “M”) logo (which really confuses WordPress formatting, so is not included here), followed by:-

WinnerMicro W600
MicroPython v1.10-279-g3c60627-dirty on 2019-05-24; WinnerMicro module with W600
Type “help()” for more information.

Yay!  We’re in business!

Tip #5  —  Import the machine-specific hardware module.  Configure a W600 pin (PB14 in this case) as an output (with no pull-up or pull-down) and assign name “led14” to it.  Use the assigned name to toggle the value of the W600 pin (note that the blue LEDs on the ThingsTurn boards have their anodes connected to VCC via a 1k resistor and the cathodes are connected to the GPIO pins, so the output value of “1” turns the LED off and “0” turns it on:-

>>> import machine
>>> led14=machine.Pin(machine.Pin.PB_14,machine.Pin.OUT,machine.Pin.PULL_FLOATING)
>>> led14.value(1)
>>> led14.value(0)

Tip #6  —  Connect to an existing Access Point.  To do this, we first import the network module and then initialize as a station and scan for available networks.  We connect to an available network (SSID “BigHouse”) with whatever the password is (“Th3Pa55word” in this example), check for a valid, live connection and finally, print out the IP address.

>>> import network
>>> sta_if = network.WLAN(network.STA_IF)
>>> sta_if.scan()
[(b'BigHouse', b'0Z:\xc7\x82\x10', 6, -67, 32, False)]
>>> sta_if.connect("BigHouse", "Th3Pa55word")
>>> sta_if.isconnected()
print("Connected, ip is: " + sta_if.ifconfig()[0])
Connected, ip is:

Tip #7  — Create an access-point on the W600  …and then shut it down again.  First we need to load the easyw600 module, which contains Winner Micro’s own helper functions to make this easy.  There’s just a single call to easyw600.createap(), with your choice of SSID.  You’ll find that the  new access point pops up immediately and is visible and accessible (but not very useful) from any nearby device equipped with WiFi:-

>>> import easyw600
>>> easyw600.createap(ssid="W600_softAP")
softap working, ip is

When you’re finished, there’s just a single call to easyw600.closeap() to shut it all down again:-

>>> easyw600.closeap()

Tip #8  –  Enable an FTP server process.  This will allow us to manipulate files on the W600, so that longer MicroPython programs can be written elsewhere and then debugged on the device itself.   Before you start with the FTP server, you need to make sure that your W600 is already on-line and associated with an existing AP (see tip #6, above).

The FTP server is included in yet another module, this time named simply “w600”, so to begin with, we need to make sure that it is imported.  After that, there’s just a one line command to start the FTP server with a given username and password (note that in the given example, the username and password are both set literally to the word “None”):-

>>> import w600
>>> w600.run_ftpserver(port=21,username="None",password="None")
ftpserver is running.

[After writing this tip, I found that the “easyw600” module has a wrapper for run_ftpserver() which is even easier to use, just:-  “easyw600.ftpserver()” ]

You can now access your W600 from any local machine and you’ll see something like this:-

Connected to
220-= welcome on W600 FTP server =-
Name ( None
331 Password required for None
230 User logged in
Remote system type is UNIX.
ftp> ls
200 Port Command Successful.
150 Opening Binary mode connection for file list.
drwxrwxrwx 0 root root 0 Jan 1 2018 sys
drwxrwxrwx 0 root root 0 Jan 1 2018 lib
drwxrwxrwx 0 root root 0 Jan 1 2018 cert
-rwxrwxrwx 0 root root 139 Jan 1 2018
-rwxrwxrwx 0 root root 34 Jan 1 2018
-rwxrwxrwx 0 root root 40 Jan 1 2018
226 Transfert Complete.

So, we can now create a file, “” containing Python code on our local Linux machine:-

def wibble(FC="dog"):
    print("Furry creature: " + FC)


Now upload it to the W600 using FTP’s “put” command and then go back to the W600 console and type:-

>>> import fc

…(note:- there’s no “.py” on the end) and you’ll see the output from your new code.

If you repeat the “import fc” command, there’s no further output, but you can now call the “wibble” function from the REPL command line.  Try:-

>>> fc.wibble()


>>> fc.wibble("rabbit")

Note that it isn’t really possible to un-import a file (or module) once it has been cached, so -don’t- edit your file remotely and then expect to see the changes reflected when it is re-uploaded. MicroPython generally ignores an import request for something which it already has marked as existing in cache. The only bullet-proof way around this is to reboot the W600.

Tip #9  –  How do I reboot the W600 (without pulling the power cord)?

>>> import machine
>>> machine.reset()

Tip #10 – And finally, here’s a replacement file which you can now upload to your W600 to have it automatically connect to your WiFi network and start the FTP server (both as described above) on reboot. You -will- need to set the SSID and password for your access point before installing it.

## file content. Used to automatically start
## the network, join an access-point and then start
## an FTP server on the W600 at initial boot.
## *** You must set an SSID and password ***
import network
import w600
import time

print(“Starting network and FTP server…”)

## Join Existing Access-Point (Local Wireless Network).
sta_if = network.WLAN(network.STA_IF)
sta_if.connect(“MY_SSID”, “MY_PASSWORD”)

## Start built-in FTP Server.

## …and let the user know what our address is.
print(“Waiting for DHCP…”)
print(“Connected, ip is: ” + sta_if.ifconfig()[0])