Skip to main content


ESPCLOCK4 - Reduce operating current by removing UART module

The ESP32 Mini uses a CP2104 UART module to drive the USB port.  The CP2104 is configured in self-powered mode, which means that even if nothing is plugged into the USB port and the board is powered by a 3.3V source, it is still drawing ~100uA of current. I wanted to see the effect of removing this module on the power consumption of my test circuit. Removing the UART module means losing access to the USB port. However, I should still be able to program it using a standard FTDI programmer, which I wanted to verify. So I took out the same FTDI programmer that was used for programming the ESP8266, and built a custom holder for the ESP32 Mini. I started with the same connections as used with the ESP8266: ESP32 VIN <-> FTDI 3.3V ESP32 GND <-> FTDI GND ESP32 TX <-> FTDI RX ESP32 RX <-> FTDI TX However, I could not get it to work. After some fiddling around, I discovered I could only get it to work by connecting RX - RX and TX - TX. Not sure why. But now I am confiden

Arduino control of PTX4 remote

I wanted to control the opening and closing of my front gate using the ESP8266. The gate uses a standard PTX4 remote, which is readily available at many hardware stores. To my surprise, I couldn't find a hardware module that I can buy off-the-shelf and interface with the ESP8266. So I bought an extra remote, paired it with the gate receiver and proceeded to take it apart to see how I can use the circuitry inside. SW4 is the button I press to open/close the gate. Points (1) and (2) are the junctions I need to short using a relay to simulate a button press. I measured point (1) to be 12V, so I need a 12V relay for this to work. The one that's readily available to me is SY4032 . Since the operating voltage is 12V, I also need to use a MOSFET (the good ol' 2N7000) to drive the relay. The gate pin needs to be grounded with a resistor, otherwise a spurious signal might be sent to the relay when the MCU is first powered on. Another thing I did was to get rid of the A23 battery by

Link dump: Auto-ranging current measuring instrument for IoT devices

With more research, I am beginning to understand more about burden voltage, the difficulty of measuring the dynamic power draw of a circuit with a wide range of current consumption (a few uA all the way to hundreds of mA), as well as the limitations of the LTC4150 coulomb counter in dealing with this. Here are a list of devices that are designed to do just that, and that are not too expensive (<$200). I hope to acquire one of them to tinker with in the future: Power Profiler Kit 2 RocketLogger BattLab-One mikroAmpMeter

Update: Line adapter for Ozito Blade Trimmer

An update on using ordinary trimmer line for the Ozito battery trimmer. I finally found a super easy and robust way to do so. No need for any  3D-printed adaptor , which is simply not strong enough to withstand the amount of force we are dealing with. You should be able to start immediately with common tools that you already have. These are all the material/tools you need: 2.4mm trimmer line 0.75mm wire (just use any thin wire you have lying around) flat nose plier cutter (or scissors, to cut the trimmer line) Cut off a length of trimmer line about 18cm long and fold in the middle. Cut off a length of wire about 8cm long and wrap around the trimmer line near the top, creating a loop. The wrap should be tight enough to just stop the trimmer lines from sliding, but you should still be able to reduce the size of the loop by pulling on the ends of the line. The orientation of the wire wrap as shown in the photo above is important, because it prevents the wire from slipping off during opera

RBX - Robotics Brick Extension

RBX is a project that I have been working on for some time now. It is a robotics kit designed for young tinkerers. It consists of a set of Lego-compatible "bricks" made with common components, such as LED, pushbutton, servo, motor etc. The brick housings are printed using a 3D printer. The components are hooked up to a microcontroller via standardized "ports". Programming is done via a variant of Javascript (a port of Duktape ) on a browser-based IDE. I started the project because I found that block-based programming environment such as Lego Mindstorm are a little too simple for older kids (8 - 12 year old), yet the long compile-run cycle of Arduino is not suitable for tinkering and quick prototyping. Something that sits in the middle is needed. On the hardware side, one of the first obstacles for a child trying to break into microcontroller programming is hooking up the desired circuitry on a breadboard. Anything beyond the the introductory "Hello World"

ESPCLOCK4 - Monitoring supply voltage via ADC

To monitor the battery pack voltage (4 x AA; max ~6V), I hooked up GPIO32 (maps to ADC1_CHANNEL_4) to a voltage divider consisting of 2 x 10K resistors. This divides the max voltage in half, giving us 3V, which is clear of the max 3.3V input voltage accepted by the ESP32 ADC pins. To initialize the ADC channel so that it can be used by ULP code, this function is used: void init_adc () { adc1_config_width(ADC_WIDTH_BIT_12); adc1_config_channel_atten(ADC1_CHANNEL_4, ADC_ATTEN_DB_11); adc1_ulp_enable(); } I created 2 new RTC_SLOW_MEM variables: enum { ... VDD_ADC, // Supply voltage measured by ADC VDD_LOW, // Low voltage threshold } The ADC reading ranges from 0 to 4095 in a slightly non-linear mapping, so I use this code to figure out the right ADC value for the low voltage threshold for the battery pack (target: 1.05V x 4 = 4.2V). #define SUPPLY_VLOW (1050*4) // 4 x 1.05V // Map given ADC value to corresponding voltage uint32_t adc_to_voltage ( uin

ESPCLOCK4 - A Simpler Reset Module

In ESPCLOCK3, the following reset circuitry was used: This generates a short low pulse for the RST pin on the ESP8266 even if the switch is held down, so that the program can read the switch pin after reset. If it it found that the switch is still held down, it can perform a factory reset. In the ESPCLOCK4, I wanted to try a software-only approach with the ULP. The main idea is the ULP will check the switch (with a little software debounce processing). If it finds the switch depressed, it will wake the main processor, which will then perform a software reset.  This means we will only need a single pushbutton, with one end connected to an input pin (pulled up), and the other end connected to GND. No need for additional resistors/capacitors. I connect the reset button to GPIO4/GND, and add the following definitions: #define RESETBTN_PIN RTCIO_GPIO4_CHANNEL #define RESETBTN_PIN_GPIO GPIO_NUM_4 #define WAKE_RESET_BUTTON 1 The following code is added to init_gpio()