Reworking the AI Thinker T5 – Part III

In the previous post, we did some simple, straightforward modifications to get the “Black board T5” working using the ESP8266 alone.  In this part, we’ll go over a very simple application to demonstrate that the ESP8266 is alive and kicking and will download a program as normal (in program mode) and will also run that program (Duh!) and communicate with the DHT11 temperature/humidity sensor.

But first, as I mentioned in Part-II, if you have (as I do) a 5v-only USB to serial converter, you’ll need to add a 5v-to-3v3 voltage converter for the TX and RX pins, otherwise there’s a good possibility that the magic smoke will escape from your ESP8266 module.  I’m using the tried and tested MOSFET conversion method, which uses a single, N-Channel MOSFET (and two resistors) in each line to do the conversion.  You can buy these as 4-way converters on eBay for about $1 each, but the circuit is so simple that I tend to throw mine together on odd scraps of stripboard whenever I need one. For the T5 board, there’s some hardware already available which makes the stripboard method even easier.

As you’ll have noticed, there’s a nice, 5-pin connector off to one side of the board which was apparently intended as a camera port.  There aren’tOLYMPUS DIGITAL CAMERA

too many details available on what camera, or what the intended use actually was, but the important point (for us) is that pin-1 on the connector is GND and pin-5 is 3v3, with the three middle pins now free (as we’ve already removed the STC QFP micro to which those pins were connected).  By a happy coincidence, we need just exactly that number of pins to attach our 5v-to-3v3 converter (TX, RX and 5v, in addition to the existing GND and 3v3).

I’m going to show you how I implemented this connection, but as always, there are several different options available to you and you should choose whichever one is the easiest or the best match to your particular circumstances.  Some of the options you might want to consider:-

  • Find a matching plug for the camera socket and use it.
  • Remove the camera socket and replace it with pins or flying leads.
  • Ignore the socket and solder flying leads directly to existing pads.
  • Butcher the socket, because we just enjoy inflicting damage on this board (insert mandatory evil chuckle here).

Of course, I chose the last option (but in the interests of completeness I should also mention that I removed the socket from the board first,

Nekkid camera socket

thinking that I would replace it with straight pins, before realizing that that was extra work and not so much fun!).  I should also mention that removing the socket is quite difficult, so I wouldn’t recommend that particular option.  Note the odd silkscreen pin descriptions which were hidden under the socket.  It seems that “CG”, “CT”, “CR” and “CV” probably stand for “Camera Ground”, “Camera Transmit”, “Camera Receive” and “Camera Volts”, respectively.

Anyway,  after consuming about twenty odd cups of tea, I had a rare flash of inspiration (in addition to the ten odd flushes) and realized that  I could just snip the top and side plastic shielding away from the existing plug and solder the chunk of stripboard with the voltage converter circuit directly to the pins (you can do this without removing the socket from the board).  Then, on the reverse side of the T5 PCB, I simply jumpered the TX and RX pins for the ESP8266 to the “WIFI_TX” and “WIFI_RX” jumper pins (described in Part-II).  The advantages of this method are, further sadistic butchery of the T5, no flying leads and the converter board is always attached to the place we want it (rather than having to search through piles of junk other projects to find it each time we want to reprogram the board).



The circuit for the MOSFET voltage converter can easily be found on-line by doing an Oogleg search for “MOSFET voltage level converter”.  Neither the MOSFET type nor resistor values are particularly critical in this particular application.

Okay, so we now have a board which we can program, so we need to write some software to drive it.  I’m using the Arduino-ESP core, simply because I find that it works reliably at fitting programs into the limited memory of the ESP8266 without too much faffing around on my part.  I’m not an Arduino guy (don’t own any boards, or chips) and I’m definitely not keen on the Arduino IDE, but the rest of the set up just works reliably for programming ESP8266 modules.

Here’s some code which is just a tiny bit longer than the absolute minimum to get you going with your newly modified T5 board:-

* $Id: DHT_Test.ino,v 1.3 2015/12/11 02:09:02 anoncvs Exp $
* Test program for the AI Thinker "Black board T5", after
* modification to remove the 8051-based QFP micro and wire
* the DHT11 sensor and blue LED directly to the ESP8266.
#include "DHT.h" // We're using the Adafruit version.

// DHT dht;
#define LDELAY 10 * 1000 // Loop delay (10 seconds).
#define DHTPIN 2 // DHT11 sensor on GPIO2.
ADC_MODE(ADC_VCC); // Required for correct operation of 3v3 measurement.
int BLED = 5; // Our WiFi debug LED is on GPIO5.
float temperature = 0;
float humidity = 0;

DHT dht(DHTPIN, DHT11, 15);

* Turn on the blue WiFi debug LED for a short
* flash. Note that on the T5 board the LED is
* driven by a low-side switch.
void BFlash() {
digitalWrite(BLED, LOW);
digitalWrite(BLED, HIGH);

* Try to get a valid reading from the DHT11 sensor
* (not always easy).
void getSensorData() {
temperature = dht.readTemperature();
humidity = dht.readHumidity();
while ((isnan(temperature) || isnan(humidity))
|| (temperature == 0 && humidity == 0)) {
temperature = dht.readTemperature();
humidity = dht.readHumidity();

void setup() {
delay(500); // Pause for boot-up crap.
pinMode(BLED, OUTPUT); // Ensure our blue LED driver pin is an output.
Serial.println(“Status\tHumidity (%)\tTemperature (C)”);

void loop() {
float vdd = ESP.getVcc() / 1000.0;


Serial.print(“Temperature: “);
Serial.print(“c – Humidity: “);
Serial.print(“% – Voltage: “);
Serial.println(“v “);

Note that this code uses the Adafruit DHT library (please send them some of your custom  — if you happen to live on a favoured continent, you can get an Adafruit ESP8266 “Huzzah” for just about the same as you’d spend on the POJ T5 board).  This simple program doesn’t use the wireless capability of the ESP8266 at all; it just sits in a loop and squirts the temperature and humidity readings from the sensor out to the serial port every ten seconds (it also displays the current 3v3 line voltage as an added extra).

Because the T5 uses the DHT11, there’s also a while() loop in the getSensorData() function which will basically discard the (fairly frequent) bad readings returned by this particular sensor.

While we’re on the subject of the DHT11, you’ll notice when you fire up your board and start using it, that the sensor starts to read high after a few minutes.  This is because of the heat generated by the ESP8266 (which the DHT11, by a poor design choice, is sitting right next to).  You can alleviate the effects somewhat by lifting the DHT11 from its flat-on-the-board position to standing vertically, instead.  It will still read a little high (because this simple program doesn’t put the ESP8266 to sleep), but it will be noticeably better than before.

Finally, again, because the ESP8266 doesn’t sleep with this simple program and because the red, power LED is always on, the batteries will last barely 24-hours if you leave your module switched on permanently.  We’ll do something about that next time.



One thought on “Reworking the AI Thinker T5 – Part III

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s