logo elektroda
logo elektroda
X
logo elektroda

[ESP32] How to change Sonoff THR320D firmware? Flashing Tasmota. Where is GPIO0?

p.kaczmarek2  Cool? (+3)
Sonoff THR320D thermostat with a display showing 23.8°C.
Some time ago I showed the Sonoff THR320D thermostat with display and presented the possibilities of the eWeLink application. This time I will continue discussing this product, but here I will focus on its interior and on changing its firmware to Tasmota, so as to completely free it from the cloud and pair it with Home Assistant on our terms.

Previous topic:
[ESP32] Thermostat with display and WiFi - Sonoff THR320D - eWeLink application

Information about purchasing the product is in the previous topic, so let's start with the inside.
THR320D interior
This product is distinguished by its solid construction. There are no breakable hooks. Unscrew the screws:
Back cover of the Sonoff THR320D thermostat on a wooden surface. Sonoff THR320D thermostat case lying on a wooden surface.
At first glance it's not that bad, there are some protections at the input, there is even a varistor, a filter capacitor, you can also see a relay, a programming connector and a small transformer with a characteristic Y capacitor, i.e. there is a flyback power supply inside..
Interior of a disassembled Sonoff THR320D thermostat with visible electronic components. Interior of the Sonoff THR320D device with visible PCB and electronic components.
There is no WiFi module inside, ESP32 is located directly on the PCB, you can see the flash memory right next to it:
Interior of the Sonoff THR320D thermostat showing the PCB.
The PCB can be removed and we will see the display controller and the WiFi antenna:
Sonoff THR320D circuit board with TM1621B chip. Image of the interior of the Sonoff THR320D thermostat showing the PCB and casing.
The display supports TM1621:
Documentation page for the TM1621 LCD driver from Titan Micro Electronics. Pin diagram of the TM1621 LCD driver from Titan Micro Electronics. Diagram of the TM1621 LCD driver by Titan Micro Electronics
We also see details of the power supply section and the LP3667 controller:
Close-up of the Sonoff THR320D thermostat PCB.
A simplified diagram of such a converter:
Schematic diagram of a flyback converter with LP3667
In the corner I also see a step down converter generating 3.3V for ESP, you can also tell it by the presence of a choke, by the way, it's interesting that they put so many ceramic capacitors there:
PCB of Sonoff THR320D thermostat with TM1621B chip. Sonoff THR320D circuit board with visible electronic components
The already mentioned WiFi antenna:
Interior of the Sonoff THR320D thermostat casing with visible components.
ESP:
Close-up of the PCB from the Sonoff THR320D thermostat with visible electronic components.
The photo above also shows programming pads, but there are only 4...

Firmware change
You need to start with the fact that IO0 is located on the button, so we solder 4 wires, not 5. As standard, a USB to UART converter (RX and TX) and ground and power supply (3.3V). To load the firmwarwe, first press the button and then connect the programmer's power supply so that IO0 is at low level while the device is booting.
Then you can upload Tasmota, e.g. using the online installer:
How to easily install Tasmota - online installer tasmota.github.io/install via a web browser
However, I used esptool myself:
Windows console with esptool program running for ESP32. Console with firmware loading process on ESP32. Console output showing the flashing process of an ESP32 chip using esptool.
The THR320D template is available online:
{"NAME":"Sonoff THR320D","GPIO":[32,0,0,0,226,9280,0,0,0,321,0,576,320,9184,9216,9312,0,0,9313,9248,0,1,0,3840,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}

GPIO roles:
- GPIO00 - Button 1
- GPIO04 - Relay 3
- GPIO05 - TM1621 DAT
- GPIO13 - Led_i 2
- GPIO15 - LedLinks
- GPIO16 - Led_i 1
- GPIO17 - TM1621 CS
- GPIO18 - TM1621 WR
- GPIO19 - Relay_b 1
- GPIO22 - Relay_b 2
- GPIO23 - TM1621 RD
- GPIO27 - Output Hi
Template activation:
Screenshot of Tasmota interface on ESP32-DevKit
Then you need to select the roles for the GPIO sensors, because there may be different sensors, I only checked with DS18B20:
Screenshot of the Tasmota configuration interface for Sonoff THR320D.
Result:
Tasmota user interface with DS18B20 temperature on a Sonoff THR320D thermostat
Of course, the display still works, the template takes into account its operation, although now it no longer displays anything about humidity like the original firmware:
Sonoff THR320D thermostat displaying temperature 34.2°C Sonoff THR320D thermostat with display showing a temperature of 35.2°C.
And the temperature in the photo is high because I heated the sensor with a lamp to test:
Close-up of a hand holding a wire next to an LED strip.
Everything seems to be working.

Summary
I already mentioned it in the previous part, but I highly praise all IoT products that are able to operate completely without WiFi, and the ability to read the current temperature from this display without reaching for the phone is certainly a step in the right direction. The button on the housing also increases the possibility of "physical" control, although we will not change the schedules, but it is not that important.
Of course, uploading Tasmota is only the first step, you still need to configure Home Assistant, but that shouldn't be a problem. Automatic HASS Discovery from Tasmota alone should do the trick.
In one of the next topics, I plan to discuss how we can use our Sonoff THR320D together with HA, e.g. to control heating, but that will come later...
To sum up - I recommend this product. Has anyone reading this already used it?

About Author
p.kaczmarek2
p.kaczmarek2 wrote 12420 posts with rating 10286 , helped 585 times. Been with us since 2014 year.

Comments

khoam 01 Nov 2023 15:35

You can try to install the ESPHome firmware according to the template: https://devices.esphome.io/devices/Sonoff-THR320D Then there should also be a humidity measurement. [Read more]

p.kaczmarek2 01 Nov 2023 16:04

In this particular case, I still have the DS18B20 probe connected, so it probably won't measure humidity, I was more referring to the fact that the original firmware displayed the placeholder values... [Read more]

szczukot 18 Apr 2024 11:32

https://obrazki.elektroda.pl/8738639400_1713432787_thumb.jpg Some photos from the Internet display different data. Is this an error or is it actually possible? [Read more]

p.kaczmarek2 18 Apr 2024 12:42

Your photo shows a slightly different product, viz POWR316D , which, by the way, I have already discussed: [ESP32] Sonoff POWR316D energy meter with display - firmware change [Read more]

szczukot 18 Apr 2024 18:45

Well, that`s all clear. Many sellers confuse them, give a photo of one and sell the other ;) [Read more]

HellG 16 Aug 2024 15:04

I would like to connect sensors via I2C to the THR320D. Do you think this is possible? Is there a spare GPIO that I could use or do I need to sacrifice e.g. one of the relays? [Read more]

HellG 23 Aug 2024 16:27

Hi, I digged a little bit deeper and found out, that PIN3 of the sensor connector has a measuring pad marked with RX1 in this picture https://obrazki.elektroda.pl/1409760600_1695907567.jpg (partially... [Read more]

p.kaczmarek2 23 Aug 2024 20:18

What kind of sensor would you like to connect? I'd suggest to choose the resistors for the sensor you have. For example, here is how a DHT11 connection should look like: https://obrazki.elektr... [Read more]

HellG 23 Aug 2024 21:07

I want to connect several sensors via I2C, that’s why I need an additional GPIO. [Read more]

p.kaczmarek2 23 Aug 2024 22:16

Both I2C lines will require pull-up resistors, here is some random sample from the web: https://obrazki.elektroda.pl/9945869600_1724444152_thumb.jpg @ElektrodaBOT which pull up resistor values... [Read more]

ElektrodaBot 23 Aug 2024 22:20

Direct Answer to the User's Question For I2C communication, typical pull-up resistor values range from 1kΩ to 10kΩ. The most commonly used values are often in the 2.2kΩ to 4.7kΩ range. However, the optimal... [Read more]

%}