RAK19007 + RAK11720 button detection issue

Please include the following information, in order for us to help you as effectively as possible.

  • What product do you wish to discuss?
    RAK11720 mounted on RAK19007

  • What firmware are you using?
    RUI3

  • What firmware version? Can it be obtained with AT+VER=?
    RUI_BOOT_0.3_RAK11720

  • Computer OS? (MacOS, Linux, Windows)
    MacOS

  • What Computer OS version?
    Sonoma 14.7

  • How often does the problem happen?
    Always

I connected a RAK11720 to a Wisblock core RAK19007
The board has many outputs, but the one I will be mentioning is IO1, IO2 and BOOT

I want to connect a button and detect button presses, and to do this I am using #include <ezButton.h>
(EzButton by ArduinoGetStarted.com, 1.0.6)

To find the pin name I refered to RAK-APOLLO3-RUI/variants/WisCore_RAK11720_Board/variant.h at main · RAKWireless/RAK-APOLLO3-RUI · GitHub

Here I find

#define P4 4//IO2
#define P41 41//BOOT0 - SWO
#define P38 38//IO1

I verified that it was the correct ones by doing a simple sketch such as

void setup() {
  pinMode(P4, OUTPUT);
}

void loop {
digitalWrite(P4, HIGH);
delay(5000);
digitalWrite(P4, LOW);
}

I then used a multimeter to measure the voltage of the tested pin.

I found that the IO pins were 1.8 V when HIGH, and the BOOT pin was 3.3 V when HIGH.

I then connected a simple sketch that, when the button is pressed, connected one of the IO or BOOT pin to GND.

Then setup a sketch (Sketch simplified, removing Serial.begin() etc)

#include <ezButton.h>
ezButton button(P4);

void setup() {
}

void loop {
  button.loop();
  int btnState = button.getState();
  Serial.println(btnState);
}

When using the BOOT pin this sketch worked, and btnState changes state when button is pressed.
But when using the IO1 or IO2 pins there was no change in state for btnState when the button was pressed.

Is there something special about the IO ping that I am missing, which prevents the button detection from working?
I did expect the IO pins to work better than the re-purposed BOOT pin.
I was not expecting the IO pins to have a stepped down voltage as well.

(a) The firmware version you mentioned is from the bootloader, not from the RUI3. Can you use AT+VER again? Are you sure your code is running?

(1) not sure how you measure, but on my RAK19007 with RAK11720, the voltage levels on WB_IO1 and WB_IO2 (P38 and P4) are 3.3V

(2) You can use the **WB_IOx* names in your code instead of searching for the Pxx names.

(3) WB_IO2 is used to control a separate 3.3V supply (3V3_S) for the sensor modules to control the supply of these modules. It is not recommended to use this pin as general GPIO

(4) BOOT pin has special function during boot up. I would not recommend to use this pin as a GPIO.

(5) Using a simple ‘attachInterrupt(WB_IO1, button_int, RISING);’ worked fine to detect a close event (pull to high). I am not sure what the library you are using is doing. But RUI3 is not compatible with all Arduino libraries. There might be functions in that library that are not working with RUI3.

My working examples code, I connected WB_IO1 and WB_IO2, so everytime WB_IO2 goes to high, the interrupt on WB_IO1 is triggered.

#include <Arduino.h>


void button_int(void)
{
	Serial.println("WB_IO1 int for rising to high");
}

void setup()
{
	pinMode(WB_IO2, OUTPUT);
	pinMode(WB_IO1, INPUT_PULLDOWN);
	attachInterrupt(WB_IO1, button_int, RISING);
}

void loop(void)
{
	digitalWrite(WB_IO2, HIGH);
	// digitalWrite(WB_IO1, HIGH);
	delay(5000);
	digitalWrite(WB_IO2, LOW);
	// digitalWrite(WB_IO1, LOW);
	delay(5000);
}

Hmm interesting. Maybe there is some issue with the board since the 1.8V output on the IO pins is not expected.
I have multiple RAK11720 so I connected another one on the Wisblock

AT+VER=RUI_4.1.1_RAK11720

I flashed a simple sketch

void setup() {
  Serial.begin(115200, RAK_AT_MODE);
  Serial.println("15 second delay..");
  delay(15000);
  Serial.println("Done! Starting..");

  pinMode(P4, OUTPUT);
  pinMode(P37, OUTPUT);
  pinMode(P38, OUTPUT);
  pinMode(P41, OUTPUT);
}


void loop() {
  digitalWrite(P4, HIGH);
  digitalWrite(P37, HIGH);
  digitalWrite(P38, HIGH);
  digitalWrite(P41, HIGH);
  Serial.println("still on");
  delay(5000);
}

I then connected my multimeter to GND on the Wisblock, and the other lead I tested against IO1, IO2 and BOOT

IO1 - 1.9V
IO2 - 1.9V
BOOT - 3.3V

This is while connected to the computer over USB-C
I then connected with battery, and the same behaviour was still there.

I tried replacing with WB_IO1 and WB_IO2 but they are still at 1.9V

Your interrupt sketch works well however, so maybe the low voltage on the IO pins doesn’t affect what I want to do, but I still would like to know why two RAK11720 boards does not behave in the expected way when it comes to the IO pins.

Also, the reason I also tried the BOOT pin is because on the smaller wisblock board the BOOT pin is the only usable OI pin.
What is the downside of using this as a IO pin?

If you use BOOT as an input and have an external circuit that pulls the pin low or high, your MCU might not boot up. And BOOT is not connected on all WisBlock Core modules.

It depends on the MCU.

  • RAK4631 would not be affected, BOOT is not connected.
  • RAK3172 will be stuck in STM Bootloader mode if BOOT is pulled high
  • RAK11720 seems to be uneffected, but I would not bet on it, there is a reason why it is connected. Of course you can use it on your own risk.
  • RAK11200 will be stuck in Espressif Bootloader mode if BOOT is pulled low
  • RAK11310 will be stuck in Bootloader/UF2 mode if BOOT is pulled low

So in general we suggest to leave BOOT pin unused.

For the 1.9V, I measured running my code and I get a clear 3.3V at HIGH. I can’t say why you see only 1.9V.