Interrupt Pin on RAK811

I have attached interrupt pin on RAK811 in RUI

void SensorInterrupt(void)



rui_lora_get_status(false,&app_lora_status);  //The query gets the current status
    case RUI_AUTO_ENABLE_SLEEP:rui_lora_set_send_interval(RUI_AUTO_ENABLE_SLEEP,app_lora_status.lorasend_interval);  //start autosend_timer after send success
    case RUI_AUTO_ENABLE_NORMAL:rui_lora_set_send_interval(RUI_AUTO_ENABLE_NORMAL,app_lora_status.lorasend_interval);  //start autosend_timer after send success


void bsp_int_init(void)
Sensor_Power_Ctl.pin_num = SENSOR_PWR_CTL;
Sensor_Power_Ctl.dir = RUI_GPIO_PIN_DIR_INPUT;
Sensor_Power_Ctl.pull = RUI_GPIO_PIN_NOPULL;

rui_gpio_interrupt(true, Sensor_Power_Ctl, RUI_GPIO_EDGE_FALL, RUI_GPIO_IRQ_HIGH_PRIORITY, SensorInterrupt);


The source of interrupt is come from the comparator circuit of the sensor.
At the beginning, the interrupt is fired by the sensor, however after a while,
the interrupt is not fired. The sensor output is OK, because I can see the LED
that connected the sensor output is blinking.

Is there any setup that have to be done to make the interrupt pin working, continuously ?


Hi @mamanbudiman,

Which pin do you use to interrupt? What is the value of SENSOR_PWR_CTL?

Hello @Sucre

#define SENSOR_PWR_CTL 16 //PB5

The value is HIGH or LOW. It is come from the comparator circuit. TP2021

Hello @Sucre,

The other problem is that the RAK811 is stop updating the data, after 6 hours running.

The pin you use are OK. Is there sleep wake-up operation before pin interrupt failure?

Does “stop updating” mean that rak811 cannot send data to the gateway?

The interrupt is occurred randomly, some time the interrupt will wake-up the operation, and the other is not.

Due to the Lorawan OTAA is very tight timing, which is better OTAA or ABP ?

Hello @Sucre.
Yes, the RAK811 do not send the data. I have to reset the RAK811 module to resume the operation.

Is there any code to resume the operation, automatically, when the RAK811 fail to send the data ?


From the code, I see that you use falling edge trigger, and it is recommended to set the pin to internal pull-up.

Compared with ABP, OTAA has one more step to join. There’s no difference in anything else.

Hello @Sucre,

Do you have any suggestion to run RAK811 module as follow
get ADC measurement every 100 ms, send update data every 30 minutes,
in low-power environment.

I have tried to make a program in RUI. I am using timer to wake-up the ADC measurement, and going to sleep after measurement. The program is running for a while, and will be no-operation after about 60 seconds.


What is the use case that requires you to check the value every 100ms, as that means you aren’t sleeping much before waking it for the ADC to run.

Can you post your entire code to a gist or on here?

I have a sensor for water meter application. The current consumption is about 2.5mA. I want to decrease the current consumption of the sensor using gated-power to the sensor. Gated-power can be provided by the GPIO pin of the RAK811, and get the ADC measurement from the ADC pin.

I can add other low power MCU to do the task, but I think it is not a good solution.
here is my code


I think the other problem is the debug print log.
Is it possible to turn off the debug print log of the RUI ?


The serial port printing interface is "RUI_LOG_PRINT”。 If you don’t want them, comment them out. However, printing inside the system cannot be turned off.

After the module sleeps, it can wake up through the edge signal of RX pin and RTC.
If you need to perform the operation regularly, you need to start a timer wake-up module to perform the operation.
The wake-up frequency of 100ms is a challenge to the power consumption of the module.

Ok, so the message of “Go to Sleep”, “Wake up” are the printing inside the system.
So can not be turned off. I suppose that the RAK811 can not continue the operation is
due to the printing.

Yes, I use the timer to wake-up regularly.

But why - what is it that the sensor needs that you have to wake every 100ms?

You aren’t going to get much power saving if you wake every 100ms - a fair amount but nothing like sleeping for 30 minutes at a time.

I have developed an optical sensor similar with the TI sensor.

As you can see in the link above, the current consumption of the sensor is depend on the sampling rate.

I’m still not clear about the 100ms - is that how often you poll the device for a reading?

Personally, I’d look at some of Microchip’s latest offerings, many of which, like the MSP430, allow peripherals like counters to run whilst the rest of the chip is shut down, but on a much smaller pin count. You can then use I2C to transfer over a reading at much greater intervals, allowing the RAK811 to sleep longer - and even incorporate a wake-up interrupt if there a reading overflow may come up!

Yes, the 100ms sampling time is the highest polling time for the device to be reading. If higher than 100ms, may be we can lost the measurement.

The MCU of RAK811, STML151 actually offering some of power modes, as you can see in the datasheet.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.