Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP8266 and HW SPI #53

Closed
olikraus opened this issue Aug 21, 2016 · 16 comments
Closed

ESP8266 and HW SPI #53

olikraus opened this issue Aug 21, 2016 · 16 comments
Milestone

Comments

@olikraus
Copy link
Owner

Currently there are two issues

@olikraus
Copy link
Owner Author

  1. The first problem is solved. Problem was the use of wrong I/O lines which might crash the ESP8266
  2. SPI Mode problem is addressed

@olikraus olikraus added this to the 2.4 milestone Aug 21, 2016
@dratini0
Copy link

For anyone else bumping into this again, at the time of writing, a pull request (esp8266/Arduino#2418) has been submitted to esp8266/Arduino, but has not yet been merged. Therefore, point 2 still stands.

@Misiu
Copy link

Misiu commented May 13, 2019

@dratini0 @olikraus this has been fixed in esp8266/Arduino#5948 and released in 2.5.1

@olikraus
Copy link
Owner Author

👍

@Misiu
Copy link

Misiu commented May 13, 2019

@olikraus could You test this? I've ordered the display (ST7920 based 128*64) but didn't get it yet so can't help.

@olikraus
Copy link
Owner Author

I can try to find a matching hardware. (ToDo: Test)

@olikraus olikraus reopened this May 13, 2019
@olikraus olikraus modified the milestones: 2.4, 2.26 May 13, 2019
@olikraus
Copy link
Owner Author

olikraus commented May 19, 2019

I did some tests and can confirm that the fix works: The ST7920 display works without modification of u8g2.

Hardware:

  • Feather HUZZAH ESP8266
  • 74HC07 as 3.3V to 5V level shifter
  • ST7920 display

IDE:

  • Arduino 1.8.4
  • esp8266/Arduino 2.5.1

Test A: Software SPI

U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 14, /* data=*/ 13, /* CS=*/ 15, /* reset=*/ 16);

Works as expected

Test B: Hardware SPI (new code)

U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16);

Now also works.

Test C: Hardware SPI (new code removed)

Same example as Test B: As expected: Example does not work any more.

U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16);

Conclusion: All tests are successfully passed.

@olikraus
Copy link
Owner Author

Testenvironment: Adafruit ESP8266 board,74HC07 and ST7920 display

https://raw.githubusercontent.com/wiki/olikraus/u8g2/img/st7920_esp8266.jpg

@Misiu
Copy link

Misiu commented May 23, 2019

@olikraus sorry for the noob'ish question, but why do You need 74HC07? Based on what I found I think ST7920 can be directly connected to ESP8266 or Arduino (for example https://www.hackster.io/user0035382/adjusting-clock-on-128x64-monochrome-display-st7920-b9569a).
I'm still waiting for the display I ordered so I'll check that when it arrives, but I don't want to damage it at the start.

If I want to use Hardware SPI (which is the fastest way right?) I must use U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 15, /* reset=*/ 16);
but what pins I must connect? I'll be using Wemos D1.

Thanks for the advice 🙂

@olikraus
Copy link
Owner Author

The hackster example makes use of an Arduino Nano, which is a 5V board. The ESP8266 however is a 3.3V board. For a 3.3V board, the maximum output voltage of the GPIO lines are 3.3V (maybe little bit lesser). But a 5V display (the ST7920 operates with 5V logic) expects at least 3.5V to detect a logic high. In other words, whatever the ESP8266 sends, will be read as logic zero. To avoid this we have to do voltage level translation: The maximum output voltage has to be increased. There are many options to do this, but I just looked for an option based on the available parts in my lab. So I took a 74HC07 device which has an open collector output. Together with a 2K resistor for each signal line it is a good 3.3V to 5V level translator.

@Misiu
Copy link

Misiu commented May 24, 2019

@olikraus and that's why this was a noob'ish question. I know that ESP8266 has 3.3V logic, but I wasn't aware that ST7920 has 5V logic. I've searched a bit, found a tutorial with Arduino and assumed that it will work the same way with ESP.

Thanks for clarification

@olikraus
Copy link
Owner Author

will work the same way with ESP.

Actually, it may work (3.3V is not that far away from 3.5V) but it will not be reliable.

@Misiu
Copy link

Misiu commented May 24, 2019

@olikraus I'll check that when my display arrives :)
Nevertheless, I'm going to order a couple of level shifters, just in case.

@olikraus
Copy link
Owner Author

👍

@Kroshtandt
Copy link

@olikraus hello, have the same problem with nodemcu and ST7920 spi connection. Display is blank. Do I need to use level converter for that?

@olikraus
Copy link
Owner Author

Discussion continued at #1186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants