Thursday, August 27, 2020

Tiny ESP32 board

Introduction

This project actually made me realise that the most important thing isn't what you're doing but it's why you're doing it. I've previously used a very simple ESP32 adaptor board from eBay, the one that only has the place for an ESP32, two buttons, two pull-up resistors, two pin-headers and a text "161015" on it. The reason I used exactly this board is that it doesn't have an integrated regulator circuitry which made it possible for me to accurately measure the current consumption of the ESP32 itself (including a very low current consumption of "deep sleep") without the effect of the voltage regulator. This board however isn't very good and at some point it wasn't very cheap either. For example the board lacks probably the most important thing a board can have, which is the required capacitor (the datasheet recommends 10uF) for the ESP32 module. Since this is a development board, the power is often connected with some random wires. In some cases the resistance of the wires is just too large and the ESP32 starts crashing because of low voltage situations. Additionally the board is large enough to have an usb connector and an optional regulator. Another important thing is the programming connector, which is also related to the previous post.

This is the reason why I decided to make my own adaptor board with blackjack and hookers.. I mean with an optional voltage regulator, USB connector and not one, but two programming connectors. I've also decided to add a stand-by LED, voltage monitoring chip and test-points for the power connections. Obviously all of the components are optional on this board except the ESP32 and the pin-headers. Additionally the original board had all the ESP32 pins connected to pin-headers. I've decided on the other hand to connect only those that can be easily used with the internal flash chip. For some reason I've also decided to make the PCB the same size as the eBay adaptor. I thought that it would be big enough for all the features and eventually it was.

The reason for the first sentence in this intro is that I originally thought I can just add all the features to this board, including the programmer part. Then I realised that I would just recreate the DEVKIT or similar development board. I also quickly realised that the board is simply too small to include all the parts and the programming connector which I really wanted to include. Eventually I realised that it really makes no sense to add everything to the board, since the main thing I want is a minimal development board that would have the programming connector and that I could use to measure the current consumption of the ESP32. For other purposes I could simply use ready made development boards. The USB connector and the integrated regulator is however such a nice feature that I've decided to keep that and simply add a "SMD solder blob" kind of switch. This way it's possible to completely separate the regulator from the ESP32 for accurate measurements. This approach is not as easy to use as a switch, but on the other hand it doesn't need to be "switched" often, it's very compact and has low resistance.

Schematic

The schematic is fairly simple, the main parts are the ESP32 and the pin-headers. Also there are the same two buttons and pull-up resistors, although there is an optional voltage monitoring chip instead of one of the resistors. Then there is the already mentioned USB connector and the voltage regulator. Lastly there are two programming connectors (50mil and 100mil), some test points and the stand-by LED. In reality the connectors could not fit properly on the board, so they are placed so that only one of them can be soldered at a time.

PCB

The board was made to very much mimic the original eBay board. The ESP32 module is on top, two pin-headers on sides and two buttons on the bottom of the board. The stand-by led is between the buttons. The bottom side has the voltage monitoring chip close to the EN pin of the ESP32, two programming connectors pretty much in the middle of the board and the USB port between the buttons. The voltage regulator is located under the left button and the test-points are scattered here and there. The test-points I use can be found from here. I've found them very useful and functional even if they're not very cheap and are a bit difficult to solder properly.

Result

I'm fairly satisfied with the result even though I haven't tested the voltage monitoring circuit yet. I've only used 100mils programming connector and it works nicely with the programmer I've made. Also the "SMD solder blob" -type switch works nicely, but I suppose the gap should be a little smaller. The only downside here is that the LED polarity is not marked as also in the previous project. I should probably do something about that at some point. Also I've used ready-made footprints for the buttons and the silkscreen markings are just huge compared to the buttons themselves. This can be seen from the pictures below. Also there seems to be some manufacturing error with the silkscreen on the top side of the PCB. I have reported this to JLCPCB, but it's not an issue here since this is just a development board and most of the problem is under the ESP32. Unfortunately I did not get any answer from JLCPCB regarding the root cause of the mistake. I was only given options to get new PCBs or get a discount for the next order. The link to public EasyEDA project can again be found here.


Final words

I suppose the only real downside of this project is that I should have done it much earlier. It would have made my life much easier. Luckily it's a hobby and no one's blaming me about it except myself.

Wednesday, August 26, 2020

Tiny ESP programmer

