20161005_005107s

Sonoff TH10 & TH16: sensors, displays, actuators,…

Itead Studio keep on creating interesting products for the hacker community. A few weeks ago a new version of the already classic Sonoff TH came to life. This new version comes in two flavours: the Sonoff TH10 and TH16 and you can buy them at Aliexpress: Sonoff TH 10A/16A Temperature And Humidity Monitoring WiFi Smart Switch.

In this article I will briefly talk about what’s new in this device to quickly go to explore one of those novelties: it’s external interface.

What’s new?

The first thing I noticed is it’s size. The new Sonoff TH10 (or TH16, they are the same except for the relay) It’s a lot bigger than the old Sonoff TH. The old case is 87.5×38.8×23.5mm while the new one is 114×51.6×32.2mm. It’s bigger in every dimension and it they were cubes (they are not) the new Sonoff would be 2.37 times bigger in volume!!

"Classic" Sonoff TH (right) versus the new Sonoff TH10 (left). Does size matter?

“Classic” Sonoff TH (right) versus the new Sonoff TH10 (left). Does size matter?

Maybe we can find an explanation for this growth in the inside but my first though is that one of the good things about the Sonoff was it’s relatively small size (compared to it’s competitor by Electrodragon, for instance).

In the inside we have a completely different PCB layout. The PCB is also 1.82 times bigger (64.8×33.9mm versus 88.9x45mm) but it certainly breathes. Having all the connectors on the same side reduces trace distance and improves the separation between high and low voltage sides of the board. High voltage traces are a lot thicker and also have an extra of tin on top. All in all it looks like they have tried to answer people concerns about the safety of the device. But they still don’t have the CE mark (actually the CE mark in the case means “China Export”, check for the right Conformité Européene mark).

UPDATE 2016/10/08: Itead has contacted me to say that they are working on the CE certification and they expect to have it in no more than a month.

UPDATE 2016/10/20: Itead has contacted me again to communicate that some of their Sonoff line has now officially the CE certification (document of the CE certificate for new Sonoff products). The certification covers Sonoff TH10 and TH16 and also Sonoff DUAL and POW. They have also been certified as RoHS compliant.

Now the same comparison from the inside...

Now the same comparison from the inside…

The only difference between the Sonoff TH10 and TH16 is the relay. The TH10 uses a Hui Ke HK3FF-DC5V-SHG subminiature high power relay rated 10A while the TH16 uses a Honfa HF152F-005-1HTQ(104). The old Sonoff TH uses a HKE HRS3FNH-S-DC5V-A. They are all driven with GPIO12 through a transistor labeled 12W59. Don’t know enough about relays to know which one is better and why, what I know that none of them is a SPDT relay actually the Hul Ke is a SPDT relay, but the NC pole is not exposed and connected to the input line…. So crossover switching is still not possible

Then there are these new push terminals. I guess they are easy to use while sticking the cable in the hole. Also the designers have added two neutral and two ground terminals so the user does not need a terminal bar to power the device and the load. There is also a very welcome F20AL250V 20A fuse.

The new push terminals and the fuse in the Sonoff TH10

The new push terminals and the fuse in the Sonoff TH10

The user interface has also improved with a new LED that can be driven with GPIO13 (the other one is tied to GPIO12, so it follows the relay state). The enclosure is thin enough so the LEDs are visible through it. Also the new button is much better in terms of usability and aesthetic pleasure. And finally there is the new external interface… which I will explore in the next sections.

The new interface

Using an audio jack as an interface is quite common. I used it in my Smartmeter pulse counter years ago. It’s also good news for anyone willing to add their own sensors. But it has two caveats: first they have decided to go for a 2.5mm jack, which is not as common as the 3.5mm one. Harder to find and more expensive. Second, even thou they are using a 4 channels jack (or TRRS for tip-ring-ring-sleeve) they are only using 3 of them for 3V3, GND and GPIO14. So what happened to the fourth?

Named pads, headers and test points in the Sonoff TH10 board

Named pads, headers and test points in the Sonoff TH10 board

Well as you can see in the image the engineering team at Itead Studio actually thought about it. Only it’s not enabled. In the image above you can see that GPIO14 is tied to the jack tip with a 0Ohm resitor and a 5KOhm pull-up (actually two 10k in parallel). Side by side to this 0Ohm resistor there is a pad ready to connect the first ring in the jack to GPIO4 and another one to add a pull-up too. So you just have to solder a 0Ohm SMD resistor to that pad (the one with the GPIO4 label) to bring out a second IO to connect the sensor…

I don't have 0603 SMD parts (too small for me) but a 0805 resistor fits just fine.

I don’t have 0603 SMD parts (too small for me) but a 0805 resistor fits just fine.

Have you read pull-up resistors? Me too. Do you know any 2 wire protocol that needs pull-ups? Me too!! So now we have a whole bunch of digital sensors we can attach to the Sonoff TH10/TH16.

A zillion of sensors, actuators, displays…

