getting LCD shield to work with wemos R1 D2

Hi,

I'm having trouble to get the lcd to display the simple message: "Hello World"
The lcd is powered on fine but it seems like no characters were written.
Please take a look!

Hardware:
-wemos board: WeMos D1 R2 V2.1.0 New Version WiFi ESP8266 NodeMCU Arduino UNO Compatible Board | eBay

-lcd shield: 1602 LCD Board Keypad Shield Blue Backlight for Arduino Duemilanove Robot for sale online | eBay

Circuit: I just put the lcd shield on top of the wemos as it fits.

Program:

#include <LiquidCrystal.h>

#define D0 3
#define D1 1
#define D2 16
#define D3 5
#define D4 4
#define D5 0
#define D6 2
#define D7 14
#define D8 12
#define D9 13
#define D10 15

//LiquidCrystal lcd(12,13,4,0,2,14);
LiquidCrystal lcd(D8, D9, D4, D5, D6, D7);
void setup() {
  Serial.begin(115200);
  
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
  Serial.println("Print test.");
}

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);
}

The pins don’t match - your lcd is meant for a standard UNO and your board is 3.3V probably, your lcd might expect 5V

J-M-L:
The pins don’t match - your lcd is meant for a standard UNO and your board is 3.3V probably, your lcd might expect 5V

The 5V pin on the lcd is matched with the 5v pin on the wemos. The lcd is powered on.
But you're right, the other data pins are probably mismatched.

arduino_new:
The 5V pin on the lcd is matched with the 5v pin on the wemos. The lcd is powered on.

What I meant for voltage is that Power might be 5V but pins will output 3.3V as HIGH - it is likely that this will be seen as HIGH by your LCD shield but if there is just a bit of voltage drop then you are in uncharted territory and weird stuff will happen.

I have a WeMos D1 R1 board and an LCD keypad shield (not the same as yours) and it works ok since the LCD is run off 5v and the LCD has the R/W pin tied to ground so it never drives the data lines at 5v. The LCD will interpret 3v high signals from the esp8266 as a 1 so it all woks.

The WeMos D1 R2 board seems to have some funkiness with respect to pins.
In looking at the two variant files, D1R1 uses variant d1 and D1R2 uses variant d1_mini
Using the d1_mini variant and pinout on an UNO board factor does not seem like a good idea.
While it can work, it can easily create pin numbering confusion.

The D1R2 shifts the Dn pins down by two to skip over the RX and TX pins.
But because of the shift the Dn pin symbols no longer match up to the same physical Arduino pin number.

I.e. D0 on the D1R2 board is not the same physical header pin as Arduino pin 0 on an UNO, where as it is on the D1R1 board.
This makes things confusing when using the D1R2 board when using the Dn symbols provided by the variant file which makes them fairly useless.

However you are re-defining them..
I looked at your Dn defines in the sketch and they seem to be correctly re-aligning the Dn numbers to use the GPIO bits to realign the Dn pins to be the same as the Arduino pin numbers.
I.e D9 will be using the GPIO pin number for the header pin for Arduino pin 9 on an UNO board etc...

Not sure why it isn't working.
Perhaps the mappings used on the PCB are not the actual mappings?
(The PCB is not wired up to the ESP8266 the way the variant file specified, or the silkscreen labels are wrong)
You may have to create a special blink sketch, and use it to check each pin to see if it matches the silkscreen label.

Keep in mind that Dn symbols already exist in the variant file.
Yours are able to work in this case because they are being defined in the sketch after the variant header file has been included, otherwise it would have caused compilation issues.
To help remove the confusion you may want to use the Dn symbols from the variant file, vs re-define your own.
By using the ones from the variant file, the Dn numbers should match the silkscreen labels on the PCB.
i.e. remove the Dn defines from the sketch and then use the Dn symbols for the desired header pins as indicated on the silkscreen for the appropriate pins.

const int rs=D6, en=D7, db4=D2, db5=D3, db6=D4, db7=D5;
LiquidCrystal lcd(rs, en, db4, db5, db6, db7);

--- bill

arduino_new:
I'm having trouble to get the lcd to display the simple message: "Hello World"

Your remapping is ok. Sure that you have a R2?

I am currently testing a sketch for openweathermap and have a Wemos D1 R1 and R2 at hand.

And can confirm

#define D9 2 // GPIO2 maps to Ardiuno D9 for D1 R1
#define D9 13 // GPI13 maps to Ardiuno D9 for D1 R2
LiquidCrystal lcd(D8, D9, D4, D5, D6, D7);

that works.

PS: try and remove the additional LiquidCrystal (from the ~//libraries subdirectory).

the standard from the IDE works without problems. check the library.properties:
name = Liquid Crystal
version = 1.0.7
author = Arduino, Adafruit

mratix:
Your remapping is ok. Sure that you have a R2?

I am currently testing a sketch for openweathermap and have a Wemos D1 R1 and R2 at hand.

And can confirm

#define D9 2 // GPIO2 maps to Ardiuno D9 for D1 R1

#define D9 13 // GPI13 maps to Ardiuno D9 for D1 R2
LiquidCrystal lcd(D8, D9, D4, D5, D6, D7);



that works.

PS: try and remove the additional LiquidCrystal (from the ~/<sketches>/libraries subdirectory).

the standard from the IDE works without problems. check the library.properties:
name = Liquid Crystal
version = 1.0.7
author = Arduino, Adafruit

I found out later that I just had to adjust the screen. Everything was working, I just didn't "see" the text.
+1 anyway