Easy Operation of TV, AppleTV and Radio (Part III)

The Situation

In the first posts with topic Easy Operation of TV, AppleTV and Radio I showed you

Here I proudly present my third prototype which adds

  • + and – buttons to adjust the volume level of the receiver and
  • Up and Down buttons to switch between the predefined TV channels, CD/DVD tracks and radio stations.
  • It now uses four additional ADC buttons and
  • a recalculated resistor ladder where the voltages for all ADC buttons lay below 1,65 V, so that each button can trigger wakeup from DeepSleep and
  • a redesigned solution for charging the battery (now charging the battery while the ESP32C3 SoC is connected and also useable with USB Power Delivery chargers).

For this prototype I am using a Waveshare ESP32C3 SoC with an OnBoard RGB LED.

All this is put into a cool professional package.

New Features

Wakeup from DeepSleep

To save battery power the ESP32C3 SoC goes to DeepSleep 30 seconds after the last executed command.

Wakeup is triggered by pressing any of the ADC buttons. This works, because the button voltage for each button is “low”, which means less than about 1.65 V (1/2 of 3.3V).

When the ESP32C3 SoC is in DeepSleep mode you have to press the button twice: first to wake up from DeepSleep, second to execute the command. I would like to change this in a future version.

Battery Charging and Flashing the SoC

In this version the battery charging solution is redesigned.

  • The CC1 and CC2 pins of the USB socket are connected to GND with 5.1 kOhm resistors, so that modern USB Power Delivery chargers start charging with 5V.
  • The charging module now includes a P channel MOSFET and a Schottky diode, so that charging the battery is possible even while the ESP32C3 SoC is connected.
  • The D+ and D- pins of the USB socket are looped through to pin 19 and 18 of the ESP32C3 Supermini SoC to enable to flash and monitor the SoC while it stays inside the package and even when it is connected to the battery.

Details of the Solution

Hardware

Resistor Ladder for 10 ADC buttons connected to one GPIO

I have to control 10 buttons and I want to use only one GPIO for the ADC. Because each ADC button should be able to trigger the wakeup from DeepSleep the maximum voltage of all ADC buttons must be below 1.65V, which is half of the 3.3V Vcc. Now we have to divide the 1.65V into 9.5 intervals of 174 mV (it is 9.5 and not 10 intervals because the midpoint of the lowest interval is fixed at 0.0V).

With a resistor of 100 kOhm between Vcc and the ADC GPIO, the resistor ladder needs these resistor values between the buttons:

The actual values can be defined with a serial combination of Ra, Rb and Rc.

With these resistor values the midpoints, minimum and maximum voltages (in mV) of the ten ADC buttons are:

USB Socket for Battery Charging and Flashing the SoC

Because the ESP32C3 SoC and the battery are included in the package it is neccesary

  • to charge the battery and
  • to flash and monitor the SoC

in place.

For charging the battery we use a TP4056 lithium charger module with a USB-C socket. This module does not work correctly when the load is connected during charging. This can be fixed by adding a resistor, a P-channel MOSFET and a Schottky diode to the charging solution. Information on this modification can be found here.

An other problem is, that the charger module does not work with USB-C Power Delivery chargers, because the CC1 and CC2 lines of the USB-C socket are not connected. To enable the use of USB-C Power Delivery chargers CC1 and CC2 have to be connected to GND by 5.1 kOhm resistors.

If we want to flash (and monitor) the SoC through the USB-C socket we have to connect the D+ and D- lines of the USB-C socket with GPIO pins 19 and 18 of the Waveshare ESP32C3 SoC.

Software

Component elrebo-de/generic_button

For the new resistor ladder with ten ADC buttons the configuration of the underlying component espressif/button, which has a maximum of eight ADC buttons per channel must be changed to 10 in sdkconfig.default of the new example/av_rmt_example_with_10_adc_buttons of component elrebo-de/av_rmt:

// we need 10 ADC buttons (default is 8)
CONFIG_ADC_BUTTON_MAX_BUTTON_PER_CHANNEL=10

Component elrebo-de/rmt_ir

Until now the rmt_ir components used the transmitNecCommandFrame method to transmit normal, 32bit non-extended command frames to a Pioneer device. This approach did use the carrier frequency 38kHz of NEC devices instead of the correct carrier frequency 40kHz of Pioneer devices. Now the new methods transmitPioneerCommandFrame can be used not only for extended Pioneer command frames with 64 bits but also for “normal” command frames with 32 bits. Both now use the correct carrier frequency of 40kHz for Pioneer devices.

Component elrebo-de/av_rmt

To control the Volume + and – buttons, the two methods increaseVolume and decreaseVolume are implemented, which send the corresponding commands to the YAMAHA receiver.

The buttons “Next Channel” and “Previous Channel” are implemented in the new methods goToNextChannel and goToPreviousChannel. These methods are doing different things dependent on the currently selected source:

  • Radio: switches to the next/previous preset station
  • TV: switches to the next/previous TV channel
  • DVD: switches to the next/previous track on CD/DVD

When a command is executed the SoC goes to DeepSleep after a delay of 30 seconds. In the new example example/av_rmt_example_with_10_adc_buttons this functionality is redesigned so that the 30 seconds delay is reset with each new button command.

The next Steps

  • When the SoC is woken up from DeepSleep by a button click, the button has to be pressed again to execute the requested function. I would like to get the wake-up and the function with only one click of the button.

Under the Hood

You can find the sources on GitHub at https://github.com/elrebo-de/esp_av_rmt.

Contact me, if you want to discuss or need more info.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *