casychow / DesktopPet_Eui

A small, mobile desk robot that helps alleviate the physical, emotional, and mental problems frequently faced by desk workers. This is my NYU Tandon Senior Design Project.
0 stars 0 forks source link

testing display subsystem #9

Closed qyc206 closed 3 years ago

qyc206 commented 3 years ago
ffund commented 3 years ago

References

ffund commented 3 years ago

Test part on I2C bus

Follow instructions in 1.3.3 Connect the SSD1306 OLED screen and 1.3.4 Scan the I2C bus and find OLED screen address of the lab manual, and make sure you get the same output.


Show photograph of connection, and show terminal output when you scan the I2C bus.

ffund commented 3 years ago

Verify download of adafruit oled library

Library is at https://github.com/adafruit/Adafruit_Python_SSD1306

Install the library with

git clone https://github.com/adafruit/Adafruit_Python_SSD1306.git
cd Adafruit_Python_SSD1306
sudo python3 setup.py install

Make sure you can run python3 and in the Python terminal, run

import Adafruit_SSD1306

without error (to verify the library installation).

We need to add an install_requires to setup.py so that it has this library as a pre-requisite. See this link. After adding this, test by running the install for the eui library again, and make sure it checks that the SSD1306 library is installed.


Show:

casychow commented 3 years ago

Importing Adafruit_SSD1306 library: image

casychow commented 3 years ago

Installed Adafruit_SSD1306 library successfully. Then followed lab instructions 1.3.3 and 1.3.4 to display the cat picture onto the OLED screen. After that was finished, I then looked into the other files in the Adafruit OLED github page. I was able to run the animate.py and shapes.py files by commenting out the first disp line of code and uncommenting the second disp line of code. The end result is as follows.

# 128x32 display with hardware I2C:
# disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST)

# 128x64 display with hardware I2C:
disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST)

This was done for image.py, animate.py, and shapes.py

casychow commented 3 years ago

Added the following code to setup.py file.

install_requires=['Adafruit_Python_SSD1306']
dependency_links=['git+https://github.com/adafruit/Adafruit_Python_SSD1306']

Got the following error before I added the dependecy_links line. I had to interrupt the reading because it was taking a long time.

image

After adding the dependency_links line, I got this error:

image

I then changed the command from sudo python3 setup.py install to pip install stubby_eui which gave me the following error:

image

I'm not sure where the websites (https://pypi.org/simple, https://www.piwheels.org/simple) are showing up.

casychow commented 3 years ago

From the previous error, I tried the following (using this website as the error reference)

https://stackoverflow.com/questions/50807507/could-not-install-packages-due-to-a-environment-error-error-13-permission-d image

https://stackoverflow.com/questions/59640898/could-not-install-packages-due-to-an-environmenterror-404-client-error image

I think I need to use the requirements.txt method. I previously saw some users criticize that method so I was initially against it, but I will try it before asking the professor for assistance.

casychow commented 3 years ago

Used the following command to create a requirements.txt file: pip3 freeze > requirements.txt image Found from this link: https://stackoverflow.com/questions/31684375/automatically-create-requirements-txt

Deleted the dependency_links line from the setup.py file. End result: image

Issue: not sure how to install setup.py file. Forgot to document it last time.

Result 1 (same error as above): image

Result 2 (didn't work because of same issue as last time): image

Result 3 (after reading error message and changing the install_requires, which changes the https://pypi.org/ link): from install_requires=['Adafruit_Python_SSD1306'] to install_requires=['Adafruit-SSD1306'] Finished installing image

qyc206 commented 3 years ago
Screen Shot 2021-03-22 at 1 33 07 PM

I was also able to install

casychow commented 3 years ago

Pi connections to OLED screen image

casychow commented 3 years ago

In lieu of filling the display functions in the stubby_eui.py file, I tried to wire the OLED again. I turned on I2C and followed the instructions in the lab manual (linked above), but to no avail. The i2cdetect -y 1 command does not work: it does not show any i2c devices. However, the lsmod | grep i2c command does work (I think). image

casychow commented 3 years ago

Works now. Think it was just needing to turn on i2c at the start instead of turning it on half way and needing to reset the connection.

Turn on spi/i2c using sudo raspi-config and check with lsmod | grep i2c

In case OLED/i2c connection is broken, use the following commands: disable the I2C driver with sudo rmmod i2c_dev sudo rmmod i2c_bcm2835

re-enable it with sudo modprobe i2c_dev sudo modprobe i2c_bcm2835

image

Can upload custom image after cloning repository on my computer computer.