# Controlling I2C fan on UCTRONICS PoE hat for Pi?



## `Orum (May 24, 2021)

I've got a Raspberry Pi 4B, with a PoE hat on it from UCTRONICS.  This hat has a fan on it, which spins down when it's not needed under the Pi OS.  I'm trying to get the same behavior under FreeBSD, but I'm still not sure how.  From what I've read, this fan should be controllable via I2C, which isn't even exposed by default.  After a bit more investigation, I found it had to be enabled by adding `dtparam=i2c_arm=on` to /boot/msdos/config.txt.  However, even then the fan doesn't appear during a scan:

```
i2c -f /dev/iic0 -sv                                               
dev: /dev/iic0, addr: 0x40100401, r/w: r, offset: 0x00, width: 8, count: 1     
Hardware may not support START/STOP scanning; trying less-reliable read method.
Scanning I2C devices on /dev/iic0: <none found>
```
I've also added the following to /boot/loader.conf and rebooted/retied just in case they helped:

```
iicsmb_load="YES"
smbus_load="YES"
...
# dmesg | grep iic
iichb0: <BCM2708/2835 BSC controller> mem 0x7e804000-0x7e804fff irq 26 on simplebus0
iicbus0: <OFW I2C bus> on iichb0
iic0: <I2C generic I/O> on iicbus0
iicsmb0: <SMBus over I2C bridge> on iicbus0
smbus0: <System Management Bus> on iicsmb0
```
...but my results didn't change.

I've read through Thread 77825, and I suspect I need something like he used in post #8.  However, he's using a different hat and trying to get different information, so I'm not sure it would be appropriate in my situation.  Unfortunately, the link to the mailing list post seems to be broken, so while I'd like to read the whole thread there, I've not yet found it.  Any ideas?


----------



## T-Daemon (May 24, 2021)

Maybe this is what you are looking for (from Thread 77825 linked e-mail thread):



			Porting FreeBSD to ARM processors: Re: I2C/IIC working on RPI4 8GB?
		


If not, the mailing list thread starts below:


			Porting FreeBSD to ARM processors: I2C/IIC working on RPI4 8GB?
		

continues:




__





						freebsd-arm@FreeBSD.org
					





					lists.freebsd.org


----------



## `Orum (May 24, 2021)

Thanks, reading through that thread was definitely worth it.  It appears these can simply be set after the system is up and running via sysctl(8). However, I'm not sure which pins I need to change (or even if changing them to alt0 is correct), so I'll have to investigate further about settings specific to the PoE hat.

*Edit:* After reading a bit more, I found an overlay to load for the hat, rpi-poe. Unfortunately, loading this doesn't seem to help; the fan still runs even though `sysctl dev.cpu.0.temperature` reports 33 to 35C, and this tells me it should never be on below 38C. Also of note, loading this overlay is not necessary for fan control when using Pi OS, but that may control it in a more manual fashion from a daemon for all I know.


----------

