Request RAK811 PWM sample c code

Hi, does anyone has come across with PWM c code sample? I am developing a light control app using RAK811 with dimming function, appreciate it if you can provide a sample c code for reference. Thanks.

Hi @fangfchen,

You use RAK811 connect with a light sensor, and you want to use an APP to control this sensor through RAK811 over LoRaWAN, right?

Hi, I am using RAK811 to send PWM signal to control LED light illuminance, I also need to connect to a light sensor using i2c in this project. Do you have a sample code to share that will be great.

Hi @fangfchen,

Yes, we’ve made several product practice sample based on RAK811, you can find their source code here:

In RAK5205 and RAK7204 product folder, we’ve shared how to connect an I2C sensor with RAK811 using RUI API. I think it may be useful for your use case.

Thanks, I have already reading on it, however I can’t see PWM part, do you have other samples?

Sorry,PWM function is not yet supported. These features will be refined over time .

Can I ask what ETA will be released PWM feature?


We have add 1 channel PWM function at RAK811 pin_num 2(For RUI use only).
You can use RUI:
RUI_RETURN_STATUS rui_pwm_init(RUI_PWM_ST pwm_st);* to initialize PWM.
RUI_RETURN_STATUS rui_pwm_start(RUI_PWM_ST pwm_st);* to start PWM.
RUI_RETURN_STATUS rui_pwm_stop(RUI_PWM_ST pwm_st);* to stop PWM.
typedef struct RUI_PWM_ST {
** RUI_GPIO_ST rui_gpio;**
** uint32_t frequency; //frequency <= 160000*dutycycle in RAK811**
** uint8_t dutycycle; //value range:0~100 **

How to use it ,pls refer to :
Init and Start PWM pls refer to this C code:

The sample PWM code tested working fine. Thanks!

Hi Wang, according to the last few days tested on the PWM signal, I have found it did not working stably when lora in the communication, resulting the led light flashes intermittently. Could you have a look again if this feature can be improved. Also rui_pwm_stop(&TEST_PWM) seems does not work. Thanks.

how set network settings in examples RUI, i want connect to my gateway and send datafor example “AABBCC”)?