Blue Pill & 2×16 I2C LCD display not working together

Chacal
Fri Jan 29, 2016 10:00 pm
Hi all,

I’m having some problems getting my generic STM32F103C8T6 board (Blue Pill) to work with my 2×16 I2C LCD display.

I’m using LiquidCrystal_I2C library bundled with STM32duino and the following code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
pinMode(PC13, OUTPUT);
lcd.init();
}

void loop() {
digitalWrite(PC13, HIGH);
delay(500);
digitalWrite(PC13, LOW);
delay(500);
lcd.print("Hello world");
}


RogerClark
Sat Jan 30, 2016 3:36 am
OK

If the I2C scanner finds the device, then its wired up OK

So the issue is in the library, or your use of it.

In general you can’t expect a AVR library to work on the STM32.

Well, a lot of libraries work fine.

But the presumption I normally make is that a library may not work because they are often designed to use AVR specific functionality

Anyway

Post a link to the library, beause the only one I found that seemed to match was

http://wentztech.com/radio/arduino/files/LCDI2C.html

and it looks like you didnt call the functions correctly, i.e wrong paramaters were being passed


zmemw16
Sat Jan 30, 2016 4:34 am
‘m using LiquidCrystal_I2C library bundled with STM32duino ??

RogerClark
Sat Jan 30, 2016 4:39 am
Looking at the commit for that library, it was submitted by someone from the Arduino.cc forum

http://forum.arduino.cc/index.php?topic … msg2186521

I have not tested individual libraries, as life is too short ;-)

Check that your LCD hardware is the device that the library was intended to work with, and after that see if you can contact the person who submitted it to me

i.e look in

http://forum.arduino.cc/index.php?topic … msg2186521


Chacal
Sat Jan 30, 2016 6:29 am
Thanks for your replies! :)

Yep, the library I used is indeed this one: https://github.com/rogerclarkmelbourne/ … rystal_I2C

I (too) simply presumed it had been deemed as working as it came with the stm32duino and was also mentioned here http://www.stm32duino.com/viewtopic.php?f=13&t=274, but apparently this is not as straightforward as I thought. :D

I’ll try to dig in to the library & contact the original author.

Btw.. Has anyone used these characted LCD:s with STM32 using some other library?

Thanks again! :)


Chacal
Sat Jan 30, 2016 7:22 am
Just another quick update on this one.

I got the LCD working using this version of the LiquidCrystal_I2C library: https://github.com/fdebrabander/Arduino … 2C-library

For me it seems that the version bundled with stm32duino is newer (there is “Version 2.0” mentioned in the header file), but for some reason it doesn’t work for me. If I just find enough time & energy, I’ll try to figure out why. :)


RogerClark
Sat Jan 30, 2016 9:00 am
Ok

Thanks for the update


mrburnette
Sat Jan 30, 2016 10:30 pm
Chacal wrote:
<…>
For me it seems that the version bundled with stm32duino is newer (there is “Version 2.0” mentioned in the header file), but for some reason it doesn’t work for me. If I just find enough time & energy, I’ll try to figure out why. :)

ddrown
Tue Feb 02, 2016 2:39 am
Chacal wrote:Hi all,

I’m having some problems getting my generic STM32F103C8T6 board (Blue Pill) to work with my 2×16 I2C LCD display.

I’m using LiquidCrystal_I2C library bundled with STM32duino and the following code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
pinMode(PC13, OUTPUT);
lcd.init();
}

void loop() {
digitalWrite(PC13, HIGH);
delay(500);
digitalWrite(PC13, LOW);
delay(500);
lcd.print("Hello world");
}


ddrown
Tue Feb 02, 2016 2:50 am
Chacal wrote:Just another quick update on this one.

I got the LCD working using this version of the LiquidCrystal_I2C library: https://github.com/fdebrabander/Arduino … 2C-library

For me it seems that the version bundled with stm32duino is newer (there is “Version 2.0” mentioned in the header file), but for some reason it doesn’t work for me. If I just find enough time & energy, I’ll try to figure out why. :)


ddrown
Wed Feb 03, 2016 3:50 am
ddrown wrote:Chacal wrote:Just another quick update on this one.

I got the LCD working using this version of the LiquidCrystal_I2C library: https://github.com/fdebrabander/Arduino … 2C-library

For me it seems that the version bundled with stm32duino is newer (there is “Version 2.0” mentioned in the header file), but for some reason it doesn’t work for me. If I just find enough time & energy, I’ll try to figure out why. :)


zmemw16
Wed Feb 03, 2016 3:54 am
if memory serves, compile will tell you the multiple libraries and which one it used.

as i normally run full warnings, i’m playing with warning/message pragmas and #ifdef etc; it’s visible

stephen


RogerClark
Wed Feb 03, 2016 4:54 am
OK.

So I guess we should get rid of the one that was contributed as the standard one works ??


mrburnette
Wed Feb 03, 2016 1:42 pm
RogerClark wrote:OK.

So I guess we should get rid of the one that was contributed as the standard one works ??


ddrown
Wed Feb 03, 2016 3:28 pm
zmemw16 wrote:if memory serves, compile will tell you the multiple libraries and which one it used.

as i normally run full warnings, i’m playing with warning/message pragmas and #ifdef etc; it’s visible

stephen


RogerClark
Wed Feb 03, 2016 7:37 pm
Ok.

Can someone post this as an issue on github, so i remember to remove it ?


ddrown
Thu Feb 04, 2016 2:32 am
RogerClark wrote:Ok.

Can someone post this as an issue on github, so i remember to remove it ?


RogerClark
Thu Feb 04, 2016 2:55 am
Thanks..

That’s saved me a load of work.

I’ve actioned the pull request on the server, as I don’t need to pull etc to do this, as there is nothing to test, i.e as its just a removal

Thanks again

Roger


Slammer
Fri Apr 08, 2016 12:17 am
FYI
The LiquidCrystal_I2C library from the “official” author is working without modifications. Now the new library NewLiquidCrystal has encapsulated all known types of hardware connections, I2C included (actualy is a super library)
You will find the library here : https://bitbucket.org/fmalpartida/new-l … /wiki/Home
I didn’t test other types of connection, only I2C.
Only these files are needed for I2C:

I2CIO.h/cpp
LCD.h/cpp
LiquidCrystal_I2C.h/cpp

At stm32 part, I used Wire library with PB6=SCL and PB7=SDA
Two pullup 4K7 resistors at I2C are necessary.
LCD is a typical 16×2 device connected with these dirt cheap boards with PCF8574 (priced about 1$, many call them as LCM1602IIC)

Here is the definition line of lcd:
LiquidCrystal_I2C lcd(0x20,2,1,0,4,5,6,7,3,POSITIVE); /// Definition LCM1602 IIC


Slammer
Sat Apr 30, 2016 1:35 am
The LiquidCrystal_I2C is working also with HardWire untouched… (only the Class Wire must be renamed to HWire in I2CIO)

zmemw16
Sat Apr 30, 2016 6:52 pm
for i2c pullups, i tend to use 3k3 or 4k7 for 3.3v and 5v respectively. actually, using 3k3 and 5k1 would maybe make it clearer.

pulling the bluepill i2c lines to 3v3 with 3k3 – avoids any issue with 5v levels, switching levels are below 3v3, usually ttl, about 2v4 istr

stephen


bhaskins
Sat Aug 20, 2016 8:35 pm
I want to post this for others that might be following this thread and not having any luck.
I have had good results by using +5 to the display, a level shifter, and a non stm32duino program.
I have never had any luck while just using 3.3 volts even while trying to use the 4-bit parallel software.
The stm32duino programs compile and download fine but no display.
Believe me, I think I’ve tried just about every combination and at lest five different displays.
I’m using PB6 and PB7 and did use pullups with the setups that failed.
The traces on my much loved Tek 2232 looked fine, just no display in fact, not even boxes.
To add to this, the working setup does not work when powered through the ST-Link.

What’s the trick to operating on 3.3 volts.

Please comment!
FWIW please don’t take this as a negitive comment, I’ve had good luck with most of the other stuff.
Thanks,
Bert


Leave a Reply

Your email address will not be published. Required fields are marked *