esp32で、 I2C OLED 0.96 inch 試してみたいと思います。
arduino IDE (1.8.1)+arduino-esp32 の環境です。
機能: 文字を表示するサンプル
*) u8g2 ライブラリ使用
# 配線
SDA: #21
SCL: #22
#code
Git:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
ESP32+ OLED 0.96 (SSD1306) | |
Author : Kouji Nakashima / kuc-arc-f.com | |
date : 2017/03/08 | |
SDA: #21, SCL: #22 connect. | |
thanks: | |
https://github.com/pcbreflux/espressif/tree/master/esp32/arduino/sketchbook/ESP32_i2c_Si7021_oled | |
u8g2 LIB: https://github.com/olikraus/u8g2 | |
*/ | |
#include <U8g2lib.h> | |
#include <Wire.h> | |
//U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED | |
U8G2_SSD1306_128X32_UNIVISION_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Adafruit ESP8266/32u4/ARM Boards + FeatherWing OLED | |
//U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display | |
/* Common addresses definition for temperature sensor. */ | |
static int pos; | |
// | |
void setup() { | |
Serial.begin(115200); | |
pos=0; | |
u8g2.begin(); | |
} | |
// | |
void proc_display(String sSrc ){ | |
String stringOut; | |
char buf[512]; | |
char degree = 0xB0; | |
if (pos%4==0) { // Heardbeat | |
u8g2.drawDisc(122,28,3); | |
u8g2.sendBuffer(); // transfer internal memory to the display | |
} | |
stringOut =sSrc ; | |
stringOut.getBytes((unsigned char *)buf, 512, 0); | |
Serial.print(pos++); | |
Serial.print(" "); | |
Serial.println(buf); | |
u8g2.clearBuffer(); // clear the internal memory | |
u8g2.setFont(u8g2_font_10x20_tf); | |
u8g2.drawStr(0,20,buf); // write to the internal memory | |
//u8g2.drawBox(0,26,humi,6); | |
//u8g2.drawFrame(0,26,100,6); | |
u8g2.sendBuffer(); // transfer internal memory to the display | |
} | |
uint32_t mTimerTemp=0; | |
// | |
void loop() { | |
if( millis() > mTimerTemp ){ | |
mTimerTemp= millis() + 1000; | |
proc_display("esp32, Test"); | |
} | |
} | |
下記を参考してます (thanks)
https://github.com/pcbreflux/espressif/tree/master/esp32/arduino/sketchbook/ESP32_i2c_Si7021_oled
ESP32 #11: Weather Station with Si7021 and OLED
https://www.youtube.com/watch?v=uGOBxG9EiUY
# OLED +dht11 Sensor (センサー付 )
https://gist.github.com/kuc-arc-f/32eb085973eb6fc6bd838e28f2a51a3e
# UART Log

# 関連のまとめ
0 件のコメント:
コメントを投稿