How to connect to a GTR via an ESP8266 WiFi Adapter

Overview

The GTR is an STM32F407ZGT6 based board.

There have been a number of changes in the way RRF builds for STM32F4, STM32H723 and STM32H743 boards are being produced from 3.5-RC4 and onwards.
The main changes are:-

  • A build per board rather than all boards being contained in one build
  • WiFi and SBC mode in one build. If there is an SD card present its in WiFi mode, if there isn’t one installed its in SBC mode. This matches the way the Duet3D boards operate.
  • A board.txt setting to denote the WiFi module type installed.

Downloading the board firmware

Teamgloomy now generate per board firmware files. The correct file to use for this board is firmware_gtr1_0_f4.bin.

The latest firmware files can be found here

You can choose to download either the latest release or the latest pre-release if available. These instructions are applicable to releases from 3.5-RC4.

Once downloaded, rename it firmware.bin

WiFi firmware preparation

The latest firmware files can be found here

  • WiFiModule_esp8266.bin

DWC (DuetWebControl)

The correct version of DWC should be downloaded from here.
The version you download should be of the same version number as the board firmware you downloaded above.
For example, if version 3.5.0 of the board firmware has been downloaded, 3.5.0 of DWC should be downloaded.

Purchasing the WiFi Adapter

If you are just purchasing an adapter now, TeamGloomy Strongly recommends an ESP32 adapter as the WiFi performance has been greatly increased.

You will need to purchase an adapter that plugs into the EXP1 and EXP2 headers. They can be purchased from a number of suppliers. They are:

  • PCR (part of TeamGloomy) on Tindie
  • Mellow (who works in close collaboration with TeamGloomy) on Aliexpress
  • BTT also make an adapter but TeamGloomy do not recommend it as it does not have a serial connection readily available, removing the ability to update the WiFi firmware from within RRF.

Connecting the WiFi Adapter

Connect EXP1 on the GTR to EXP1 on the WiFi adapter and connect EXP2 on the GTR to EXP2 on the WiFi adapter.
Connect the 4 pin serial header on the WiFi adapter to the WiFi header on the GTR. As power is being taken through EXP2, only the RX and TX lines need to be connected.

Homemade ESP8266 WiFi Adapter

Use a nodemcu ESP8266 with USB programming as it already 5v tolerant and it allows for updating via USB.

BOM

  • 1 x nodemcu ESP8266 or Wemos D1 mini
  • 3 x 47R resistor
  • 1 x 470R resistor
  • 3 x 2200R resistor
  • jumpers or other ways of connecting to the GTR

Preparing the ESP8266

Follow the instructions here.
Alternatively you can connect the RX/TX pins on the ESP8266 to a set of RX/TX pins on the GTR.

Connecting the ESP8266

The pinout for the GTR can be found here and the schematic for the Duet 2 WiFi for reference can be found here.

The table below shows the pins required on the ESP8266 and what they are connected to on the GTR.

ESP8266 Pin GTR Pin Resistor Value
RST PB_10 on EXP2 470R
CS/GPIO15 PB_12 on EXP2 2200R
MOSI/GPIO13 PB_15 on EXP2 47R
MISO/GPIO12 PB_14 on EXP2 47R
SCLK/GPIO14 PB_13 on EXP2 47R
ESP_DATA_Ready/GPIO0 PA_15 on EXP1 2200R
LPC_DATA_Ready/GPIO4 PC_11 on EXP1 None
VIN(5v) 5v on EXP1 None
GND GND on EXP1 2200R to RST

Generate a config

We provide a handy online tool to assist you in generating a set of config files for your 3D printer. The configurator doesn’t cover all options that RRF can be used for (such as dual motor axis control, which can be manually added later), however it does give a good start.

We also have a collection of user created configs which can be a useful reference. They can be found here

Manual board.txt Changes

If you are using a set of config files provided by someone else or have no need to use the configurator, you may need to create your board.txt file manually. From 3.5-RC4, the majority of the board.txt configurables are pre-configured per board.
The preset configurables for the GTR are listed below for reference.

board=gtr1_0_f4
board.longName="BTT GTR V1.0"
sdcard.internal.type=1
SPI0.pins={A.5,A.6,A.7}
SPI1.pins={B.13,B.14,B.15}
SPI2.pins={NoPin,NoPin,NoPin}
SPI3.pins={I.9,B.11,H.11}
SPI4.pins={I.1,I.2,NoPin}
SPI5.pins={B.3,B.6,G.15}
stepper.powerEnablePin=NoPin
stepper.enablePins={F.1,E.4,B.9,G.13,D.7,D.2,F.8,G.2,F.4,E.8,I.0}
stepper.stepPins={C.15,E.3,B.8,G.12,D.6,D.1,F.3,D.14,E.12,G.0,H.12}
stepper.directionPins={F.0,E.2,B.7,G.11,D.5,D.0,G.3,D.11,E.10,G.1,H.15}
stepper.numSmartDrivers=6
stepper.TmcUartPins={C.14,E.1,B.5,G.10,D.4,C.12}
stepper.spiChannel=5
power.VInDetectPin=NoPin
sbc.TfrReadyPin=B.10
sbc.csPin=B.12
sbc.spiChannel=1
heat.tempSensePins={C.0,C.1,C.2,C.3,A.3,F.9,F.10,F.7,F.5}
heat.spiTempSensorChannel=4 
heat.spiTempSensorCSPins={H.9}

There should be no need to override any of the above preset values unless you are adding additional features, such as an accelerometer or 12864 display.
You will however still need a board.txt file to configure, as a minimum, the drivers used in your board.

WiFi Pins

As RRF doesn’t know which WiFi module you are using and what method you are using to connect the module, you will need to specify the board.txt entries for the module you are using.
For an ESP8266, they should be as follows:

//WiFi pins
wifi.espDataReadyPin = PA_15
wifi.TfrReadyPin = PC_11
wifi.espResetPin = PB_10


//ESP8266 RX/TX Settings
wifi.serialRxTxPins = { PC_7, PC_6 }
serial.aux.rxTxPins = { PD_9, PD_8 }

Drivers

The following line should be added (obviously with the array entries matching your drivers and their locations):

stepper.DriverType = {Tmc2208, Tmc2240, tmc2209, tmc5160, stepdir}

The DriverType array allows for any driver to be used in any slot so there is no order requirement like the previous detection method. The array must also include an entry for each driver slot up to the last one thats populated.
The following list of entries are valid:

none
stepdir
tmc2208
tmc2209
tmc2660
tmc5160
tmc2240

The entry for stepper.numSmartDrivers is preset in the firmware for the number of drivers your board can handle. The number of drivers only needs to be changed if you are adding more drivers using something such as the BTT EXP MOT.

TMC2240 Driver Temperature

TMC2240 drivers support reporting their own temperature, rather than just hot and very hot like the other TMC drivers. To utilise this, add the following line to your config.g

M308 S11 Y"drivers"

This will return the highest temperature reading from any of the drivers, 2240s will return the actual temperature, other drivers will return 0, 100 or 150 (as before).

If you want to know the temperature of a particular driver you need to add the following line (as well as the above):

M308 S12 Y"drivertemp" p"S11.X"

Where x is the driver number that matches the driver number used by M569

Sensorless Homing

Follow the instructions as found here

SD Card preparation

Now all the required files have been gathered, the SD card structure needs to be created.

SD Card Specification

When choosing an SD Card to use with RRF, we recommend one with the following features:

  • a branded card with a speed rating of Class 4 or higher
  • of up to 32GB capacity, formatted as below. RepRapFirmware does not support SD cards formatted in exFAT format.

Formatting

If you can’t use the recommended formatting tool, then the following points should be taken into account:

If you need to reformat the micro SDHC card:

  • If the capacity of the card is 4GB or lower, use FAT16 format
  • If the capacity is more than 4GB (up to 32GB) then you will have to use FAT32 format
  • All cards should be formatted with 512 byte sectors
  • For best upload speed choose the largest cluster size available, which is normally 64kb for FAT16 and 32kb for FAT32

SD Card Structure

The following structure should be replicated on your SD card.

sd card root/
├─ filaments/
├─ firmware/
│  ├─ WiFiModule_esp*.bin
├─ gcodes/
├─ macros/
├─ sys/
│  ├─ bed.g
│  ├─ board.txt $ If required
│  ├─ config.g
│  ├─ homeall.g
│  ├─ homex.g
│  ├─ homey.g
│  ├─ homez.g
│  ├─ pause.g
│  ├─ resume.g
│  ├─ sleep.g
│  ├─ stop.g
│  ├─ tfree0.g
│  ├─ tpost0.g
│  ├─ tpre0.g
├─ www/
│  ├─ contents of DuetWebControl-SD.zip
firmware.bin

In the above example, the contents of the sys folder have come from the online configurator. The WiFiModule file name will either be:

  • WiFiModule_esp32.bin
  • WiFiModule_esp8266.bin
  • WiFiModule_esp32eth.bin
The contents of DuetWebControl-SD.zip should be extracted into the www folder.

Final Setup

Once connected, power up the board using 12-24v and connect to the USB port on the board. Connect to the board using a program such as putty. Follow the instructions here to set it up for RRF. Change the Com port to match the GTR and connect. The baudrate doesn’t matter.

Flashing the WiFi Firmware

Type in the following to putty

M552 S0
M997 S1

Wait for the uploading of the WiFi firmware to finish.

Sending your WiFi Credentials

Send the following

M552 S0
M587 S"your SSID" P"your password"
M552 S1

The blue light on the WiFi chip shoould then flash blue and will go solid when a connection has been established. The ip address will be shown on the serial connection. It is also possible to type just M552 to get the current ip address reported back.

The final thing to do is add the line “M552 S1” to your config file. This can be done through the web interface. This just ensures that the WiFi connection is started at start up. There is no need to add the M587 command as this is written permanently to the flash of the ESP8266 chip.

Once up and running

You will need to PID tune your tools and your bed. Please be aware that bed tuning may take up to an hour and tool tuning normally takes around 15 minutes. If it takes longer, that is also fine as up to 30 cycles may be ran.

To tune the bed, run the following command, changing the temperature (the S value) if a different tuning temperature is required.

M303 H0 S60

To tune each tool, run the following command, changing the temperature (the S value) if a different tuning temperature is required. This proceedure will activate the part cooling fans during the final phase of the tuning process so their effect is taken into account. If your printer has more than one tool, make sure each one of them is tuned.

M303 T0 S220

Once the tuning is complete, either copy the M307 command into the heater definitions or send M500, ensuring you have M501 at the end of your config.g.
If the tuning fails at the end, carry on saving the values as in most cases the outputted values still work correctly.
If the values still result in a heater fault, please refer to this wiki page for information about how to adjust the values manually.

Tags: