• You've been granted Beta access to this site, allowing you to explore some of the new features while they're still under construction. More information can be found in the Beta forum.

SONOFF THR316 Origin

pete_c

Guru
Purchased a couple of SONOFF THR316 Origin devices for conversion to Tasmota 1-Wire networks and doing a pictorial here.


Shipping was around 30 days for these devices via USPS.

I am using 3 of these older models with combo Temperature and Humidity sensors. I am using first generation Sonoff Basic devices today for 4 DSXX sensors X 2. IE: have one in the basement and one in the attic. These two were originally using Espurna firmware and recently converted these to Tasmota.

I am surprised that the entire 1-wire library hasn't been imported over to the Tasmota firmware like the Arduino.

This is the GUI for the first Generation Sonoff Basic (R1) that I modded for use with the DSXXX temperature sensors. Hardware modifications involved cutting away the high voltage traces and soldering in to GPIO pins.

1-wire basement.jpg

SonoffR1.jpg
This is the GUI for first generation Sonoff DH (made for use with sensors and included a 120VAC relay)

SonoffTH-FirstGen.jpg

Sonoff TH10.jpg


These will be connected to DS18XXX sensors (4 each).


Purchased in bulk from Amazon.

Note that it is using a ESP32-D0WD-V3 rev.3 which is a combo WLAN and BT chip. There is no mention of BT on the label.

These are pictures of the new Sonoff DH316 with the ESP-DOWD-V3 rev.3 chip. Firmware includes many features.


sonoff-1.jpgSonoff-2.jpgSonoff-3.jpgSonoff-4.jpgSonoff-5.jpg

Remove 4 philips screws on back and open case. JTAG using following pins which are labeled GND, RXO, TXO, 3V3.

Note here that I have the barebones versions of the Sonoff 16 AMP THR316 Origin device.
There is also the 20 amp version and the display version and the POW version.

Sonoff-6.jpg
 
Last edited:

pete_c

Guru
Part II

I had to solder 4 pins to be able to JTAG the device.

Note: Tasmotizer does not work with ESP32 devices. You have a few choices to JTAG.

I tested the Tasmota GUI web page updater located here:


and it worked but I liked seeing it live so used the esptool.py command line methodology which I used to use many years ago.

First read the device:

Code:
/Downloads$ esptool.py flash_id
esptool.py v3.0
Found 2 serial ports
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: c0:49:ef:f6:ba:68
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

Erased Flash:

Code:
esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting.....
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: c0:49:ef:f6:ba:68
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 12.4s
Hard resetting via RTS pin...

Code:
esptool.py write_flash 0x0 tasmota32.factory.bin
esptool.py v3.0
Found 2 serial ports
Serial port /dev/ttyUSB0
Connecting......
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: c0:49:ef:f6:ba:68
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Compressed 2432912 bytes to 1639241...
Wrote 2432912 bytes (1639241 compressed) at 0x00000000 in 145.6 seconds (effective 133.6 kbit/s)...
Hash of data verified.


Leaving...
Hard resetting via RTS pin...

Configured WiFi on reboot.

Firmware updated via GUI to tasmota32-bluetooth.bin

Connect device to 120VAC. You will not see the GUI until you do this.

Used template here:


{"NAME":"Sonoff THR316","GPIO":[32,0,0,0,0,0,0,0,0,321,0,576,320,0,0,0,0,224,0,0,0,1,0,3840,0,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}

Final GUI looks like this: (no sensors connected yet)

THR316-1.jpg


Part III

Connecting sensors.

Device comes with an RJ-11 female port. I purchased an RJ-11 to 2.5mm 4 pole adapter for each of the two devices from Itead.
Also purchased a 2.5mm 4 pole to bare wires cable from Amazon.

51-L76BUPSL._SL1001_.jpg
 
Last edited:

pete_c

Guru
Part III (continued)

Sensor wiring image. I am using a VOM here to check the 4 wires coming from the 2.5mm audio jack to pigtail connections.

IE: device comes with an RJ-9 handset sized 4 pin jack and I purchased an RJ-9 to to 2.5mm female jack adapter.

I used to have some of the RJ-9 handset jacks and couldn't find them so ordered them and will make up a pigtail to connect to temperature sesnors. You cannot mix DS-18XX (up to four-six) and the combo Temperature / Humidity sensors (only 1)

Pull up resistor is built in to the device. From this point I can connect 4 DS18XX sensors in a star fashion (which I am already doing).

sensorwiring.jpg



Using Autoconfiguration:

autoconfig-1.jpg

autoconfig-2.jpg

Never seen or used this feature before. Now the interface shows two toggles because the THR316D has a second relay.

Removed the autoconfiguration and using template only.

autoconfig-3.jpg

autoconfig-4.jpg
 
Last edited:

pete_c

Guru
Part IV - Soldering 4 pins for JTAG and JTAGing device.

I removed the board and unplugged antenna cable before soldering 4 pins to board. Most difficult was plugging in antenna cable.

SonoffTH316-backofboardA.jpg

SonoffTH316-frontofboardA.jpg

SonoffTH316-JTAG-1a.jpg

SonoffTH316-JTAG-2a.jpg

SonoffTH316-JTAG-3a.jpg

Plug in USB stick while holding button in. This will put boot mode in to JTAG mode.

While uploading firmware via command line if it doesn't work switch the RX and TX wires. On my device I see RX and TX leds flash.
 

pete_c

Guru
Part V

Flashing second TH316. Note this is what I did and really do not know if this is the right way to do this. It worked for me.
Thinking I did this because initially I thought it would boot up to AP mode and it never did until I connected the device to 120VAC.

1 - Erase flash first

Code:
/home/pete/Downloads# esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting........
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: c0:49:ef:f6:ba:64
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 13.4s
Hard resetting via RTS pin...

2 - Write another bin. Factory binaries to be used for inital flashing using esptool

Code:
~/Downloads$ esptool.py --port /dev/ttyUSB0 write_flash 0x0 tasmota32-bluetooth.factory.bin
esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting.......
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: c0:49:ef:f6:ba:64
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Compressed 2567696 bytes to 1732516...
Wrote 2567696 bytes (1732516 compressed) at 0x00000000 in 153.9 seconds (effective 133.5 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...

3 - Disconnect JTAG cables. Back up configuration from first device.

4 - Connect 120VAC to device and plug it in.

5 - Using Android phone see the device in AP mode. Connect to it and configure your home WLAN AP and password. It will reboot on your network.

First boot shows the following:

SonoffTH316-FactoryBINBoot.jpg

6 - reassemble case and connected the 120VAC lines to it.

7 - updated firmware using OTA URL

8 - uploaded saved configuration from first device.
Name will be the same and it will have a different IP.

9 - done and it is a duplicate of the first one with a different IP and name.

THR316-B.jpg

What I do with all of my Tasmota devices via console.

1 - Timezone via the Tasmota timezone table (near Chicago here)
Backlog0 Timezone 99; TimeStd 0,1,11,1,2,-360; TimeDst 0,2,3,1,2,-300

2 - ntpserver (1,2,3)
16:40:53.163 CMD: ntpserver
16:40:53.170 MQT: stat/THR316-B/RESULT = {"NtpServer1":"192.168.244.129","NtpServer2":"nl.pool.ntp.org","NtpServer3":"pool.ntp.org"}

3 - set Longitude and Latitude

3 - add a second DNS server 1st is gateway

4 -
SetOption8 Show temperature in
0 = Celsius (default)
1 = Fahrenheit

5 - configure MQTT broker IP and MQTT name

Not using Bluetooth with this device which is similar to the Wyse outdoor wireless switch that I am using.
 
Last edited:

pete_c

Guru
Brewing Controller using the Sonoff TH and custom firmware.

Worlds easiest and cheapest to build brewing control. Supports mashing and fermentation. Combine multiple Bricks to control higher wattages or different functions (heating, cooling, pumps). Works with smartphone, iPad, Mac, & PC.


[youtube]
 

pete_c

Guru
Part VI

Connecting a DS18B20 Temperature sensor.

1 - Go to Configuration Template and configure GPIO25 for DS18X20 as seen in the following attached image.
GPIO25Configuration.jpg

2 - Go to Console.
Configure Temperature setting to Fahrenheit.
SetOption8
Show temperature in
0= Celsius (default)
1 = Fahrenheit

setoption8 1
3 - Connect 3 wires from RJ11 to DS18B20 cabled sensor. (used a VOM to check for ground, 3.3VDC and data line)

green ==> black
red ==> yellow
black ==> red

DS18B20.jpg

Part VII

Connecting an SI7021 combo Temperature and Humidity Sensor (using 4 wires).

Ordered a couple of these from Ebay for $8.00 each with free shipping.

SONOFF THS01 Temp and Humi Sensor Smart Home Work with TH Elite/TH Origin Switch
 
Last edited:
Top