Notifications
Clear all

ESP8266-12x o. ESP32 with TFT ILI9341 and I²C-Interface

17 Posts
4 Users
4 Likes
1,103 Views
WolfgangW
(@wolfgangw)
Member
Joined: 4 years ago
Posts: 70
Topic starter  

Hello community,
I would like to connect an ESP8266 NodeMCU, or Lolin, or an ESP32 WROOM to an ILI9341 type LCD touchscreen and still use the full I2C interface.
So far I've only found examples online that connect the CS of the monitor to a D2 connection of the various ESPxxx. Now the SDA is there too. In the examples there, however, only the use of ESPxxx and the monitor is described, not the use of additional sensors that use this I²C interface.
I get the monitor itself to display whatever, but the I²C interface can no longer be used because of the D2-SDA mentioned.
I think that many of you who have connected such a monitor to an ESPxxx have already had this problem and have probably found a solution.
I currently have the libraries from
Ardafruit in use, although I also found something about "#include <TFT_eSPI.h> ", but I can't get it to work either. Possibly a version dependency.
All libraries used as of today
#include "Arduino.h"
#include "Wire.h"
#include "SPI.h"
#include "ESP8266WiFi.h"
#include "PubSubClient.h"
#include "Time.h"
#include "TimeLib.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "Herakles.h" // Project internal
#include "Variables.h" // External variables

#include "Fonts/FreeSans9pt7b.h"
#include "Fonts/FreeSansBold12pt7b.h"
#include <Fonts/FreeMono9pt7b.h>

I used the wiring from this website, which is like most others.
https://thesolaruniverse.wordpress.com/2021/05/02/wiring-an-ili9341-spi-tft-display-with-esp8266-based-microcontroller-boards-nodemcu-and-wemos-d1-mini/

thank you in andvance for any kind of help

Wolfgang

 

If I am not here, then I am most probably somewhere else


   
Quote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1121
 

@wolfgangw

Whilst there are default pins for i2c on the esp32 I think you can actually reassign the pins to be be used so as not to conflict with the SPI interface.  I've been working outside today and still have my thirst to quench 🍺 😎 and a recording to watch.  If I see you have not had any other good responses or you have still not sussed out using alternative pins for i2c  by tomorrow I will have a deeper dig. 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6910
 

Perhaps I misunderstand, but with I2C ty just connect as many devices as you need as long as each has a unique address. Some boards have jumpers or zero ohm resistors that have to be moved to select a different address if there is a conflict. I have a breadboard with 3 devices all plugged into the one SDA and SCL pins.

TFT may be obsolete, I am not positive but in my IDE I see TFT under retired.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1121
 

@zander your slowing down and this time my post came first, I feel one of my legs must be getting shorter.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6910
 

@byron But which of us is right?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1121
 
Posted by: @zander

@byron But which of us is right?

Probably both.  i2c does not have a CS (chip select) pin, so I presume SPI is being used and  it had the temerity to use one of the default i2c pins.  So lets use other pins for i2c. But of course you can connect multiple i2c devices on one i2c bus so you get a brownie point.

But if you were referring to diminished legs, then I think its my left. 😎 


   
Inq reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6910
 

@byron Oops, I missed the CS reference, so brownie point to you too. Just in case the OP has any doubts though about I2C here are pictures showing 2 devices connected to the I2C bus. I then ran the standard I2C scanner sketch that prints the addresses.

IMG 7044
IMG 7045
Screen Shot 2022 07 08 at 15.36.08

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1121
 

@wolfgangw

Well I'm drinking my beer, but why put off the i2c pin stuff until tomorrow, so I refer you to a random nerd post and note that somewhere he refers to using different i2c pins to the default ones.

https://randomnerdtutorials.com/esp32-i2c-communication-arduino-ide/

 


   
Ron reacted
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1121
 
Posted by: @zander

@byron Oops

😀, but that picture you show is of a venerable arduino uno.  Did you raid the museum.  You should really dig out one of your ESP32 S3 boards or even a shiny new rpi pic W board.  


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6910
 

@byron The Pico W is winging its way here from Merry Olde. I do not have any of the fancy shiny new S3 boards yet, haven't had a need YET. 

When doing a quick ad hoc experiment, I almost always use a UNO if it will work since it's mounted with a breadboard etc.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1121
 
Posted by: @zander

When doing a quick ad hoc experiment, I almost always use a UNO

and then fry your nice 3.3v sensor...  Well thats what I did,  I think I will ditch my arduio boards they just gather dust now.

This post was modified 2 years ago by byron

   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6910
 

@byron I think my UNO is a clone and has 3.3V as well as 5V outputs.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1121
 
Posted by: @zander

I think my UNO is a clone and has 3.3V as well as 5V outputs.

Mine have a 3.3v and 5v power pins, but the digital I/O pins are all 5v when driven high.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6910
 

@byron True, I guess I have been lucky so far.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1900
 
Posted by: @byron

@zander your slowing down and this time my post came first, I feel one of my legs must be getting shorter.

Don't I feel like the tortoise!  Just wait till I get fiber at the house and I'll be in the running.  😎   

Posted by: @wolfgangw

So far I've only found examples online that connect the CS of the monitor to a D2 connection of the various ESPxxx. Now the SDA is there too. In the examples there, however, only the use of ESPxxx and the monitor is described, not the use of additional sensors that use this I²C interface.

@wolfgngw is there something special about the I2C as it applies to this monitor?  Does it have both the SCL and SDA lines?  On the ESP8266 (NodeMCU or Wemos) these go to D1 and D2 respectively.  Those are the default lines for I2C and libraries for sensors assume these. 

As Ron and Bryon said, you can have as many I2C devices on that "bus" (D1,D2) as long as they have different addresses.  It is just like a network with IP addresses.  In my current project https://forum.dronebotworkshop.com/user-robot-projects/inqling-junior-robot-mapping-vision-autonomy/ , I have five sensors on the same, default I2C bus D1,D2.  Accelerometer, Gyro, Magnetometer, Barometer and ToF sensor.

There is one situation that can arise from having too many sensors on the same bus.  Most sensors include pull-up resistors built-in.  If too many sensor have these, the pull up will be too strong and the network will fail.  I've only read this as my situation above does not have this problem.  Probably because four of those sensors are on one board and they only have the one set of pull ups for all four.  

If however any two sensors have the same address, you can always create a second I2C bus out of any other pins, say... D3, D4.  I've done this before, and if you have this situation, let me know and I'll see what was done for that.

Either way, you can just wire them up to your ESP and using the I2C scanner sketch ...

https://github.com/todbot/arduino-i2c-scanner/blob/master/I2CScanner/I2CScanner.ino

... it will scan all your pins and tell you which one have an I2C device connected and what its address is.  

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Ron reacted
ReplyQuote
Page 1 / 2