This instructables show how to start playing with TTGO T-Watch.
Step 1: What Is TTGO T-Watch?
TTGO T-Watch is watch shape ESP32 based development kit. 16 MB flash and 8 MB PSRAM both are top specification. It also built-in a 240×240 IPS LCD, touch screen, micro-SD card port, I2C port, RTC, 3-axis accelerometer and a custom button. The backplane also can be switched to other modules such as LORA, GPS and SIM.
But the most important thing it can become a usable watch is the power system. It integrated AXP202 multi-channel programmable power management chip. This is the first time I see a development kit that have a I2C controllable power chip!
According to AXP202X_Library interface, you can control each power channel on and off, read the battery level, charging status and even direct shutdown the power, just like pushed the power button.
Step 2: Simple Watch PoC
The power chip seems good, but how long does it last for the built-in 180 mAh battery?
Since it designed as a watch outlook, let’s start with a simple watch example as a PoC to exam how the power chip work.
Step 3: Design Watch Face
ESP32 is a very powerful chip, 240 Mhz dual core CPU and 80 Mhz SPI speed can design a very smooth display layout. So I designed a decent watch face with continuous sweep second hand.
However, the design difficulties is unexpected high, it is not easy to remove the last second hand without blinking. I have tried 4 extra methods to make it. The above pictures show a failed redraw that remained last second pixels not removed on the screen. The design watch face work have many words can say but a little bit outside this project. May be I can say more about the design journey in my next instructables, it should be called “Arduino Watch Core”.
Step 4: Set Time
T-Watch have built-in RTC chip, that means it can keep time between reset while development. Before it can keep the time, we should set the time first.
There are various way to set the time:
- ESP32 have WiFi capability, so you can sync time with NTP
- similar to other electronic devices, like digital camera, you can write a UI to set the time
- you can use GPS backplane, then you can get the time from satellite
To make it simple, it still a vary lazy way to set the time, you can find this way at some TFT clock example. When you compile the program in Arduino, the preprocessor defined 2 variable “__DATE__” and “__TIME__” to record the compile time. We can utilize this information to make a very simply program to set the RTC time.
This simple program always set the time at boot. But the compile time is only valid at the first boot, so you should overwrite with other program once it set the time success.
Step 5: Power Consumption
When the watch running, showing continuous sweep second hand, it consume a little more than 60 mA. For power saving reason, it should go into sleep mode after a certain period.
If I turn off the LCD backlight and call ESP32 deep sleep, it drop to around 7.1 mA. It only can last around 1 day for the 180 mAh battery.
I know around 6 mA is consumed by the LCD chip. According to the ST7789 data sheet, there are a command to enter sleep mode. But current TFT_eSPI library not yet have sleep mode API.
And also there are still around 1 mA consumed by somewhere.
Step 6: Programmable Power Management Chip
There are many chips in the development kit, according to their data sheet, most of them support power saving mode. However, not all libraries exposed power saving mode API. And it is a long coding for power saving by checking and calling each module enter sleep mode.
How about direct shutdown the power just like direct pushed the power button? AXP202X_Library can make it by simply calling the shutdown() function. In shutdown mode, it only consume a little below 0.3 mA. It can last 25 days for the 180 mAh battery!
I have just charged the battery at 28 June, you may follow my twitter to know the latest battery status.
The battery drain up at 18 July, the battery can last 20 days. During the period I check the time a few times a day, I assume the watch can last 1-2 weeks in normal use.
Step 7: Program
- Follow https://github.com/Xinyuan-LilyGO/TTGO-T-Watch page instruction to install the software and library.
- Download source code at GitHub: https://github.com/moononournation/TTGO-T-Watch
- Open, compile and upload Set_RTC.ino to update the RTC date and time
- Open, compile and upload Arduino-T-Watch-simple.ino
The simple watch program will do:
- read the RTC date and time
- draw clock mark (you can select round or square clock mark)
- show continuous sweep second hand
- shutdown power after 60 seconds (or you may hold the power button for instant shutdown)
- press the power button to turn it on again
Step 8: Happy Programming!
TTGO T-watch can do much more that a simple watch, e.g.
- ESP32 can make WiFi and BT wireless communication
- use touch screen panel can develop a more fancy UI
- onboard three-axis accelerometer (BMA423), built-in step counter algorithm and other multi-function GSensor
- replaceable backplane can add LORA, GPS, SIM function
- I2C port can extend much more features
Step 9: Arduino-T-Watch-GFX
Arduino-T-Watch-simple require press and hold the tiny power button to wake up and the LCD initial introduction few senconds delay. So the user experience is not so good.
I have add another program called Arduino-T-Watch-GFX to improve this. This program change to use Arduino_GFX display library, it can then tell the display enter sleep in mode to save power. So when the ESP32 enter light sleep, it just consume below 3 mA now. And also it can now trigger wake up by touch the screen. The ESP32 wake up and display sleep out is much faster than whole reboot process, you can see the above video it is nearly instant response. Theoretically the battery should able to last over 2 days 😛
Source: TTGO T-Watch