Difference between revisions of "Temp wiki01"
From Waveshare Wiki
Line 26: | Line 26: | ||
Choose Interfacing Options -> SPI -> Yes to enable SPI interface | Choose Interfacing Options -> SPI -> Yes to enable SPI interface | ||
</pre> | </pre> | ||
− | [[File: | + | [[File:RPI_open_spi.png|900px]]<br /> |
Reboot Raspberry Pi:<br /> | Reboot Raspberry Pi:<br /> | ||
<pre> | <pre> | ||
sudo reboot | sudo reboot | ||
+ | </pre> | ||
+ | </pre> | ||
+ | Please make sure that SPI interface was not used by other devices <br /> | ||
+ | I2C is the same, enter the configuration interface and select Interfaceing Options -> I2C -> Yes to open the IIC interface, and then restart | ||
+ | ==Install Libraries== | ||
+ | *Install BCM2835 libraries | ||
+ | <pre> | ||
+ | wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz | ||
+ | tar zxvf bcm2835-1.68.tar.gz | ||
+ | cd bcm2835-1.68/ | ||
+ | sudo ./configure && sudo make && sudo make check && sudo make install | ||
+ | #For more details, please refer to http://www.airspayce.com/mikem/bcm2835/ | ||
+ | </pre> | ||
+ | |||
+ | *Install wiringPi libraries | ||
+ | <pre> | ||
+ | sudo apt-get install wiringpi | ||
+ | |||
+ | #For the Raspberry Pi system after May 2019, it may need to be upgraded | ||
+ | |||
+ | wget https://project-downloads.drogon.net/wiringpi-latest.deb | ||
+ | sudo dpkg -i wiringpi-latest.deb | ||
+ | gpio -v | ||
+ | #You will get 2.52 information if you install it correctly | ||
+ | </pre> | ||
+ | |||
+ | *Install Python libraries | ||
+ | <pre> | ||
+ | #python2 | ||
+ | sudo apt-get update | ||
+ | sudo apt-get install python-pip | ||
+ | sudo apt-get install python-pil | ||
+ | sudo apt-get install python-numpy | ||
+ | sudo pip install RPi.GPIO | ||
+ | sudo pip install spidev | ||
+ | #python3 | ||
+ | sudo apt-get update | ||
+ | sudo apt-get install python3-pip | ||
+ | sudo apt-get install python3-pil | ||
+ | sudo apt-get install python3-numpy | ||
+ | sudo pip3 install RPi.GPIO | ||
+ | sudo pip3 install spidev | ||
+ | </pre> | ||
+ | |||
+ | ==Download Examples== | ||
+ | Open Raspberry Pi terminal and run the following command<br /> | ||
+ | <pre> | ||
+ | sudo apt-get install p7zip-full | ||
+ | sudo wget https://www.waveshare.com/w/upload/2/2c/OLED_Module_Code.7z | ||
+ | 7z x OLED_Module_Code.7z -O./OLED_Module_Code | ||
+ | cd OLED_Module_Code/RaspberryPi | ||
+ | </pre> | ||
+ | |||
+ | ==Run the demo codes== | ||
+ | Please go into the RaspberryPi directory (demo codes) first and run the commands in terminal<br /> | ||
+ | ===C codes=== | ||
+ | *Re-compile the demo codes<br /> | ||
+ | <pre> | ||
+ | cd c | ||
+ | sudo make clean | ||
+ | sudo make -j 8 | ||
</pre> | </pre> |
Revision as of 07:26, 17 January 2022
Hardware connection
Please connect the LCD to your Raspberry Pi by the 7PIn cable according to the table below
OLED | Raspberry Pi | |
BCM2835 | Board | |
VCC | 3.3V | 3.3V |
GND | GND | GND |
DIN | SPI:10 / I2C:2 | SPI:MOSI / I2C:SDA.1 |
CLK | SPI:11 / I2C:3 | SPI:SCLK / I2C:SCL.1 |
Enable SPI interface
- Open terminal, use command to enter the configuration page
sudo raspi-config Choose Interfacing Options -> SPI -> Yes to enable SPI interface
sudo reboot
Please make sure that SPI interface was not used by other devices
I2C is the same, enter the configuration interface and select Interfaceing Options -> I2C -> Yes to open the IIC interface, and then restart
Install Libraries
- Install BCM2835 libraries
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.68.tar.gz tar zxvf bcm2835-1.68.tar.gz cd bcm2835-1.68/ sudo ./configure && sudo make && sudo make check && sudo make install #For more details, please refer to http://www.airspayce.com/mikem/bcm2835/
- Install wiringPi libraries
sudo apt-get install wiringpi #For the Raspberry Pi system after May 2019, it may need to be upgraded wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v #You will get 2.52 information if you install it correctly
- Install Python libraries
#python2 sudo apt-get update sudo apt-get install python-pip sudo apt-get install python-pil sudo apt-get install python-numpy sudo pip install RPi.GPIO sudo pip install spidev #python3 sudo apt-get update sudo apt-get install python3-pip sudo apt-get install python3-pil sudo apt-get install python3-numpy sudo pip3 install RPi.GPIO sudo pip3 install spidev
Download Examples
Open Raspberry Pi terminal and run the following command
sudo apt-get install p7zip-full sudo wget https://www.waveshare.com/w/upload/2/2c/OLED_Module_Code.7z 7z x OLED_Module_Code.7z -O./OLED_Module_Code cd OLED_Module_Code/RaspberryPi
Run the demo codes
Please go into the RaspberryPi directory (demo codes) first and run the commands in terminal
C codes
- Re-compile the demo codes
cd c sudo make clean sudo make -j 8