RUI: How to set RUI_I2C_ST - I2C_REG_MAGIC

Hi,

I am using RAK5205. Because it does not have enough ADC inputs, I am using I2C-ADC chip ADS1114 to get 4 analog inputs via I2C interface.

I saw in rui.h:

#define I2C_REG_MAGIC 0xAA
typedef struct RUI_I2C_ST {
uint32_t INSTANCE_ID;
uint32_t PIN_SDA; // SDA pin num
uint32_t PIN_SCL; // SCL pin num
uint32_t FREQUENCY;
uint32_t REG_NULL; // if no reg , should be 0xAA
} RUI_I2C_ST;

uint32_t rui_i2c_rw(RUI_I2C_ST rui_i2c,RUI_IF_READ_WRITE rw, uint8_t devAddr, uint16_t regAddr, uint8_t data, uint16_t len);

Question:
What does REG_NULL=0xAA means? Does it mean the parameter regAddr in rui_i2c_rw() will be ignored? I am asking this because my I2C device, during read, does not need the regAddr.

Thanks and regards
Boh Lim

Hi, @bohlimsim
This parameter is not used in RAK5205 module.If Init ,you can config it to 0.
devAddr and regAddr must be needed at IIC standard agreement ,but you could set up a custom address.

Hi,

I could not get I2C-ADC chip ADS1114 to work in RAK5205m using your RUI I2C API (rui_i2c_rw etc).

But I could get ADS1114 to work in ESP32 (using its IDE framework), and also in beaglebone, within a day,
So there is no issue with my I2C concept/usage…

What is the next step I can do?

Thanks and regards
Boh Lim

Hi,@bohlimsim
I don’t know how you use it.
We provide some application references,about RAK5205 based on RAK811 you can FYI: https://github.com/RAKWireless/Products_practice_based_on_RUI/tree/master/based%20on%20RAK811/app_5205

I am trying to read light lux from BH1750 using I2C today without successful. According to sample code in app_5205:
void bsp_i2c_init(void)
I2c_1.PIN_SDA = I2C_SDA;
I2c_1.PIN_SCL = I2C_SCL;

I printed out I2C_SDA = 24 and I2C_SCL=23, which I thought should be pin number 27 and 26 to the RAK811 diagram? (But I still can’t make it to work with this setting).
also my reading code as:
rui_i2c_rw(&I2c_1,RUI_IF_READ, 0x23, 0, data, 3);
power up code as:
rui_i2c_rw(&I2c_1,RUI_IF_WRITE, 0x23, 0, 0x01, 1);
Is this correct format?

Also, could you explain more about command rui_light_set_mode and rui_light_get_strength please? What light sensor do you need for this command?

Hi @fangfchen
I2c_1.PIN_SDA = I2C_SDA ;
I2c_1.PIN_SCL = I2C_SCL ;
RAK811 support 1 fixed I2C,so this two pin can’t modify.Please use default initalization.
How to use the I2C,please refer to app_5205.c :https://github.com/RAKWireless/Products_practice_based_on_RUI/tree/master/based%20on%20RAK811/app_5205

These two commands are valid in RAK811 now.

Hi Wang,
What is the default pin number for fixed I2C in RAK811? Different diagram shows different pin number for SDA and SCL.

Hi,@fangfchen
Sorry,this is a negligence. The pin number 18 is I2C_SCL and 19 is I2C_SDA At RAK811 module . I’ll fix it to module pin number.This pin number is fixed for I2C,because RAK811 used hardware i2c,so it can’t remap to other pin.

Hi @leopold, do you have BH1750 sample code to share? I can’t read light sensor data.

Hi,@fangfchen
Sorry,we haven’t used the BH1750 sensor.


You’d better refer to its datasheet:https://pdf1.alldatasheet.com/datasheet-pdf/view/350139/ROHM/BH1750FVI.html

help with rui

When I compile and load code into rak811, the module does not work, nothing happens. I use usb-ttl to download the program. I try to use the program with AT command and it works, but rui do not work

Hi,@oleksander
The firmware that you compiled is based bootloader:https://downloads.rakwireless.com/en/LoRa/RAK811/Firmware/RUI_RAK811_BOOT_Version3_0_2.rar.
So you must download RUI_RAK811_BOOT_Version3_0_2.bin and flash it first,then update your firmware by RAK Upgrade Tool.
You can refer to:https://doc.rakwireless.com/rak811-wisnode-lora-module/upgrading-the-firmware.

first i upload the bin file and then do the update RAK LoRaButton Upgrade Tool V1.0, where i find file for RAK LoRaButton Upgrade Tool V1.0??

Hi,@oleksander
The above post ends with a link to a reference:https://doc.rakwireless.com/rak811-wisnode-lora-module/upgrading-the-firmware


tools here:https://downloads.rakwireless.com/en/LoRa/RAK612-LoRaButton/Tools/
Burning bootloader guide:https://doc.rakwireless.com/rak811-wisnode-lora-module/burning-the-bootloader-into-the-device

I have rak811 breakout board, then i do this:qVaOTeklHt

2 step:
i go to https://downloads.rakwireless.com/en/LoRa/RAK811-BreakoutBoard/Firmware/

then i see:

8DVNyJ8GO3

3 step:
I must first download RUI_RAK811_BOOT_Version3_0_2, then download like this:

After this step, I need to do anything???

i try how you say, it work, thank

how use rui
i want send date to my gateway
I use COiDE

#include “rui.h”
#include “board.h”

static RUI_RETURN_STATUS rui_return_status;
RUI_LORA_STATUS_T app_lora_status; //record status

rui_lora_get_status(false,&app_lora_status);;//The query gets the current device status
static uint8_t sensor_data_cnt=0; //send data counter by LoRa

rui_lora_set_region(EU868);

rui_lora_set_work_mode(RUI_LORAWAN);

rui_lora_set_dev_eui(uint8_t *dev_eui);

rui_lora_set_app_eui(uint8_t *app_eui);

rui_lora_set_app_key(uint8_t *app_key);

rui_lora_set_join_mode(RUI_OTAA);

rui_lora_join();

rui_lora_set_dr(0x05);

/*
RUI_RETURN_STATUS rui_lora_send(uint8_t port,uint8_t* data,uint8_t len)
Copy
@brief rui_lora send
@return RUI_RETURN_STATUS
@param uint8_t port: send data port
uint8_t* data: send data string
uint8_t len: send data length
@module RAK811, RAK4200, and RAK4600 core module.
*/

rui_lora_send(2,“AABBCC”,3);

Hi,@oleksander
Pls refer to :https://doc.rakwireless.com/rak811-wisnode-lora-module/rui-online-compiler

My code here

#include “rui.h”
#include “board.h”

int main(void)
{
int i;
static RUI_RETURN_STATUS rui_return_status;
RUI_LORA_STATUS_T app_lora_status; //record status

rui_lora_get_status(false,&app_lora_status);;//The query gets the current device status
static uint8_t sensor_data_cnt=0;  //send data counter by LoRa

rui_init();

void rui_uart_recv(RUI_UART1, 2, 1)

while (1) {
rui_lora_get_status(false,&app_lora_status);//The query gets the current status
rui_running();

  for(i=0;i<0x100000;i++);
  rui_lora_set_region(EU868);
  for(i=0;i<0x800000;i++);
  rui_lora_set_work_mode(RUI_LORAWAN);
  for(i=0;i<0x800000;i++);
  rui_lora_set_dev_eui("003EBD495B106225");
  for(i=0;i<0x800000;i++);
  rui_lora_set_app_eui("70B3D57ED0027A86");
  for(i=0;i<0x800000;i++);
  rui_lora_set_app_key("B09751554689810EC3907461A97F29ED");
  for(i=0;i<0x800000;i++);
  rui_lora_set_join_mode(RUI_OTAA);
  for(i=0;i<0x800000;i++);
  rui_lora_join();
  for(i=0;i<0x800000;i++);
  rui_lora_set_dr(0x05);
  for(i=0;i<0x800000;i++);

  rui_lora_send(2,"AABBCC",3);

}
}

Hi,@oleksander
rui_uart_recv() this is callback function when UART receive data.

This function is automatically triggered by data received through the serial port.