PoE HAT (B)
| ||
Overview
Introduction
PoE HAT (B) is a Power-over-Ethernet (PoE) expansion board designed for Raspberry Pi 3B+/4B, supporting IEEE 802.3af network standards If you have a PoE router or switch that supports 802.3af network standard, then with this expansion board, you can achieve networking and power supply for your Raspberry Pi with just one network cable.
Features
- Standard Raspberry Pi 40PIN GPIO header, supporting Raspberry Pi 3B+/4B
- PoE (Power Over Ethernet) capability,802.3af-compliant.
- Fully isolated Switch Mode Power Supply (SMPS)
- Onboard 0.91 inch OLED, capable of real-time display of temperature, IP address, fan operation status, etc.
- Supports real-time temperature reading and intelligent heat dissipation, programmable for redefinition
- Onboard cooling fan with fan switch, allowing auto running on power up or being controlled by programming through IO pins
- Onboard PCF8574, 8 I/O ports can be expanded through I2C to directly control the fan
Specifications
- PoE input voltage: 37V ~ 57V DC
- PoE output voltage: 5V 2.5A DC
- Network standard: 802.3af PoE
- OLED control interface: I2C
- OLED size: 0.91inch
- OLED resolution: 128×32
- OLED driver chip: SSD1306
- OLED display color: White
- OLED viewing angle: >160°
- GPIO expansion port: I2C
- GPIO expansion chip: PCF8574
- Dimensions: 65.0×56.5 (mm)
Working with Raspberry Pi
Plug PoE HAT (B) into the Raspberry Pi as shown in the figure below.
Enable I2C Interface
The I2C interface is required for the OLED display, you need to first enable the I2C interface to work properly.
Open the terminal and configure:
sudo raspi-config #Select Interacting Options ->I2C ->yes to start the I2C kernel driver
- Then restart Raspberry Pi
sudo reboot
Libraries Installation for RPi
First of all you need to determine which language to use, C or python. Open the terminal of Raspberry Pi and install libraries as guides below.
C
If you use bookworm system, only the lgpio library is available, bcm2835 and wiringPi libarary cannot be installed or used. Please note that the python library does not need to be installed, you can directly run the demo.
BCM2835
#Open the Raspberry Pi terminal and run the following commands: wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.71.tar.gz tar zxvf bcm2835-1.71.tar.gz cd bcm2835-1.71/ sudo ./configure && sudo make && sudo make check && sudo make install # For more information, please refer to the official website: http://www.airspayce.com/mikem/bcm2835/
wiringPi
#Open the Raspberry Pi terminal and run the following commands: cd sudo apt-get install wiringpi #For Raspberry Pi systems after May 2019 (those earlier may not require execution), an upgrade may be necessary: wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb gpio -v # Run gpio -v and version 2.52 will appear. If it does not appear, there is an installation error #Bullseye branch system uses the following command: git clone https://github.com/WiringPi/WiringPi cd WiringPi ./build gpio -v # Run gpio -v and version 2.70 will appear. If it does not appear, there is an installation error
lgpio
sudo su wget https://github.com/joan2937/lg/archive/master.zip unzip master.zip cd lg-master sudo make install # For more information, please refer to the official website: https://github.com/gpiozero/lg
python
- Install Python function library
#python2 sudo apt-get update sudo apt-get install python-pip sudo pip install RPi.GPIO sudo apt-get install python-smbus #python3 sudo apt-get update sudo apt-get install python3-pip sudo pip install RPi.GPIO sudo apt-get install python3-smbus
Download Demo
wget https://files.waveshare.com/wiki/PoE_HAT_(B)/PoE_HAT_B_code.zip unzip -o PoE_HAT_B_code.zip -d ./PoE_HAT_B_code sudo chmod 777 -R PoE_HAT_B_code
Run Demo
C
Note: C language does not use the library by default, and uses the method of reading and writing the device number. If you need to change it, please modify the Makefile file.
cd PoE_HAT_B_code/PoE_HAT_B_code/c/ make clean make sudo ./main
python
cd PoE_HAT_B_code/PoE_HAT_B_code/python/examples/ sudo python main.py
Rotate
Modify OLED initialization as shown below:
The image is displayed in C language
Set Fan Startup Temperature
#C sudo nano examples/main.c # The last parameter of the POE_HAT_Display() function sets the fan on temperature #python sudo nano examples/main.py # The POE.POE_HAT_Display() function parameter sets the fan on temperature
Set Auto Run on Powerup
Compile and test the demo before setting up startup.
Bullseye and Bookworm
Use the python demo to boot up and create service
sudo nano /etc/systemd/system/POE_OLED_Python_Service.service
Add the following statements:
[Unit] Description=POE OLED Python Service After=network.target [Service] ExecStart=/usr/bin/python3 /home/pi/PoE_HAT_B_code/PoE_HAT_B_code/python/examples/main.py WorkingDirectory=/home/pi/PoE_HAT_B_code/PoE_HAT_B_code/python/examples StandardOutput=journal StandardError=journal Restart=always [Install] WantedBy=multi-user.target
Start the service
sudo systemctl start POE_OLED_Python_Service.service
View the service status
sudo systemctl status POE_OLED_Python_Service.service
Stop the service
sudo systemctl stop POE_OLED_Python_Service.service
Service startup on boot
sudo systemctl enable POE_OLED_Python_Service.service
Disable service startup on boot sudo systemctl disable POE_OLED_Python_Service.service Check if the service starts on boot sudo systemctl is-enabled POE_OLED_Python_Service.service
Use C to create a startup service and change the content in POE_OLED_Python_Service.service to
[Unit] Description=POE OLED Python Service After=network.target [Service] ExecStart=/home/pi/PoE_HAT_B_code/PoE_HAT_B_code/c/main WorkingDirectory=/home/pi/PoE_HAT_B_code/PoE_HAT_B_code/c/ StandardOutput=journal StandardError=journal Restart=always [Install] WantedBy=multi-user.target
Note:
ExecutStart specifies the full command for executing Python scripts, ensuring that /usr/bin/python3 is the correct Python interpreter path, which can be confirmed with the command which python3. If it is in C language, simply point to the executable file directly.
WorkingDirectory is the directory where the script is located. Make sure that WorkingDirectory is set to the directory where the script is located, which ensures that the relative path of the script starts from that directory during execution.
StandardOutput and StandardError send output and error messages to the system log.
Restart=all means that if the demo crashes or exits, the system will automatically restart the service.
Other Old Raspberry Pi OS Systems
sudo nano /etc/rc.local
Set to start up automatically. Add sudo /home/pi/Fan_HAT/c/main & before exit 0. Note that you must add "&" to run in the background. Otherwise, the system may not be able to start.
fi sudo /home/pi/PoE_HAT_B_code/PoE_HAT_B_code/c/main & exit 0
Resources
Demo
Related Resources
Third-Party Programs
- Before using third-party programs, please use our demo to ensure that there are no hardware issues. We do not maintain third-party programs, we only recommend them
- Raspi PoE HAT Monitor
- RustBerry-PoE-Monitor
- The Waveshare team would like to thank all the developers for their support!
Support
Technical Support
If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)