Skip to content

Commit 2bf8982

Browse files
authored
Add ESP32-C3 board w/ I2C OLED 0.42" (#15)
1 parent 2865840 commit 2bf8982

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+81
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions

esp32_c3_oled_0.42/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.common/Makefile
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* demo for tiny ESP32-C3 board with 0.42" OLED display using u8glib2.
3+
* The OLED is connected to I²C pins 5 (SDA) and 6 (SCL).
4+
* The on-board LED is connected to pin 8 and low-active.
5+
*/
6+
7+
#include "U8g2lib.h"
8+
#include "jled.h"
9+
#include <Wire.h>
10+
#include <driver/temp_sensor.h>
11+
12+
#define SDA_PIN 5
13+
#define SCL_PIN 6
14+
15+
U8G2_SH1106_72X40_WISE_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
16+
auto led = JLed(8).Breathe(4000).MinBrightness(20).LowActive().Forever();
17+
18+
void setup(void) {
19+
// initialize I²C
20+
Wire.begin(SDA_PIN, SCL_PIN);
21+
u8g2.begin();
22+
23+
// Initialize temperature sensor
24+
temp_sensor_config_t temp_sensor = {
25+
.dac_offset = TSENS_DAC_DEFAULT,
26+
.clk_div = 6,
27+
};
28+
temp_sensor_set_config(temp_sensor);
29+
temp_sensor_start();
30+
}
31+
32+
void loop(void) {
33+
static long last_update = 0;
34+
35+
if (millis() - last_update > 1000) {
36+
u8g2.firstPage();
37+
do {
38+
float temp;
39+
temp_sensor_read_celsius(&temp);
40+
41+
u8g2.setFont(u8g2_font_torussansbold8_8r);
42+
u8g2.drawFrame(0, 0, 72, 40);
43+
u8g2.drawStr(2, 10, "Hello");
44+
u8g2.drawStr(2, 18, "ESP32-C3");
45+
u8g2.drawStr(2, 26, (String("T=") + String(temp, 1)).c_str());
46+
u8g2.drawStr(2, 34, (String(last_update / 1000)).c_str());
47+
48+
} while (u8g2.nextPage());
49+
last_update = millis();
50+
}
51+
52+
led.Update();
53+
delay(1);
54+
}

esp32_c3_oled_0.42/platformio.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[platformio]
2+
default_envs = esp32c3
3+
src_dir = .
4+
5+
[env:esp32c3]
6+
platform = espressif32
7+
board = esp32-c3-devkitm-1
8+
framework = arduino
9+
lib_deps=olikraus/U8g2@2.36.2
10+
jandelgado/JLed@4.15.0

images/WS2812_protection.jpg

-3.44 KB
-70.2 KB
Binary file not shown.

images/bmp280.png

-21.9 KB

images/cjmcu-8x8/cjmcu.jpg

39.5 KB
-346 KB
Binary file not shown.
-358 KB
Binary file not shown.

0 commit comments

Comments
 (0)