Related lists

This project is submitted for

Description

There is a motor shield for the WeMos D1 Mini ESP8266 board, and it uses an STM32F030 microcontroller for the communication. However, the code running on it is really sloppy, resulting in the firmware hanging and bringing the I2C bus down whenever you look at it funny. But we are hackers, we can fix it!

The shield has a serial interface for programming broken out, and that chip is supposed to have a bootloader built-in, so hopefully we will be able to just use stm32flash and an USB2TTL adapter to program it.

Files

Project Logs

As mentioned by @Matrix User in the comments, the new firmware doesn't support selecting of the I²C address with the jumper pads on the bottom of the board — instead the address is fixed in the firmware. There is an issue reported about this at https://github.com/pbugalski/wemos_motor_shield/issues/3 and some workarounds, including alternate builds of the firmware with different hard-coded addresses.

Turns out that the procedure in the previous log can be greatly simplified. You don't need an ST-Link programmer, and you don't need to solder anything. Even if your shield is locked, you can unlock and program it with a simple serial adapter. Here is how.

Last evening I made the first try at programming this thing. From the datasheet and the schematic it looks straightforward: the BOOT0 pin is connected to the RTC pin of the serial, the NRST pin is connected to DTR, it should just work. So I connected the USB2TTL (also a WeMos one), and gave it a go:

No joy. To the datasheet then! Hmm, they mention a BOOT1 there too, but it's nowhere to be seen as a pin... Let's google for it... http://stackoverflow.com/questions/22351703/stm32f030-and-boot0-pin Ah-ha! It looks like BOOT1 is a flag in something called "user flash option byte", and it has to be set to 0 for the bootloader to start. Shame I have no way to check it.

If that flag is set to 1 in this firmware, then the only way to reprogram this board is to use an stlink programmer. Fortunately, I do have one! Unfortunately, the SWD and SWC pins are not broken out, so I guess I will need to do some precision soldering directly to the chip's legs. Oh well.

Become a Hackaday.io Member

I wrote firmware for STM23f030 to drive a stepper in microstep mode,at this time working version use serial port but in testing I2C interface,I used Libopencm3 libraries,it lacks of I2C slaves examples but i think is almost ready .

Hi all,does anybody know why there is 2x a 'delay(100); ' in WEMOS_Motor.cpp of the original wemos library? Is this really needed? I am trying to get my plugin included by pull request into ESPeasy, but developers complain about it as blocking.

Hi all, thx for the fix. I would like to use ESPeasy with the D1 mini and motorshield. But currently there is no plugin available, only for the Adafruit motor shield. Is anybody able to support me in writing a plugin for ESPeasy?

Thank you so much for this manual!I've got this Chinese clone of Wemos D1 Motor Shield which was not detectable via I2C and thanks to your post I was able to make it work! Unfortunately I was not able to build my own firmware but your built worked perfectly.

I've been been playing with this for weeks now and I'm going to admit that I'm stuck.

My motor shield seems to be intermittent in its i2c communication. I've *think* I've managed to upload the new firmware to it (I used the motor_shield_30.bin binary as I have some problems getting the tool chain to work on my Mac). When I ran the:

I have two of these on the same circuit. I have soldered the pads on the back side in an attempt to change the I2C address of one so I can use both at the same time. No matter what I do the pads, I can't seem to change the default address. I don't know if this firmware ignores those pads or something else it wrong. Any ideas? Does the following concept still applies to this firmware?

Actually, I did the steps. The I2C scan sketch can read 0x30 (which it couldn't before). I have applied 12v to VM and GND pins. A1 and A2 has a 12v DC motor attached. I can read 12v using a multimeter across the VM and GND pins but I can't read any voltage on A1/A2 or B1/B2 pins and the motor never spins using the stock Arduino sketch. If I directly apply 12v to the same motor it spins. Any ideas?

Never mind. I read aarn_a comment and seems like this one also had the IO pad soldered for standby mode. I unsoldered it and soldered the I2C pads and everything works now. I didn't think to look there as all documentation said that I2C is standard/default on these boards for standby mode.

Thank you so much guys. I also had a china shield that won't come up in i2c scan sketch. Luckily, I had a serial adapter from a few years ago that I used with Mini Pro. I hooked it up to windows, ran the exe and uploaded the bin in like 2 minutes and it started responding!!

When I connect VM/GND to A1/A2, I see a reaction in the motor, and same goes for the other motor. So, that seems to be working. Now, how do I make the sketch send power to the motors? I'm testing it with the examples from the motor shield library (https://github.com/wemos/WEMOS_Motor_Shield_Arduino_Library).

Thanks for this! Certainly makes the shield usable. I reprogrammed without any soldering at all. I just used arduino style jumper wires and poked the pins through the holes in the shield, and then pushed them with my hand to ensure a good contact. I poked a wire thru the RTS hole and wrapped it round the 3V pin. The stm32flash operations are very fast, so it is not hard to do.

Those of you who want to do this using Window's 8/10. Download the motor_shield.bin from aboveDownload STM32Flash from here https://sourceforge.net/projects/stm32flash/files/Extract and put the above files into a directoryPlug in your USB serial device and make a note of the COM port it usesUsing Window Command Prompt cd to the directoryUse the following after connecting the RX,TX,GND,VCC, short the RTS and the 3V as per Radomir Dopieralski instructions on the top of this page . 1) stm32flash.exe COM8 "replace with your port number"2) stm32flash.exe -k COM8 This will unlock your shield3) stm32flash.exe -f -v -w motor_shield.bin COM8 this will flash the bin and re-lock the shield.