I have a lot of 4 row x 20 character I2C LCD displays kicking around. Are these supported by OpenMV? Personally I don’t see why not, but I couldn’t find any sample code. I’m considering using one to give status readouts from one of my OpenMV cameras.
I think MicroPython just supports that in general. Since we are a MicroPython board you don’t need to look for a driver just for our system:
I cloned his code samples and copied them to a directory on my Windows PC. I try running a sample program and it can’t find the modules lcdapi and i2clcd. There are .py files by those names in the same directory as the test program. How do I get the IDE to find them?
“”“Implements a HD44780 character LCD connected via PCF8574 on I2C.”“”
from lcd_api import LcdApi
from pyb import I2C, delay, millis
from pyb_i2c_lcd import I2cLcd
You need to copy those files from the package you downloaded to the OpeMV Cam’s disk. The IDE is just a text Editor. The camera is what actually compiles and runs the code.
Is that why the code reads “from pyb”?
The camera can only see modules on its own disk. So, when you import stuff they need to be on the camera.
His install requires smbus. I am running the IDE on my Windows 10 machine. How do I install smbus?
Hi, all the libraries needed should be in the source folder you downloaded. Copy them to the OpenMV Cam disk.
smbus isn’t part of the source. Here is what is in there. The lcd1 and lcd2 pictures show what is in the source once downloaded. The openmv_disk is what I copied over to the camera. When I try to run 12c_lcd_test.py, I get the message ImportError: no module named ‘smbus’. Also, if you look at his setup.py file, it has this in it.
from distutils.core import setup
url=‘GitHub - dhylands/python_lcd: Python based library for talking to character based LCDs.’,
description=‘Python library for HD44780 compatible character based LCDs.’,
Most of the samples are for different boards (Adafruit, Grove, Node, ESP32 or PY boards).
Please use the pyb examples. The OpenMV Cam has the same pyb module that the pyb board from MicroPython has. So, that should be what you use. Different MicroPython boards have different hardware abstraction layers. I don’t know what the SMBUS module is.
This is the file you want to use: python_lcd/pyb_i2c_lcd.py at master · dhylands/python_lcd · GitHub
Actually, I think you mean pyb_i2c_lcd_test.py, which calls pyb_i2c_lcd.py.
I’m still not able to get anything to appear on the LCD display, so I’m doing more advanced troubleshooting. Hopefully something will come of this to serve as examples for other users.
Last night, I tested my LCD displays by connecting them to an Arduino UNO. I got two displays working on the UNO, one 16x2 with I2C expander board from Ywrobot and a 20x4 display with I2C expander board from Sunfounder. Both use address 27. See pictures.
I created a test program to run on the OpenMV board to scan the I2C bus and report what it finds. It is coming up with nothing, which might explain why I’m not seeing anything displayed on the LCD. Is there a problem with my test script or is it something with the OpenMV board?
Mmm, scan should work. Question, are there pull up resistors on the I2C lines?
Also, from the pic you swapped SCL and SDA. That will prevent it from working.
I have SDA to SDA and SCL to SCL.
I’m not sure if the boards have pullup resistors. If I recall, they should be 4.7 - 10 kohm?
I added 10K pullups to SDA and SCL, but still no success. My scan program still doesn’t find any I2C devices.
# I2C Scanner Basic - By: Scott Murchison - Fri Jul 19 2019 # simple program to scan I2C bus for connected devices from pyb import I2C i2c = I2C(2, I2C.MASTER) print('Scan i2c bus...') devices = i2c.scan() if len(devices) == 0: print("No i2c devices found !") else: print('i2c devices found:',len(devices)) for device in devices: print("Decimal address: ",device) print("Hex address: ",hex(device))
Can you use this module instead for I2C and try scan?
The machine module bit bangs I2C with pins so it should always work. It’s possible a MicroPython upstream change broke I2C.
I’m trying several programs using
from machine import I2C
but no success so far
from machine import I2C i2c = I2C(freq=400000) devices = i2c.scan() print(devices)
I get TypeError: ‘scl’ argument required
from machine import I2C i2c = I2C(2,4,5,freq=400000) devices = i2c.scan() print(devices)
I get TypeError: extra positional arguments given
i2c = I2C(sda=Pin('P5'), scl=Pin('P4'))