Please see Part 1 of this series to get up to speed on what we’ve already done (perhaps that should actually be “undone”) to get to this point.
Okay, so we’ve had our fun with the craft knife, got rid of the QFP chip and disabled the pesky beeper in the process, so what are the next steps. My goal is to get something working in the shortest number of steps possible. What I’d like to do is to get the DHT11 sensor working with the ESP8266 as a basic functional test and go on from there to add some of the original hardware options (LEDs, switches, etc.) back in, but again, controlled directly by the ESP8266. I’m still (as I write this) on the fence about whether to add the beeper and the relay to that list.
The beeper came very close to being (deliberately) crushed to a messy, splintering death with a pair of pliers and I’m reluctant to give it any sort of second chance. I can see that it might possibly be useful in some situations (locator beacon or low battery emergency alert), but for now I’ve had quite enough of it.
The relay, though …I really don’t want to encourage anyone to connect mains to this board as it stands. There’s not enough physical clearance between the low voltage and high voltage tracks on the board, no isolating slot and, in addition, there are no mounting holes of any sort on the PCB (mains voltage on a loose board rattling around all over the shop; yuk!). Yup, you could use it for driving a low voltage pump, or something along those lines, but most of us would probably rather use a MOSFET for something like that anyway, so at the moment the relay is slated for removal (also because I want to use the pads to mount a diode for 5v input …but more on that later).
Okay, so back to the task in hand. What do we need to do to get the DHT11 working with the ESP8266? There are basically three things:-
- A connection from the DHT11 data line to an ESP8266 GPIO pin.
- 3v3 enabled to the ESP8266.
- Access to the ESP8266 serial port to load new firmware.
As it turns out, all three are fairly easy to implement, although the first two are rather fiddly.
short jumper from it to pin-3 on the DHT11 (the pull-up resistor is there already).
The power for the ESP8266 goes through a P-channel MOSFET (high-side switch), which was originally driven by pin-9 of the STC QFP chip. Because it’s a P-channel device, we know that it needs the gate to be driven low to switch on, so instead of
jumpering the 3v3 directly to the ESP8266, I’m going to jumper pin-9 (on the QFP pads) to pin-12, which is ground. This will switch the MOSFET on permanently, so whenever the board is powered on, the ESP8266 will receive power. It also allows us to easily modify the board in the future to add our own power control for the ESP (which could be something as simple and low tech as a 555 timer, or a microswitch on a door).
The last item on the list, the connections for in-circuit programming of the ESP8266, is already taken care of by the existing jumper block (visible in the photo above). First of all, the top jumper (with a blurry “GPIO0_”, or an upside-down “CON2”) is the standard GPIO0-jumper-to-program (so throw on a jumper to program and take it off to run normally). The next jumper down (“WIFI_T” or “CON5”) is the TX pin, the one below that (“WIFI_G” or “CON6”) is a GND pin and the bottom one (“WIFI_R” or “CON7”) is the RX pin. If you have USB-to-Serial converter which has 3v3 outputs, you’re all set. Connect TX, RX and GND to the left-hand pins of the jumper block (the pins on the same side as the coloured LED “spoke”), add a jumper to the GPIO0 pins, power cycle the board and fire up esptool.
If you don’t have a 3v3 capable USB-to-Serial converter, you’ll need to do a little extra work to add a voltage converter; we’ll get to that in Part-III (along with the test program to run on your functional DHT11 sensor module).