Skip to content

ZaitsevY/BrotherLink

Repository files navigation

Wireless Brother KH-9xx knitting machine connection.

Isn't your Brother KH-9xx online and blogging yet 😄?
Come on, stop wiring your room, it's time for IoT and WiFi!
Let's create wireless BrotherLink cable!

TL;DR

Watch it working

Briefly

Introduction

You all know that BrotherLink BLx USB cables are far overpriced. Some of you create DIY cables following Adafruit or Daviworks tutorials. Having repeated their cable I got an idea to replace the wired connection with a WiFi one.

After looking around I found that there's a pretty cheap solution out there on the market – ESP8266 module, which is actually an MCU (micro controller unit) with built-in SPI flash memory, WiFi, GPIO, UART, etc. periphery. It is very popular for DIY IoT projects, has a lot of users, who contributed a lot of libraries helping to develop ESP8266 applications using pure C/C++, Arduino Wiring, Lua and so on.

Hardware

I'm not an electronic engineer so I decided to go with ready-to-use modules to reduce welding and avoid mistakes. As for the minimum you need:

  1. ESP8266 module (or board). I selected WeMos D1 mini - a minimalist ESP8266 board with all necessary resistors, an integrated USB-UART bridge (you won't need a separate converter to connect the module to PC for firmware flashing) and a 5V-to-3.3V power converter (not very reliable though).
  2. Logic level converter. Brother KH-9xx serial interface is known to operate at 5V level, while ESP8266 IO expects 3.3V. The simplest logic level conversion can be achieved with two resistors by I opted to use a factory manufactured module. I bought mine from AliExpress which is times cheaper than the one from SparkFun. Caution: do not! connect ESP8266 RX/TX directly to KH-9xxx port, doing so will most likely harm the module.
  3. Power. ESP8266 operates at 3.3V (caution!); to coordinate logic levels you'll also need 5V. For the time writing the article I feed my device with a breadboard power supply (note separate +5V and +3.3V buses on the diagram), but for a final setup I'm going to pick up +5V directly from KH-9xx internals in order to get rid of wires completely. To step +5V down to +3.3V you should consider including a separate AMS1117 power module (not shown on the diagram).
  4. Optionally, to provide for Interactive Knitting (IK) mode of the DesignaKnit application, you might want to add a reed switch and a 10kOm resistor (or, like did I, use a pre-manufactured reed switch module). You also need a magnet, which you'll put (glue or somehow attach) to the carriage of the knitting machine (that'll be your BL5 “magnetic arm”). With this option your device becomes a BrotherLink BL5 wireless cable, while without it – just BL1.

Diagram

Firmware

To make things fly you'll have to upload some firmware to the ESP8266.

The best option for those who are not close to MCU firmware programing is to download ready-to-flash binary files from the release.

The firmware is based on esp8266web project which already contains almost all the necessary things including: WEB Server, TCP-to-UART bridge with a lot of configurable options, device and application configuration through web interface.

I had to make some customizations of the original project in order to utilize reed switch and provide for Interactive Knitting. Customized sources are here and the sources of the application (Eclipse project) are right in this very repository. Again, to skip the time consuming learning trail of compiling firmware from sources, you might prefer to download the ready-to-flash binary files.

To upload firmware to your module you'll have to install Python (choose 2.x version) with pyserial (the simplest way is to issue pip install pyserial from command prompt after Python installation). Esptool is already included in the binary distribution. If you follow me and use WeMos D1 mini module, make sure you have installed Ch340G driver (if appropriate for your OS).

Connect your module to USB of your PC, detect the resulting COM-port number.
Note: COM4 is assumed for the example commands below.
Note: click RESET button of D1 mini just before you run esptool.py … write_flash … command.

First, flash clear settings with the following from the command prompt:

esptool.py --port COM4 --baud 460800 write_flash -ff 80m -fm qio -fs 4m 0x79000 clear_eep.bin 0x7C000 esp_init_data_default.bin 0x7E000 blank.bin

Second, flash the software portion:

esptool.py --port COM4 --baud 460800 write_flash -ff 80m -fm qio -fs 4m 0x00000 .0x00000.bin 0x07000 .0x07000.bin

Press RESET on the module again (just to be on the safe side), wait a couple of seconds and now you can use any of your WiFi-enabled devices (notebook, smartphone) to:

  1. Connect to a WiFi access point named ESP8266 (by default);
  2. Point you browser to http://192.168.4.1/fsupload (default username:password are ESP8266:0123456789) and upload WEBFiles.bin file;
  3. Point you browser to http://192.168.4.1/ and continue device configuration.

Configuration:

  1. WiFi Settings: set your home WiFi SSID and password. Optionally switch off ESP8266 access point by selecting STATION_MODE. Mention that right after switching AP off you won't be able to access web interface of the module with 192.168.4.1, instead reconnect your notebook (or whatever) back to your home network and use http://sesp8266/ or, if the latter doesn't work for you, find out the new module IP address from your WiFi router (notice http://192.168.1.37/ address part on the screenshots below). Or just leave WiFi mode setting as STATIONAP_MODE.
    WiFi Settings
  2. TCP-TO-UART Settings: set baud rate to 9600, enable RX and TX inversion.
    TCP=UART Settings
  3. System Setup: disable checking RX pin to reset WiFi configuration (important! When you power on your device while it is connected to KH-9xx port, this setting, if enabled, will reset your customizations from 1.).
    System Settings

Software (Windows only)

DesignaKnit expects knitting machine to be connected through COM interface. To make it acquainted with your device you'd install a virtual COM-port driver. There are several solutions out there: HW VSP, VSPE, USR-VCOM; I didn't try them all so the following screen shots are all about HW VSP.

After installing HW VSP you'd create a virtual COM-port with the following settings:

First, at the Settings tab, click Login to acquire administrative access, then configure as on the following screen shot:
VSP Settings

Next, go to the Virtual Serial Port tab to select your COM-port name; set “sesp8266” for the IP-address (or take the IP of your device from its web interface WiFi Settings page, IP from WiFi Station column); set port to 12345:
VSP Virtual Port

Note: if you power your device off, HW VSP looses connection to your device and to enable it again you'll have to delete and create your virtual port again. Looks like "Use NOP to Keep Connection" and "Renew Automatically" settings of HW VSP might help but they are by some reason disabled.

Video

Finally it's time to DesignaKnit!

Wireless Brother KH-9xx connection

Acknowlegements