CM4 RTC FAN

From Waveshare Wiki
Jump to: navigation, search

RTC FAN

To enable the I2C for controlling the fan and the RTC, you need to add the line "dtparam=i2c_vc=on" in the config.txt file.
RTC is connected to i2c-10 with address 0x51 (7bits)
FAN is connected to i2c-10 with address 0x2f (7bits)

sudo nano /boot/config.txt
Add the following line to the end of the config.txt
dtparam=i2c_vc=on
And then comment out the line dtparam=audio=on
#dtparam=audio=on
Save the file and reboot the system
sudo reboot

RTC test

1. Download the test demo.

Open the terminal of the Raspberry Pi, and enter the following command:

sudo apt-get install p7zip-full
sudo wget https://files.waveshare.com/upload/4/42/PCF85063_code.7z
7z x PCF85063_code.7z -O./
cd PCF85063_code

2. Run the demo

C

Execute the following commands to compile and execute the test demo:

cd c
sudo make clean
sudo make -j 8
sudo ./main

And then you can check the running result as below:

RTC PCF85063 c test.png

Python

Enter the python/example directory:

cd python/example

Then run the Python demo, the demo can support python2/3.

# python2
sudo python main.py
# python3
sudo python3 main.py

The running result as below:

RTC PCF85063 python test.png

FAN test

【Note】Please connect the fan first before connecting the power to the Board! Please do not connect the fan to the Board when the board is powered on (the fan control chip is powered on), otherwise, it will be damaged!

Open the terminal of the Raspberry Pi, and enter the following command:

sudo apt-get install p7zip-full
sudo wget https://files.waveshare.com/upload/5/56/EMC2301_code.7z
7z x EMC2301_code.7z -O./
cd EMC2301_code

C

Compile and execute the test demo:

cd c
sudo make clean
sudo make -j 8
sudo ./main

python

Enter the python/example directory:

cd python/example

And then run the Python demo, the demo can support python2/3

# python2
sudo python main.py
# python3
sudo python3 main.py

The fan will run the variable speed test in RPM mode. Pay attention to the changes in the fan's sound. The Python demo is the same as the C program. The terminal will output the relevant data of the fan at the same time, as shown in the picture below:

FAN EMC2301 test.png

You can also directly control the fan speed by modifying the parameters of the demo.