Introduction

I'm not going to explain here what ESP32 is in much detail. It is just some programmable module with WiFi capability. It can be programmed using the serial line and controlling few other pins of the module in a specific way. Originally I was programming these modules simply by entering programming mode by using buttons or just shorting the pins manually and then using some basic (CP2102 based) usb-serial adaptor. For some reason I was really against using a programmer. I really have no idea why. Later on I acquired an ESP-Prog programmer and would never go back to using buttons. This programmer however has some disadvantages that I really don't like. The biggest disadvantage is that this programmer does not have a case, so it's very easy to short something (yes, one could print a case using a 3d-printer, I don't have one). Lack of casing is not a problem by itself but usually the programmer is used with some kind of a development board or an incomplete project that also doesn't have a case. Having two devices without enclosure next to each other is already a serious risk. The other problem is that it's quite over-engineered and thus relatively large. Yes it does have JTAG support, but I haven't needed it yet and probably never will. There are also some switches included, both 50mil and 100mil IDC connectors and some other circuitry. Additionally there is a blue indicator light which in my opinion the worst choice for an indicator light. Don't get me wrong, I like bright and colorful lights.. but not as indicator lights. So I've decided to make a smaller version of this programmer using CH340C chip and encase it properly.

Electronics

The schematics of the board are quite simple. The main part is the CH340C chip because programming an ESP32 automatically requires RTS and DTR pins. CH340T or G would also work, but they would require an external crystal. Then there is a usb port and a programming port. Additionally there is a fuse and place for an optional 3V3 regulator. The official ESP-Prog has a DIP switch to select whether the programmer should provide 3V3 or 5V voltage to the programming connector. I really don't want to use DIP switches however, so I've decided to just make fixed versions, with the regulator and without. If the regulator is installed, the connector will provide 3V3 to the device. If the regulator is not installed, the power pin of the connector will be floating, since I don't really see the need for 5V on the connector. Then there is the circuitry required to connect the RTS and DTR signals to the IO0 and ENABLE pins on the ESP32. Eventually I also decided to include the smaller 50mil connector on the board. It's location on the board is a little inconvenient, but it's there just in case, since the connectors are quite expensive and apparently not so easily available.

Last things are power and activity LEDs. The power led is connected directly to the 5V input. The activity LEDs are however connected to TxD and RxD signals, since there is no dedicated output for the activity LEDs in the CH340C chip. While connecting the LEDs it's important to note the polarity of the signals, since the UART signals are high when idle. This means that the other pin of each activity LED should be connected to the 3V3 voltage. The problem is that the 3V3 regulator is optional as stated above. For this reason I've connected the LEDs to the "V3" pin of the CH340 chip. This pin is the output of the internal 3V3 regulator and it's most definitely acceptable to connect low power LEDs to this pin. Lastly it's also important to choose proper resistors for the LEDs so they will not be too bright.



Creating the board is actually very simple. The idea is taken from any other Chinese made programming device. The board is a narrow strip. On one side is the USB port and the 6-pin IDC connector on the other. On top of the board is the CH340 chip and the dual transistor. On the bottom is the voltage regulator and that's basically it. The reason for such design is simple. The whole board can be encased in transparent heat shrink tube, which is quite neat in my opinion. This physically isolates the device (mostly) and makes the enclosure very slim (compared to any 3d-printed case). Also LEDs and PCB markings can be seen through the heat shrink tube. The only downside is that the PCB is a bit slimmer than the distance between the pins of the IDC connector so it often ends up slightly crooked, but I guess it's fine. I've acquired 12.7mm wide 2:1 heat shrink tube for this purpose and it works well in my opinion.



Result

At least I am completely satisfied with the result. The only problem with the assembly is hand-soldering the SOT363 cased dual transistor. The footprint is however large enough in my opinion, so that is not the problem here. I haven't used the programmer much yet, but for now it seems to function as well as the official ESP-Prog programmer. The final result is shown in the picture below. The public EasyEDA project can be found here.




Final words

One thing that I would really like to make is a proper light box. It would probably improve the quality of the pictures that I'm going to use in this blog. That is however a project for another time.

Note: As far as I know this programmer should also work for the ESP8266, but I haven't tried it.

Internet of Crosstrainers, part 2

Introduction As mentioned in the original post here , there were some issues in the described implementation. I had some difficulties to fin...