Arduino BiJin ToKei
Intro: Arduino BiJin ToKei
This instructables show how to use Arduino IDE, ESP32 dev board and ILI9341 LCD to built a photo clock.
STEP 1: What Is BiJin ToKei?
Recap from my previous intructables, ESP32 Photo Clock:
BiJin ToKei(美人時計)start from 2009, they find various beauty hold a time board report time every minute. BiJin ToKei provide web application and mobile app version. After these years, you can find many variant on the web now.
Ref.:
https://ja.wikipedia.org/wiki/BIJIN%26Co.
STEP 2: Arduino Version
My previous intructables, ESP32 Photo Clock, works fine. However, the program is built on ESP-IDF. This is a big barrier for the beginner. Since Aruino-esp32 framework is very maturer now, implement a photo clock on Arduino IDE become much easier.
STEP 3: Preparation
Any ESP32 dev board should be ok.
Stacking HeaderA 8-pins stacking female header. Bending the long header wire can help to adjust the viewing angle of the LCD.
BreadboardA 400 tie points breadboard.
Breadboard WireSome breadboard jump wire.
LCD DisplayThis time I am using a 2.8 inches ILI9341 LCD. This program using Arduino_GFX library, so most common SPI LCD Display should be ok.
Arduino_GFX currently support:
- HX8352C 240x400
- HX8357B 320x480
- ILI9225 176x220
- ILI9341 240x320
- ILI9341 M5Stack 320x240
- ILI9486 320x480 (18 bit color)
- SEPS525 160x128
- SSD1331 96x64
- SSD1351 128x128
- SSD1351 128x96
- ST7735 128x128 (various tabs)
- ST7735 128x160 (various tabs)
- ST7735 80x160
- ST7789 240x135
- ST7789 240x240
- ST7789 TTGO T-Watch 240x240
- ST7789 240x320
STEP 4: Plug ESP32 Dev Board on Breadboard
STEP 5: Bend Stacking Header & Plug on LCD
STEP 6: Plug LCD on Breadboard
STEP 7: Connection
Use Breadboard jump wire connect LCD and ESP32 dev board together.
Here are the connection summary:
LCD -> ESP32 === ===== Vcc -> 5V pin (or 3.3V pin depends on your LCD display) GND -> GND CS -> GPIO 5 RESET -> GPIO 17 D/C -> GPIO 16 MOSI -> GPIO 23 SCK -> GPIO 18 LED -> GPIO 22 (Optional, some LCD require direct plug LED pin to 3.3V pin to make it brighter)
STEP 8: Software Preparation
Download and install Arduino IDE if not yet: https://www.arduino.cc/en/Main/Software
Arduino ESP32 SupportPlease follow Installation Instructions at GitHub: https://www.arduino.cc/en/Main/Software
Arduino GFX libraryAdd Arduino_GFX library to Arduino IDE: https://github.com/moononournation/Arduino_GFX.gi...
If you are not familiar add library from GitHub, simply press the green "Clone or download" button and then "Download ZIP". And then in Arduino IDE, select Sketch menu -> Include Library -> Add .ZIP Library... -> select downloaded ZIP file.
Arduino BiJin ToKei Source CodeDownload the source code from GitHub: https://github.com/moononournation/ArduinoBiJinTo...
STEP 9: How It Works?
Here are the program workflow:
- Initial LCD, you may change the pins and driver to fit for your display
Arduino_HWSPI *bus = new Arduino_HWSPI(16 /* DC */, 5 /* CS */, 18 /* SCK */, 23 /* MOSI */, -1 /* MISO */); Arduino_ILI9341 *tft = new Arduino_ILI9341(bus, 17 /* RST */, TFT_ROTATION);
- Connect WiFi, remember fill your WiFi AP settings
#define SSID_NAME "YourAP" #define SSID_PASSWORD "YourPassword"
- Connect NTP server to get the current time, you may change your local NTP server and timezone settings
const char* ntpServer = "pool.ntp.org"; #define GMT_OFFSET_SEC 28800L // Timezone +0800 #define DAYLIGHT_OFFSET_SEC 0L // no daylight savingLoop
- If minute changed, make a HTTP request to a predefined URL in URL.h. There are many URL in the ToKei list, please read the comments in URL.h for more details.
#define JPG_SCALE JPG_SCALE_NONE #define TFT_ROTATION 0 // portrait #define URL "http://www.bijint.com/assets/pict/shizuoka/bp/%02d%02d.jpg"
- Get the HTTP response JPEG stream and feed to the esp_jpg_decode
esp_jpg_decode feed the decoded image block to LCD draw function
STEP 10: Program
Open ArduinoBiJinToKei.ino in Arduino IDE, compile and upload the program to ESP32 dev board.
STEP 11: Happy Time!
It's time to put the Arduino BiJin ToKei on your desktop and show off what you have done. Enjoy!
10 Comments
MichealM1 2 years ago
It is that simple! Also, code should be added to write the downloaded picture to SD to use tomorrow. Don't re-fetch it every day, forever! I tried, for a little while, to decide now to do that but did not make it yet. Will look again some day. Other projects going on, too.
Is this what you want? Little to no change from your project code!
/* WiFi settings */
#define SSID_NAME "LaoagMikey"
#define SSID_PASSWORD "PCCRules"
/* NTP server settings */
const char *ntpServer = "pool.ntp.org";
// const char* ntpServer = "192.168.123.1"; // local AP NTP server
#define GMT_OFFSET_SEC 28800L // Timezone +0800
#define DAYLIGHT_OFFSET_SEC 0L // no daylight saving
// WDT, enable auto restart from unexpected hang, it may caused by JPEG decode
#define ENABLE_WDT
// select preferred BiJinToKei here
#include "URL.h"
#include <time.h>
#include <WiFi.h>
#include <esp_jpg_decode.h>
#include <esp_task_wdt.h>
#include <SPI.h>
#include <HTTPClient.h>
/* display settings */
#include <Arduino_GFX_Library.h>
//Next line for T14 T-Gallery
Arduino_HWSPI *bus = new Arduino_HWSPI(23 /* DC */, 5 /* CS */, 18 /* SCK */, 19 /* MOSI */, -1 /* MISO */);
// Arduino_HWSPI *bus = new Arduino_HWSPI(16 /* DC */, 5 /* CS */, 18 /* SCK */, 23 /* MOSI */, -1 /* MISO */);
// Arduino_DataBus *bus = new Arduino_ESP32SPI(27 /* DC */, 5 /* CS */, 18 /* SCK */, 23 /* MOSI */, 19 /* MISO */);
// Arduino_DataBus *bus = new Arduino_ESP32SPI(-1 /* DC */, 5 /* CS */, 18 /* SCK */, 23 /* MOSI */, -1 /* MISO */);
// Arduino_HX8347C *tft = new Arduino_HX8347C(bus, 17, TFT_ROTATION, true /* IPS */);
// Arduino_HX8357B *tft = new Arduino_HX8357B(bus, 17, TFT_ROTATION, true /* IPS */);
// Arduino_ILI9341 *tft = new Arduino_ILI9341(bus, 17 /* RST */, TFT_ROTATION);
// Arduino_ILI9481 *tft = new Arduino_ILI9481(bus, 33 /* RST */, TFT_ROTATION);
// Arduino_ILI9486 *tft = new Arduino_ILI9486(bus, 17 /* RST */, TFT_ROTATION);
Arduino_ST7789 *tft = new Arduino_ST7789(bus, 33 /* RST */, TFT_ROTATION, true /* IPS */);
// Arduino_ST7796 *tft = new Arduino_ST7796(bus, 33 /* RST */, TFT_ROTATION, false /* IPS */);
#define TFT_BL 22
static int len, offset;
static int8_t last_show_minute = -1;
static struct tm timeinfo;
static char url[1024];
HTTPClient http;
DAVIDXGAMES 1 year ago
uden 2 years ago
uden 2 years ago
Any ideas why?
uden 2 years ago
But my screen remains dark. Note that it does work with other projects.
陳亮 2 years ago
At the same time, I found you have many good idea. I believe you are a good maker too. I encourage you go ahead to enhance it base on my sample code and re-share what you have done in Instructables ;>
MichealM1 2 years ago
陳亮 2 years ago
MichealM1 2 years ago
陳亮 2 years ago