Using the Newhaven I2C 2x20 char Display NHD-C0220BIZ-FSW-FBW-3V3M

I recently received a question from forum user @jeanphilippe about how to connect and use a NewHaven I2C display with an imp, so here’s a bit of a schematic to get you started.

Note that this block does not show the I2C pullups, which are required. Pull SCL and SDA up to 3.3V, each with their own 4.7kΩ resistor.

Thank you @tbyrne.

My schematic is almost the same (except I am not driving the backlight yet).
I reused the st7036 class of the Janice reference, but nothgin is happening. Could you confirm that my debug script is correct?
`/* I2C Display Module */
class st7036{
_i2c = null;
_addr = null;
constructor(i2c, addr = 0x78)
{
_i2c = i2c;
_addr = addr;
//This magical line came straight from the datasheet code example
// 0x38 = 2-lines, Single Height, Instruction 00 = ??
// 0x39 = 2-lines, Single Height, Instruction 01 = Bias Set
// 0x14 = Bias Set = 1/4 Bias
// 0x78 =
_i2c.write(_addr, format("%c%c%c%c%c%c%c%c%c%c", 0x00, 0x38, 0x39, 0x14, 0x78, 0x5E, 0x6D, 0x0C, 0x01, 0x06));
}

function write(str)
{
_i2c.write(0x78, format("%c%s", 0x40,str));
}
}

i2c <- hardware.i2c12;
i2c.configure(CLOCK_SPEED_10_KHZ);

Rst <- hardware.pin7;
Rst.configure(DIGITAL_OUT_OD_PULLUP);

Rst.write(0);
imp.sleep(0.1);
Rst.write(1);

disp <- st7036(i2c);

disp.write(“Hello”);`

Thank you!

Oh I found the issue.

It is an old (and well known) hardware issue…
I am using the I2C12, and the SCL pin (pin1) was not properly connected to the imp card because of the SD socket of the April board…
The code runs well now.
Thank you @tbyrne for the support!

Best regards,

For those who want to tinker with this low cost display, the following code may be of interest. I adapted the st7036 class to drive both lines of the LCD.

`/* I2C Display Module */
class st7036{
_i2c = null;
_addr = null;
constructor(i2c, addr = 0x78)
{
_i2c = i2c;
_addr = addr;
//This magical line came straight from the datasheet code example
// 0x38 = 2-lines, Single Height, Instruction 00 = ??
// 0x39 = 2-lines, Single Height, Instruction 01 = Bias Set
// 0x14 = Bias Set = 1/4 Bias
// 0x71 = Contrast set {0x70…0x7F}
// 0x5E = Power/ICON
// 0x6D = Follower control
// 0x0C = Display ON, cursor OFF
// 0x01 = Clear display
// 0x06 = Entry mode set
_i2c.write(_addr, format("%c%c%c%c%c%c%c%c%c%c", 0x00, 0x38, 0x39, 0x14, 0x71, 0x5E, 0x6D, 0x0C, 0x01, 0x06));
}

function write(str) { _i2c.write(_addr, format("%c%s", 0x40,str)); }
function cls() { _i2c.write(_addr, format("%c%c",0x00,0x01)); }
function line1() { _i2c.write(_addr, format("%c%c",0x00,0x80)); }
function line2() { _i2c.write(_addr, format("%c%c",0x00,0xC0)); }
}`

Here is how to use it:

`
i2c <- hardware.i2c12;
i2c.configure(CLOCK_SPEED_50_KHZ);

//Do not forget to reset the LCD (Rst pin active LOW)
disp <- st7036(i2c);

disp.line1();
disp.write(“123456”);
disp.line2();
disp.write(“abcdef”);`

have fun :slight_smile: