How to interact with the OpenWrt service picod on the command line via ubus

By MyTechCatalog, 1 May, 2023

The CM4-WRT-A software repository includes a service called picod whose purpose is to communicate with the Raspberry Pi Pico, collecting periodic measurements from six temperature sensors and system fan tachometer on the CM4-WRT-A board.

Viewing Board Status

The status of the board can be queried by running the following command: ubus call picod status. The result of which, is shown below:

root@gateway2:~# ubus call picod status
	"fan_pwm_pct": {
		"System_Fan_J17": 50,
		"CM4_FAN_J18": 50
	"watchdog": {
		"is_enabled": "false",
		"timeout_sec": 10,
		"max_retries": 0
	"temperature_c": {
		"PCIe_Switch": "34.9",
		"M.2_Socket_M_J5": "31.0",
		"M.2_Socket_E_J3": "30.5",
		"M.2_Socket_M_J2": "29.6",
		"RPi_Pico": "34.6",
		"Under_CM4_SOC": "34"
	"tachometer_rpm": {
		"System_Fan_J17": 3480,
		"CM4_FAN_J18": 0

Checkout the OpenWrt ubus technical reference: 

Listing picod Procedures/Methods and Arguments

To find out which procedures/methods the picod service provides, as well as their argument signatures, run this command: ubus -v list picod

Listing picod Procedures/Methods and Arguments.

Changing the FAN Speed

You can change the fan speed by updating its PWM setting. In the example below, a call to the fan_pwm method of picod is made with the argument fan_pwm_pct set to 80 percent. The default PWM setting is 50 percent.

root@gateway2:~# ubus call picod fan_pwm '{"fan_name":"System_Fan_J17", "fan_pwm_pct":50}'

Change CM4-WRT-A fan speed

Fetching the Current PWM Setting

If the fan_pwm_pct argument is omitted, its current value is returned.

root@gateway2:~# ubus call picod fan_pwm '{"fan_name":"System_Fan_J17"}'

Get CM4-WRT-A PWM setting

Enabling/Disabling the Watchdog

The watchdog is disabled by default, however you can enable it via a setting in the picod config file (/etc/picod.conf), or on the command line as shown in the example below: 

root@gateway2:~# ubus call picod watchdog '{"is_enabled": true, "timeout_sec": 10, "max_retries": 0}'
	"is_enabled": "true",
	"timeout_sec": 10,
	"max_retries": 0

Subscribing to picod Events

You can also subscribe to picod notifications to receive temperature and fan speed updates:

root@gateway2:~# ubus subscribe picod
Subscribing to picod events on CM4-WRT-A router

Changes made via the command-line will not persist after a reboot or restart of the service picod. If you would like to make the changes permanent, update the config file instead (/etc/picod.conf).