Comments (48)
This is working with a TTGO-TS V12 (1.44" display) w/ a ST7735R:
https://github.com/aaronh86/ST7735R_ESPHome
It's not pretty, or up to code standards, but it'll print text if you need it to.
Maybe someone can build on it.
from feature-requests.
Hello!
I am interested in ST7735S support for the 80*160 TFT LCD of M5StickC. I also submitted an issue to the M5Stack team for that..
m5stack/M5StickC#18
I really think the M5StickC could be the killer device for esphome, and esphome be the killer application for that device, if most of the components can be integrated.
from feature-requests.
Hi there,
I´m pretty new to all this stuff but very interested. I own such a display with ST7735 128x160. In a project I´m trying to realize I want to fill the TFT using Home Assistant. I attached the device and get temperatur of an also attached DHT22 but the screen remains white.
Here is an extraction of code I´m actually using for evaluation:
/**************************************************************************
This is a library for several Adafruit displays based on ST77* drivers.
Works with the Adafruit 1.8" TFT Breakout w/SD card
----> http://www.adafruit.com/products/358
The 1.8" TFT shield
----> https://www.adafruit.com/product/802
The 1.44" TFT breakout
----> https://www.adafruit.com/product/2088
The 1.54" TFT breakout
----> https://www.adafruit.com/product/3787
The 2.0" TFT breakout
----> https://www.adafruit.com/product/4311
as well as Adafruit raw 1.8" TFT display
----> http://www.adafruit.com/products/618
Check out the links above for our tutorials and wiring diagrams.
These displays use SPI to communicate, 4 or 5 pins are required to
interface (RST is optional).
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution
**************************************************************************/
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <SPI.h>
//defined(ESP8266)
#define TFT_CS 15
#define TFT_RST 0
#define TFT_DC 2
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
float p = 3.1415926;
void setup(void) {
Serial.begin(9600);
//Serial.print(F("Hello! ST77xx TFT Test"));
// Use this initializer if using a 1.8" TFT screen:
tft.initR(INITR_BLACKTAB); // Init ST7735S chip, black tab
//Serial.println(F("Initialized"));
uint16_t time = millis();
tft.fillScreen(ST77XX_BLACK);
time = millis() - time;
tft.fillScreen(ST77XX_BLACK);
testdrawtext("Initialisiere WIFI", ST77XX_WHITE);
tft.println(time, DEC);
delay(500);
tft.println("done");
delay(1000);
tft.fillScreen(ST77XX_BLACK);
testdrawrects();
}
void loop() {
}
void testdrawtext(char *text, uint16_t color) {
tft.setCursor(0, 0);
tft.setTextColor(color);
tft.setTextWrap(true);
tft.print(text);
}
void handle_OnConnect() {
Temperature = dht.readTemperature(); // Gets the values of the temperature
Humidity = dht.readHumidity(); // Gets the values of the humidity
//tft.fillScreen(ST77XX_BLACK);
tft.setTextColor(WHITE, BLACK);
tft.setCursor(20,10);
//tft.println("");
tft.print(Temperature);
//tft.print(" C");
// tft.println("");
tft.setCursor(20,90);
tft.print(Humidity);
//tft.print(" %");
//tft.println("");
}
void testdrawrects() {
tft.fillScreen(ST77XX_BLACK);
//for (int16_t x=0; x < tft.width(); x+=6) {
tft.drawRect(0,0,tft.width(), tft.height()/2, BLUE);
tft.drawRect(1,1,tft.width()-2, tft.height()/2-2, BLUE);
//tft.drawRect(0, tft.height()/2, tft.width(), tft.height() -50, BLUE);
tft.drawRect(0,tft.height()/2, tft.width(), tft.height()-80, BLUE);
tft.drawRect(1,tft.height()/2-1, tft.width()-2, tft.height()-80, BLUE);
//}
}
In the Arduino IDE I´m using these libraries:
Adafruit-GFX-Library-master.zip
Adafruit-ST7735-Library-master.zip
It would be fantastic when this display will be functional using HA.
I think because it is also a cheap one there are many others who will be interested in.
I can do some testing, if neccessary, if explained what to do. Remember newbie talking ;-)
Thanks in regards
from feature-requests.
Any leading points in ESPHome docs from which I could get a start? The closest one is, I guess, Nextion display.
I would look at waveshare epaper and SSD1306 integrations. They both use the DisplayBuffer
interface that I want to use going forward. Only thing that's missing there is: Color support (though interface is designed to allow that in future) and touch (I guess we could add a simple trigger that gives the user XY position, then the user can figure out what to do with it).
Does ESPHome has a separate HAL from Arduino?
For most things, yes. For GPIO there's esphal.h
, for i2c
there's i2c_component.h
(same for UART and SPI). All but the first one are pretty much themselves just wrappers around the Arduino APIs. But I want an additional layer between Arduino and integration code so that things can be changed easily (for example a better i2c implementation, or hardware SPI etc)
When developing new integrations these interfaces should always be used.
Can we just use the Adafruit library as a dependency or should we invent our own driver for ESPHome?
The latter. The integration itself should however not do anything other than communicating with the display. All drawing/etc stuff should be handled by DisplayBuffer
class, so that all subclasses from that benefit from changes.
Is there any per-class method of 'dynamic' dependencies like in HASS?
Yes, see LIB_DEPS
variable.
from feature-requests.
I'd love to build on that with my m5stick-c, but I am missing the starting point. Can you poke me in a direction on how to include your files into an esphome configuration? Maybe post your yaml? Thanks!
from feature-requests.
Thanks for the info (still a beginner at esphome...). That's certainly the right and safe way to install them - it's there for me because it's actually in some local esphome source tree with some custom changes (and installed there using pip install)
from feature-requests.
@airy10 It works like a charm! Great job
from feature-requests.
I added a PR for this. I tried to make it as customizable as possible. You can set the model according to adafruit. Thats for initialization and what nots. You can also change col,row,height,width and 8bit color. This should cover all of us. The 8bit is used because of RAM usage. I couldnt run my 128x160 at 16bit since it need 40Kb of the 80 that I had on my esp12. esphome/esphome#1066
from feature-requests.
I've added early versions of some esphome components for the M5StickC here :
https://github.com/airy10/esphome-m5stickC
With a sample yaml to display some info on the screen.
The components should be made more generic since they could be used with other boards but for now some of the initialization is hard-coded with the way they are used on the M5StickC
from feature-requests.
@airy10 Please do not copy files into the site-packages dir. There is a much easier solution: Copy the component in the custom_components
directory where the .yaml file is (see contributing guide for more info).
from feature-requests.
Thanks @SenexCrenshaw! So the only thing missed is a documentation? Or this functionally is not in production yet?
It is and the docs have been merged. they should be showing up in dev or the next release
Here is a link in my repo in case you cant find it
https://github.com/SenexCrenshaw/esphome-docs/blob/ST7735/components/display/st7735.rst
Also if you are using an 8266 the driver can run in 8bit color mode saving 1/2 the required buffer space.
from feature-requests.
@SenexCrenshaw Thanks for the quick reply. But what I have is a display shield - how can I change the pins?
See here: https://www.wemos.cc/en/latest/d1_mini_shield/tft_1_4.html
Ah, what I see there is that the reset pin of the TFT is attached to the reset pin of the d1 mini.
The reset pin for this component is optional and you can just leave it out.
from feature-requests.
from feature-requests.
@OttoWinter Any chance to get this working?
from feature-requests.
I don't own such a display myself, nor do I plan to add support for it myself in the near future. Always open to contributions though.
from feature-requests.
I actually own this display and I'm really interested in integrating it into HASS/ESPHome.
I have a few questions:
- Any leading points in ESPHome docs from which I could get a start? The closest one is, I guess, Nextion display.
- Are there any plans on developing several generic display classes (like text-only, monocrome, color, etc displays) and some notion of uniform fonts?
- Does ESPHome has a separate HAL from Arduino?
- Can we just use the Adafruit library as a dependency or should we invent our own driver for ESPHome?
- If we can import the library as dependency, is there any per-class method of 'dynamic' dependencies like in HASS?
I've tried this example on D1 mini. I used the following PIO ini and basically copy/pasted the sketch with some functions moving to get the normal PIO compiler to compile the thing:
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
Adafruit GFX [email protected]
Adafruit ST7735 and ST7789 [email protected]
from feature-requests.
The prices for this type of displays is close to the oled ones - just with color 🌈
Prices for this ones, small: 1,95€, big: 2,20€
Source: https://www.aliexpress.com/item/4000032391177.html
from feature-requests.
@aaronh86 if you could share your yaml that would be amazing. I have the custom components installed but can't seem to get it running yet.
PS - thanks for getting things this far!
from feature-requests.
I've added an example.yaml file - it only contains the relevant code.
Note: you'll need to have the correct ttf (font) file in the same folder as the yaml.
Also, this is only configured for the screen/driver configuration that I listed.
from feature-requests.
That's fantastic. Much appreciated @aaronh86 .
from feature-requests.
@aaronh86 it doesn't seem like it was developed as a custom component for esphome. I had to modify display.py to import st7735_base as a custom component to just be able to load it, however I'm still getting Platform not found: 'display.st7735_spi' for some reason.
from feature-requests.
It was being developed as a full component, not a custom component. Copy both folders into you're esphome components folder.
from feature-requests.
from feature-requests.
@grinco, you can always just copy it across when you flash your device, it doesn't need to be in your docker image all the time. Unless you're reflashing your esp device all the time it wouldn't be too much effort. I don't have the time at the moment to bring it up to code standards or integrate the other lcd displays. So it will likely be greater than 6 months before I make a merge request.
from feature-requests.
Awesome, thank you very much! Just to get it clear - To get this working I have to copy the folders within the components/
-folder of your repo into my esphome installation (which is /usr/local/lib/python2.7/site-packages/esphome/components/
on my MacOS installation with pip)?
from feature-requests.
Right. Then esphome should find it (my python install is at /usr/local/lib//python3.7/
for me but it depends of your config)
from feature-requests.
@airy10 Please do not copy files into the site-packages dir. There is a much easier solution: Copy the component in the
custom_components
directory where the .yaml file is (see contributing guide for more info).
Unfortunately, that doesn't work for me. I have Homeassisant running on a raspi3. custom_components is available. Can you describe this in more detail?
error message is : Platform not Found: display.st7735
from feature-requests.
Doesn't work for me, too.
Validate error:
INFO Reading configuration /config/esphome/nodemcu_02.yaml...
WARNING Unable to import custom component st7735_spi.display:
Traceback (most recent call last):
File "/opt/esphome/esphome/config.py", line 140, in _lookup_module
module = importlib.import_module('custom_components.{}'.format(domain))
File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/config/esphome/custom_components/st7735_spi/display.py", line 4, in
from esphome.components import spi, st7735_base
ImportError: cannot import name 'st7735_base'
Failed config
display.st7735_spi: [source /config/esphome/nodemcu_02.yaml:43]
Platform not found: 'display.st7735_spi'.
platform: st7735_spi
model: ST7735_TFTHEIGHT_160
cs_pin: D2
dc_pin: D3
reset_pin: D4
lambda: it.print(0, 0, id(my_font), "Hello World!");
from feature-requests.
The custom_components folder should be inside the ESPHome folder in a hassio install
from feature-requests.
The custom_components folder should be inside the ESPHome folder in a hassio install
it didnt work for me . i copied the custom_component folder everywhere but get the error
Traceback (most recent call last):
File "/opt/esphome/esphome/config.py", line 140, in _lookup_module
module = importlib.import_module('custom_components.{}'.format(domain))
File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 678, in exec_module
File "", line 219, in _call_with_frames_removed
File "/config/esphome/custom_components/st7735_spi/display.py", line 4, in
from esphome.components import spi, st7735_base
ImportError: cannot import name 'st7735_base'
Failed config
display.st7735_spi: [source /config/esphome/pantallita2.yaml:30]
Platform not found: 'display.st7735_spi'.
platform: st7735_spi
model: ST7735_128X128
cs_pin: D2
dc_pin: D4
reset_pin: D3
lambda: it.print(0, 0, id(my_font), "Hello World!");
from feature-requests.
Thanks @SenexCrenshaw! So the only thing missed is a documentation? Or this functionally is not in production yet?
from feature-requests.
I'm having an issue with this display. Coding/compiling from the esphomeDev integration.
Works like a charm on ESP8266, but the moment it goes in code setup for the ESP32, it just hangs on boot. Tries to find wifi, and just hangs.
Through adding/removing code, it seems that when the "display" section gets added, it all goes south.
Anyone with an ESP32 able to confirm/deny? Any ideas of possible issues?
from feature-requests.
Interesting. I test my code on both devices but maybe missed something with the ESP32. I am away this week and can look at it early next. Do you have any other SPI devices enabled and do they work?
from feature-requests.
The SPI declaration code on its own works fine. No other SPI devices, and unfortunately i don't have any available to test either.
The logs seems to complete the display setup. It hangs right before it usually outputs my Dallas sensor reading. Also tested with plain display code, to make sure that the problem isn't in the dallas stuff, but same behaviour.
[16:52:04][I][logger:166]: Log initialized
[16:52:04][C][status_led:014]: Setting up Status LED...
[16:52:04][C][ota:366]: There have been 5 suspected unsuccessful boot attempts.
[16:52:04][I][app:029]: Running through setup()...
[16:52:04][C][spi:022]: Setting up SPI bus...
[16:52:04][C][adc:018]: Setting up ADC 'thermo_Vbat'...
[16:52:04][C][dallas.sensor:032]: Setting up DallasComponent...
[16:52:04][E][dallas.sensor:200]: Reading scratchpad failed: reset
[16:52:04][C][st7735:235]: Setting up ST7735...
[16:52:04][D][st7735:247]: START
[16:52:04][C][st7735:372]: ST7735
[16:52:04][C][st7735:372]: Rotations: 0 °
[16:52:04][C][st7735:372]: Dimensions: 128px x 160px
[16:52:04][C][st7735:373]: Model: ST7735 GREENTAB
[16:52:04][C][st7735:374]: CS Pin: GPIO15 (Mode: OUTPUT)
[16:52:04][C][st7735:375]: DC Pin: GPIO21 (Mode: OUTPUT)
[16:52:04][C][st7735:376]: Reset Pin: GPIO4 (Mode: OUTPUT)
[16:52:04][D][st7735:377]: Buffer Size: 20480
[16:52:04][D][st7735:378]: Height: 160
[16:52:04][D][st7735:379]: Width: 128
[16:52:04][D][st7735:380]: ColStart: 0
[16:52:04][D][st7735:381]: RowStart: 0
[16:52:04][C][st7735:382]: Update Interval: 1.0s
[16:52:04][D][st7735:249]: END
[16:52:05][C][wifi:033]: Setting up WiFi...
[16:52:05][D][wifi:324]: Starting scan...
[16:52:05][D][adc:056]: 'thermo_Vbat': Got voltage=0.00V
[16:52:05][D][sensor:092]: 'thermo_Vbat': Sending state -0.20000 V with 2 decimals of accuracy
[16:52:05][E][dallas.sensor:126]: Requesting conversion failed
[16:52:05][D][binary_sensor:034]: 'thermo_tact_plus': Sending initial state OFF
[16:52:05][D][binary_sensor:034]: 'thermo_tact_minus': Sending initial state OFF
Next line normally contains Dallas sensor reading. Looking forward to hearing from you whenever you are able to. I will try to borrow any supported SPI device to test in the meanwhile.
from feature-requests.
Ok thanks for the logs. I will get this as soon as i can. give me a week max
from feature-requests.
I identified the problem and submitted a small PR.
esphome/esphome#1493
If you want just add
this->disable();
before the }
at line 457 in st7735.cpp
For the docs, I guess will be added in the next release, in the meantime see below. Its supports string color in 332 (8bit) format which saves 1/2 the buffer space.
https://github.com/esphome/esphome-docs/blob/next/components/display/st7735.rst
I plan on adding additional functionality to it in February but works great as is.
from feature-requests.
Where can i find this file? I tried editing the file /config/esphome//src/esphome/components/st7735/st7735.cpp but it just gets overwritten to before. I cant seem to locate the original file under hassio :/
from feature-requests.
Its going to be whereever esphome is installed in your python library. If
on linux/MAC you can try
find / -name st7735.cpp -type f
or
updatedb && locate st7735.cpp
from feature-requests.
Ohh you just closed the feature request #1 🤣
from feature-requests.
Hmm... Was closed with the small PR I guess
Shouldn't this have been closed anyway with esphome/esphome#1066?
from feature-requests.
Has anyone been able to make this work with the new st7735 platform?
I have the exact same board and TFT shield mentioned in the first post and I cannot make this thing to work.
I keep getting the following error
Cannot resolve pin name 'RST' for board d1_mini.
Here is what my config looks like
esphome:
name: display
platform: ESP8266
board: d1_mini
display:
- platform: st7735
model: "INITR_REDTAB"
reset_pin: RST
cs_pin: D4
dc_pin: D3
rotation: 0
devicewidth: 128
deviceheight: 128
colstart: 0
rowstart: 0
eightbitcolor: true
update_interval: 5s
from feature-requests.
reset_pin: should be a gpio pin. I use the below in my config
for spi:
spi:
clk_pin: D5
mosi_pin: D7
for the st7735:
reset_pin: D1
cs_pin: D8
dc_pin: D2
from feature-requests.
@SenexCrenshaw Thanks for the quick reply. But what I have is a display shield - how can I change the pins?
See here: https://www.wemos.cc/en/latest/d1_mini_shield/tft_1_4.html
from feature-requests.
Thanks for looking into it @jesserockz !
from feature-requests.
Thanks a lot, @jesserockz and @SenexCrenshaw! Works perfectly now!
Here is what my config looks like:
spi:
clk_pin: D5
mosi_pin: D7
display:
- platform: st7735
model: "INITR_GREENTAB"
cs_pin: D4
dc_pin: D3
rotation: 0
devicewidth: 128
deviceheight: 128
colstart: 0
rowstart: 0
eightbitcolor: true
update_interval: 5s
lambda: |-
it.print(10, 10, id(dogica_font), "HELLO!");
from feature-requests.
How do I display color images? I am trying to display the following image:
and it comes up like this
Here is how I've configure the display:
image:
- file: "img/color.png"
id: img_color
resize: 128x128
type: RGB24
display:
- platform: st7735
id: screen
model: "INITR_REDTAB"
cs_pin: D4
dc_pin: D3
rotation: 0
devicewidth: 128
deviceheight: 128
colstart: 0
rowstart: 0
eightbitcolor: true
update_interval: 5s
lambda: |-
it.image(0, 0, id(img_color));
from feature-requests.
Can you try a picture encoded @ 332 ? I might have to update the code to handle 332 when someone is using eightbitcolor. You could turn that off to get 565 but im not sure your device has enough RAM for that size buffer. LMK
from feature-requests.
Can you try a picture encoded @ 332 ? I might have to update the code to handle 332 when someone is using eightbitcolor. You could turn that off to get 565 but I'm not sure your device has enough RAM for that size buffer. LMK
How do I change encoding to 332? The only supported types for image
are BINARY
, GRAYSCALE
, and RGB24
.
from feature-requests.
Related Issues (20)
- DSMR get custom telegram message
- Add WebUI port to .env file to be able to change 6052 to, for example, 80.
- Add ability to restore valve state on reboot HOT 2
- What about adding the static part of the Web Server Component to the esphome/esphome docker image HOT 1
- Speaker Request for external option remote speaker
- sftp "flash on boot" HOT 5
- Be able to access the event_type that triggered an event on the on_event automation. HOT 2
- Support ST7701 type 5 init operations
- Support for Display Driver: EK9716BD3 & EK73002ACGB HOT 1
- ESPHome native API: active connection establishment (from device to Home Assistant) HOT 1
- Toshiba climate IR control support for RAS-10E2KVG-A
- Support for Pylontech H2 Force battery
- modbus_controller climate
- climate platform for using modbus registers HOT 2
- modbus_controller climate HOT 1
- climate platform for using modbus registers HOT 7
- Enable/disable timer as in typical normal rollerblind switches (enable/disable a group of "on_time" entries) HOT 1
- Remote Receiver new protocols HOT 1
- Modbus binary sensor with inverted property HOT 2
- Shelly initial OTA flash
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feature-requests.