Help Troubleshooting Wemos D1R2 with Qapass 1602A & Custom Shield

Hi there, I am building a small Device to measure the pressure of a vacuum pump, send it to a server and display the last value.
I have the Server part figured out already, but the LCD just doesn’t work.
I followed this tutorial, this is the Board pinout and here is my Code:

/*
  LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD
 and shows the time.

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 modified 7 Nov 2016
 by Arturo Guadalupi

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld

*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
#define rs  5
#define rw  6
#define en  7
#define d0  8
#define d1  7
#define d2  6
#define d3  5
#define d4  4
#define d5  3
#define d6  2
#define d7  1
LiquidCrystal lcd(rs, rw, en, d4, d5, d6, d7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}

as for the custom shield, I don’t have any good diagrams at the moment.

I'm guessing you are confused between the pin numbers and names. For example

#define d5  3

refers to the pin marked "GPIO3", not the pin marked "D3". GPIO3 is also marked RX and is used, along with TX (=GPIO1), for sketch upload and serial monitor, so best to avoid using those pins in your circuit.

I tried both, but

#define rs  14
#define rw  12
#define en  13
#define d0  15
#define d1  13
#define d2  12
#define d3  14
#define d4  2
#define d5  0
#define d6  4
#define d7  5

doesn’t work either

Well, we need to see how you have wired the lcd to the Arduino. It cannot be the same as the tutorial you linked, because that used an Uno. You must have made some changes to accommodate the esp board, and that is the most likely cause of the problems. Hand drawn is ok but please make it neat and label all the pins.

Here are some Photos (Please excuse my handwriting :/):

Sorry, but you appear to be attempting to link to your personal files on Google.

You need to post the images to a usable image hosting site first. It is frequently easiest to attach them to your post here in order for them to be visible to others. :grinning:

Fixed Images (I hope)

ubus99:
Fixed Images (I hope)

Do you think they are big enough?

First, my condolences for having a Wemos D1 R2
IMO, that board has the absolute worst pinout of any Arduino board I have ever seen.
Not only does it require using Dn symbol names but all the symbols are offset by 2 physical pins on the connectors which can make things quite confusing.
i.e. the D0 pin on the Wemos D1 R2 is not the RX pin and is not the pin of the Arduino digital pin 0 location of an UNO.
What that means is you can't take an existing sketch for say an AVR based board with UNO type connectors that used naked constants and just slap a "D" in front of the pin number since it will refer to a different physical pin.
Combine that with the Wemos D1R2 board sharing the same variant file with the Wemos Mini and it gets even more confusing since that variant does not define symbols for D11 to D15.

Since there are so many symbol names likd Dn dn and n
I will use the term DBn to refer to LCD pins which is what the hd44780 datasheet uses.

From looking at your posts and your diagram, I can not tell how you have wired things up because the pins you used in the code to not match the symbol names you used in your diagram
i.e. 7 is not the same pin as D7
And the diagram and the code show connecting the same Wemos pin to more than one LCD pin
i.e. LCD pins E and DB1 are both connected to the same Wemos pin.

Several things need to be corrected.
1st and most importantly. DO NOT use a pin for r/w.
The LiquidCrystal library does not support reading from the LCD
If you specify a r/w pin all the library does is set it low. There is no need to waste a pin for a ground signal.
Also, and this is the most important thing to keep in mind:
if directly connecting a 5v device (LCD) to a 3v device (esp8266) you never want the 5v device to drive the pins with 5v.
Hard wire the r/w pin on the LCD to gnd and leave the r/w pin out of the constructor.
By hard wiring the LCD r/w pin to gnd you ensure that the LCD will never driver any of the data bus signals.

Next. You are using 4 bit mode.
If using 4 bit mode you must either not connect anything to LCD pins DB0, DB1, DB2, DB3 or connect them to ground.
You are connecting those LCD pins to the Wemos and some of the same wemos pins are also connected to pins used to control the LCD.
This will not work as the LCD will not be able to properly enter 4 bit mode.
I would recommenced not connecting anything to LCD pins DB0, DB1, DB2, DB3.

The other thing you need to understand is what PaulRB mentioned.
When using the Wemos boards, the Dn labels printed on the PCB refer to name of the symbol you should use if you want to reference that pin.
i.e. if it says D5 then you must use "D5" as the pin name. If you use naked constants you are referring to a GPIO bit number which will usually not be the same physical pin.

A bit of additional complexity is that there are not enough pins on the esp8266 to have unique pins for all the pins in the UNO form factor connectors.
So some pins are duplicated, which means that you must pick which location you want to use and avoid using the other pin location where that same esp8266 pin is used.

On the Wemos D1R2, D5 is GPIO14 and shows up in the Uno connector where UNO digital pin 7 and UNO digital 13 are located.

The key takeways:

  • don't use a pin for r/w (ground the LCD pin)
  • use the Dn labels on the PCB for your Arduino pin numbers.
  • don't re-use Dn pins as you can't share a pin for multiple functions.

--- bill

Thanks bperrybap,
that was really helpful.
I hope I can get around using an external 5V power supply though, this will make the project so much more complex.

misunderstood something

So, I got it working in General, thanks to all of your help, but there is still one problem left that I can't figure out:
The display works just fine normally, but after initialization of Homie it only outputs a garbled mess. Google doesn't show me anyone else with the same problem, and I don't know what exactly goes wrong. Does anyone have experience with this?

Does anyone have experience with this?

Yes, unfortunately we all have far too much experience of this situation. If we could take courses or pills to enhance our psychic abilities, we would :confused:

I guessed as much :slightly_frowning_face:...

ubus99:
I guessed as much :slightly_frowning_face:

I think you may not have understood the sarcasm.
We cannot help you without any information about your situation.

You have not provided us with a schematic or wiring diagram of how you have things hooked up, any photos, and no code.
In the absence of information about what you have wired up and what what code you are running, we can not help you.

— bill

Well, I knew it was sarcasm, but I thought he was talking about how everyone had experience with incompatible Libraries.
As for the hardware: at the time I last posted it still hadn't changed from the original image except for removing d0-d3 and grounding RW.
I talked to the guys at Homie-Esp8266, and they told me that I can't use D4, because it also connects to the internal LED, so I fixed this, DB0-DB3 are now wired to D0-D3.

Using this Code, the Display works in the setup phase, but the part in the loopHandler just produces a mess (e.g. printing "1" results in a "3")
Neither me nor the guys at Homie-ESP8266 know what causes this atm, but is might be a timing issue.

(IMPORTANT: the code on pastebin is slightly outdated, I removed the structs)

ubus99:
As for the hardware: at the time I last posted it still hadn't changed from the original image except for removing d0-d3 and grounding RW.

We can't tell how you have things wired up.
From looking at your posts:
original post, response #2, and response #4, there should be no expectation of those pins/wiring working.
The first two use GPIO numbers, and the drawing uses Dn symbols.
All 3 are using different wiring, and all 3 reuse pins. If you attempt to use the same pin for different LCD pins it will not work.

None of those 3 match the pins used in the pasetbin code you linked to in response #14
And, you said the code on pastebin is out of date so we can't see the actual code you are really attempting to run.

It is very unlikely to be a timing problem.
I have extensively tested the LiquidCrystal library on esp8266, esp32, and pic32 processors with no issues.

Almost always when there is a "not working" or misbehaving issue when using the LiquidCrystal library, it is a wiring issue.

  • an incorrect wiring (connecting the wire to the wrong LCD pin or the wrong Arduino pin) vs pins in the code
  • soldering issue
  • broken wire

In your case from the OP, response #2, and response #4, you also have attempted to use the same pin more than once.

Until the pin wiring and pins in the code are resolved and match, it isn't going to work.

--- bill

To finally resolve this: Lübbe Onken on the other Forum speculated it might still be another GPIO pin, and he was right. Homie Reserves GPIO0 for reset-purposes. Disabling it fixes the problem.

On the esp8266 there are several pins that are special.
Several are used to control the boot mode at powerup and reset.
You have to be very careful if you use the special purpose pins as some uses are incompatible with the pin.
You can google around and find lots of information on this.

Here is a small summary:

GPIO2 is used to control the built in LED.
It is recommended to avoid using GPIO0, GPIO2, & GPIO15 for inputs (see below)
GPIO0, GPIO2, and GPIO15 are special inputs used at reset and power up.
They control the boot mode:

GPIO15    GPIO0    GPIO2    MODE       Description
   L         L        H      UART    Download Code from Uart
   L         H        H      FLASH   Boot from SPI flash (normal)
   H         x        x      SDIO    Boot from SD card

Programing flash using uart0 requires a boot mode of "boot from uart0"
with boot_sel=b001, that is, it must make sure
GPIO15=0, GPIO0=0, and GPIO2=1 during reset
Because of this, GPIO15 has an external pulldown.
This makes these GPIO pins unsuitable for simple grounding switches
especially when switches can be pressed at powerup to set modes.
GPIO15 and GPIO0 do appear to work correctly after boot and GPIO0 does
not appear to have a pull down on it.

--- bill

bperrybap:
GPIO15 and GPIO0 do appear to work correctly after boot and GPIO0 does not appear to have a pull down on it.

Do you not mean "GPIO0 does not appear to have a pull up on it"? You want it to be pulled up on boot; there is no reason it would ever want a pull-down, that would be completely counterproductive! :astonished:

Paul__B:
Do you not mean "GPIO0 does not appear to have a pull up on it"? You want it to be pulled up on boot; there is no reason it would ever want a pull-down, that would be completely counterproductive! :astonished:

I'm not sure what I meant by that. This was a note I wrote to myself nearly 3 years ago when I switched a project over from a Teensy to a Wemos D1 mini.
I agree. It doesn't make sense.

The D1 mini I have that I just looked at has a 10k pullup on GPIO0.
But you do want and need to pull down GPIO0 for downloading from the serial port.

DTR and RTS from the CH340C are used to control RST (to auto reset the device) and GPIO0 (for downloading).

--- bill