Itead Studio sells two sensors for the Sonoff TH10/TH16: an AMD2301 temperature and humidity sensor (DHT22 compatible) and a DS18B20 waterproof temperature sensor.

AM2301 and DS18B20 sensors for the Sonoff TH10/TH16

Look at the size of that AM2301 enclosure!

But now we can connect any digital device that requires one or two GPIO pins to drive it. And that includes I2C devices. We still have a limitation: the interface has a 3V3 channel, so we won’t be able to power 5V sensors with it… unless we hack that too (cut that thick trace going to the “3V3 / SLEEVE” point and solder a wire to any of the 5V test points in the image).

First I worked my testing cable. A 2.5mm TRRS jack [Aliexpress] to 4-channels Dupont connector. You can also purchase a convenient 2.5mm jack to screw terminal block for prototyping.

Wooden clothes pins rocks

Sometime ago a friend told me I should always carry a wooden clothes pin with me…

Testing cable for the Sonoff TH10 sensor interface

Now ready to test sensors…

So let’s start playing! A BMP085 [Aliexpress] pressure sensor, a HC-SR04 [Aliexpress] ultrasonic range module, a PIR [Aliexpress], an I2C LED display [Aliexpress] or an nice little 0.96″ I2C OLED display [Aliexpress]…

BMP085 with the Sonoff TH10/TH16

A BMP085 sensor using I2C protocol

HC-SR04 ultrasonic range module with the Sonoff TH10/TH16

The HC-SR04 ultrasonic range module needs two GPIOs to drive the trigger and echo pins, but it only works with 5V.

Using a PIR with the Sonoff TH10/TH16

This PIR works great with 3V3 and can be driven with just one GPIO. This is actually quite useful for a light switch…

I2C LED display with the Sonoff TH10/TH16

You will need 5V to drive this I2C LED display…

An I2C OLED display with the Sonoff TH10/TH16

But this 0.96″ I2C OLED is a perfect match!

What else… well, almost anything digital out there: displays, humidity sensors, distance sensors, touch sensors, encoders, magnetometers, gyroscopes, accelerometers, tilt switches, reed switches, real time clocks,… and also servos, external relays, buzzers, and WS2812 strips!

Sensors and actuators for the Sonoff TH10/TH16

A zillion of sensors AND actuators

Flashing it

Last note before letting you go to find something to attach to your new Sonoff TH10/TH16. Tech people at Itead Studio know some of their clients will open the product enclosure and own the device by flashing their own firmware into it. They even use it as an advertising slogan: “For hackers, Sonoff Pow is another exciting board.”. So go ahead. The programming header is labelled and goes like this (check the picture above): VCC, RX, TX, GND. The button is tied to GPIO0 so just press it while powering the board and you are in flash mode.

If you don’t know what to flash give a try to the Espurna firmware. It’s a work in progress but will soon support I2C devices or two relays (for the Electrodragon or the Sonoff Dual) in different configuration modes including crossover switching.

By the way: I hope I will have a Sonoff Pow soon in my hands…

CC BY-SA 4.0 Sonoff TH10 & TH16: sensors, displays, actuators,… by Tinkerman is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

42 thoughts on “Sonoff TH10 & TH16: sensors, displays, actuators,…

  1. Pingback: Tinkerman, Sonoff | It's Not Available

  2. Pingback: Tinkering with the Sonoff TH (by Tinkerman) | esp8266hints

  3. Fabien

    Thank you. I just recieve my board today and it was very simple to upload new firmware with you post. But I can’t compile espruma. I think you have a custom version of platformio.

    Reply
    1. Xose Pérez Post author

      Yes you are right. I have a custom platformio.ini file that suports inheritance. There is a PR about it but I have no idea if or when it will be merged (https://github.com/platformio/platformio/pull/790).
      Since you are not the first one to face this problem I have updated the file in the repo with a compatible one. Please update your repo copy before trying again.
      And thanks for your interest in the firmware.

      Reply
    1. Xose Pérez Post author

      The old Sonoff exposes GPIO14 in the “programming” header. It’s the pin further from the button. So the answer is yes. The one I tested here works with 3V3 and it’s a perfect match for the job.

      Reply
        1. Xose Pérez Post author

          I don’t think so. As far as I know there are no commercially available PIR sensors with a 2.5mm jack interface. Itead Studio only sells AM2301 and DS18B20 sensors for their TH series.

          Reply
    1. Xose Pérez Post author

      Have not tried it myself but I’d bet you can use any of these sensors with ESPEasy as long as you can define what GPIOs there are attached to.

      Reply
    1. Xose Pérez Post author

      Yes. I have done it with a Sonoff Basic in the past. You’d need thin copper and good hand control. But I’m working on an adaptor for the TH series that would use a ADC121 with I2C interface to use an external analog CT. Will write about that soon.

      Reply
  4. jerrynorbury

    Would it be normal (usual) to replace the plastic case it’s supplied in with a waterproof enclosure OR would you normally try find a waterproof enclosure big enough to put it all in?

    Reply
    1. Xose Pérez Post author

      Hi. Assuming you will use a good waterproof enclosure I can’t really see a reason to keep the original one. Please make sure water never ever gets in.

      Reply
  5. Marco van Veelen

    Hi,

    I have a regular Sonoff which I use to switch a light. I was wondering if (and how, because I can’t find anything on Google) I could add a LUX sensor (BH1750) to it. Or maybe I need another Sonoff? Can you give me some pointers?

    Reply
  6. Miguel

    Sonoff TH10, do it work with 2 simultaneous sensors??? (example LUX sensor + PIR sensor)

    Reply
    1. Xose Pérez Post author

      The TH10 esposes 1 ditigal GPIO on the 2.5mm jack (2 if you do the little hack I talk about in the post). So if your sensors use 1 digital pin each and work at 3V3 yes. Or if your sensors are I2C and you can daisy chain them it will also be possible.

      Reply
  7. Charis

    Hello Xose! Can i convert a sonoff to PIR sensor using your firmware? This is very interesting capability, if for example we could use one sonoff and one HC-SR501 to convert a PIR sensor. Thanks.

    Reply
    1. Xose Pérez Post author

      You can easily connect a PIR sensor making it behave like a switch button, everytime it goes on or off it will toggle the relay.

          #define BUTTON2_PIN         14
          #define BUTTON2_RELAY       1
          #define BUTTON2_MODE        BUTTON_SWITCH
      

      Problems you may face: most PIRs work at 5V and up but your Sonoff uses 3V3 logic so you need to 1) feed 5V to the PIR from before the ASM1117 and 2) add so kind of logic shifter. The second point might not be necessary. It’s not well documented but ESP8266 “might” tolerate 5V so maybe a resistor in series will do.

      Reply
  8. Michelmk2

    Hello all, as I m not an expert 🙂 is it possible to use a 5v battery to power up the TH16 ? The goal is to have an stand alone wifi temp sensor
    Many Thanks
    Michel

    Reply
    1. Xose Pérez Post author

      It should be possible, but if you plan to power the board through the programming header your battery should provide 3.6V max according to ESP8266 specs, so you might need some kind of LDO between the battery and the board. Another option is to use 5V wiring it to some of the exposed pads (see the picture with the pads and their connection). BUt the main issue here would be power consumption. Your best bet is to use deep sleep mode (actually powering off the board) with GPIO16 tied to reset to bring it up again after a certain amount of time. But GPIO16 is not brought out so you will have to solder a thin wire to the IC leg (good luck!).

      Reply
  9. joe

    I can’t be the only fool who figured out the hard way that because Ground uses Ring 2, if you try to use a “normal” 3 pin “headphone” connector, it will short with the 3.3v sleeve.

    Reply
    1. Xose Pérez Post author

      Wow, it has to be a 4 channels connector (TRRS or stereo&mic). Was the damage important?

      Reply
    2. David

      I have a 4 pin headphone jack and a DS18B20 sensor.
      Red is 3.3V, black is ground and yellow is data with my sensor
      What is the “pinout” for the headphone connector?

      Keep up the good work!

      Reply
      1. Xose Pérez Post author

        You can check the pinout in the picture with the labels on it. For a TRRS connector (tip-ring-ring-sleeve) it’s GPIO14, GPIO4 (not connected), GND and 3V3.

        Reply
  10. Larry

    Hey Xose – I tried making a 15 meter long extension cable for the temperature sensor since my hot water heater is in the roof and i don’t want the th 16 up there. but it doesn’t work. Do you know if there is a length limit for an extension cord?

    Reply
    1. Xose Pérez Post author

      The DS18B20 sensors are very sensitive to cable length. Yes, there is a limit but I can’t really tell you where, but there are some very good articles about it on the Internet. Just google “ds18b20 cable length”, some people seem to fix the issue using a resistor, had not test it myself.

      Reply
  11. AW

    Noob here. My desire is to use the Sonoff TH10 only as a temperature monitor, and to send via wifi the temperature in a room. I figure I’ll just take a grounded extension cord, put the wires in the Sonoff, plug it in the wall, and use their Ewelink app. HOWEVER, what I would REALLY like is to have the Sonoff trigger an email alert if the temperature in the room exceeds a certain threshold. Is there a way to do this using Blynk WITHOUT the need for any soldering or hardware revising, as I have no such equipment? Thanks in advance.

    Reply
    1. Xose Pérez Post author

      Not sure if the stock app allows that. ESPurna does not either atm, but built-in blynk support is in the roadmap.

      Reply
    1. Xose Pérez Post author

      Hi!
      I would do it as a general counter, probably in a counter.ino module. Adding an interrupt is no big deal, just like you would do on a standard Arduino. Increment an counter in you main loop. You would problably want to aggregate the number of counts every minute or so and report them (mqtt, influxdb, websockets, domoticz). You can check the analog.ino module which is the simplest in ESPurna.

      BTW, that caudal meter works at 5V. Make sure you provide 5V.

      Reply

Leave a Reply (all comments are moderated, be patient)