RoadTest: RX23W BLE 5.0 Module Target Development Board
Author: ss_shrenik
Creation date:
Evaluation Type: Development Boards & Tools
Did you receive all parts the manufacturer stated would be included in the package?: True
What other parts do you consider comparable to this product?: NRF BLE products/ SI Lab BLE products
What were the biggest problems encountered?: The Development tools are not compatible with MacOS. Although its available on Linux but not all MCU series are supported on Linux and especially this specific RX MCU series compiler. I had to install Windows in VM that too Windows10(windows 7 had some compatibility issue for e2Studio). So basically, Renesas need to focus on making their tools compatible with major OS distributions. You need to read through e2Studio manual to know these limitations
Detailed Review:
I received the board on 10th of August, and was thinking to start working on it immediately in next weekend and was excited, until i figured out that e2studio does not support macOS. Then i moved onto the Linux since i could see e2Studio and Renesas compilers are available on Linux. But when i started to create a project for Rx23W module, found that the compiler needed for this Rx Series is only available on Windows version, Bummer!!! Now, the final option was to install windows in VM and then install e2Studio on top of that, and that also has to be windows 10. Finally, after these many attempts i could get to first demo app flashed and running on the Rx23W module.
Out of Box Demo was pretty good and easy to try out showing the capabilities of this BLE module. I will not waste time in writing about Demo details here as its explained very well in the official document i.e. Target Board for RX23W Quick Start Guide and can be found here https://www.renesas.com/us/en/products/microcontrollers-microprocessors/rx-32-bit-performance-efficiency-mcus/rtk5rx23w0… . This link also have info/source code for sample codes that can be run on Rx23W module.
Basically this demo does following
- BLE server profile running
- User switch state notification characteristics
- LED Blink Rate characteristics
And the Android APP, GATTBrowser which can be found on the Google playstore working as client, would scan and connect and search for services available, then we can enable notification to get notification on Switch press or Change LED blink rate from LED Blink Rate characteristics. Pasting a flow diagram from user guide for better understanding and now moving on to my aimed project
Good enough, the demo mentioned above fits perfectly for my project idea, lets see what is that idea.
So basically, in my free time I am working on one of my own open source IoT platform project. This project comprises of Front end, Backend, MQTT handling, Database handling and few supported device's FW code examples(WiFi as of now based on Espressif modules). The plan is to keep adding more connectivity platform support FW examples for this project. BLE module support is one of many(WiFi, BLE, Zigbee, Lora).
The examples are like IoT Switch, IoT Sensor, etc. With RX23W module I wanted to create BLE IoT Switch example for this project. (Note: the project is not yet made open source, the documentation and setup script is ongoing and we are working on making is easy to setup with just one install script. Will edit this blog in few weeks to include same.)
Below is the flow diagram to demonstrate the flow of my project
My open source platform consists of Database, MQTT subscriber from server side which will subscribe to BLESwitch topic, lets keep this separate now. Since, this is other side of the project.
In this specific project, our goal is to get Switch press notification from RX23W BLE module to WiFI_BLE_Bridge and then to the cloud through MQTT broker. Let's understand what each of above block will do
MQTT Broker -
As we all know, MQTT is typically used protocol in IoT Applications, and its most commonly used protocol, hence selected same here. Although BLE directly could not talk to MQTT broker hence the next part is imp.
MQTTSubscriber_WiFi -
Here, we are using ESP32 WiFi BLE chip. WiFi is using MQTT protocol and has subscribed to BLESwitch topic and be able to publish/subscribe messages on this topic
WiFI_BLE_Bridge -
One of the important part of this project is this component, Since BLE won't directly communicate over MQTT, we have created WiFI BLE bridge. Here BLE is working in client mode and will search for the BLE_Switch characteristics on the RX23W module and once found, it will connect to it and start listening to the Switch notifications. This code is done in arduino environment.
RX23W_BLE_Switch -
Here, i made use of demo example of BLE server application and tweaked it for my needs. Basically the switch should send notification every time it is pressed.
This code is written in ESP32 arduino environment and full code can be found at
https://github.com/engineershrenik/Embedded-system/blob/master/MQTT_WiFi_BLE_client_bridge.ino
Code section searching for service on BLE server
// Obtain a reference to the service we are after in the remote BLE server. BLERemoteService* pRemoteService = pClient->getService(serviceUUID); if (pRemoteService == nullptr) { Serial.print("Failed to find our service UUID: "); Serial.println(serviceUUID.toString().c_str()); pClient->disconnect(); return false; } Serial.println(" - Found our service");
Register for notification service
if(pRemoteCharacteristic->canNotify()) pRemoteCharacteristic->registerForNotify(notifyCallback);
Notify call back would get called once the notification is received from RX23W module
static void notifyCallback( BLERemoteCharacteristic* pBLERemoteCharacteristic, uint8_t* pData, size_t length, bool isNotify) { Serial.print("Notify callback for characteristic "); Serial.print(pBLERemoteCharacteristic->getUUID().toString().c_str()); Serial.print(" of data length "); Serial.println(length); Serial.print("data: "); Serial.println((char*)pData); client.publish(topic, "Event Detected"); }
The code is written in e2Studio's environment, which is official IDE by Renesas. RX23W modules are only supported on windows. The code is placed on my github repo
Few points to remember while compiling this code on e2Studio
Device characteristics published
/* Device Name characteristic definition */ const st_ble_servc_char_info_t gs_dev_name_char = { .uuid_16 = BLE_GAPC_DEV_NAME_UUID, .uuid_type = BLE_GATT_16_BIT_UUID_FORMAT, .app_size = sizeof(st_ble_gapc_dev_name_t), .db_size = BLE_GAPC_DEV_NAME_LEN, .char_idx = BLE_GAPC_DEV_NAME_IDX, .p_attr_hdls = gs_dev_name_char_ranges, .decode = (ble_servc_attr_decode_t)decode_st_ble_gapc_dev_name_t, .encode = (ble_servc_attr_encode_t)encode_st_ble_gapc_dev_name_t, };
Switch pin initialisation and callback register
/* Configure the board */ R_BLE_BOARD_Init(); R_BLE_BOARD_RegisterSwitchCb(BLE_BOARD_SW2, sw_cb);
Code to initialise the service
/* Initialize LED Switch Service server API */ status = R_BLE_LSS_Init(lss_cb);
Callback function for LED switch service
/****************************************************************************** * Function Name: lss_cb * Description : Callback function for LED Switch Service server feature. * Arguments : uint16_t type - * Event type of LED Switch Service server feature. * : ble_status_t result - * Event result of LED Switch Service server feature. * : st_ble_servs_evt_data_t *p_data - * Event parameters of LED Switch Service server feature. * Return Value : none ******************************************************************************/ static void lss_cb(uint16_t type, ble_status_t result, st_ble_servs_evt_data_t *p_data) {
Callback function for Switch press which will call R_BLE_LSS_NotifySwitchState to send state info notification
/****************************************************************************** * Function Name: sw_cb * Description : Callback function for board switch. * Arguments : none * Return Value : none ******************************************************************************/ static void sw_cb(void) { #if (APP_CFG_NOTIF_GUARD_EN != 0) if( BLE_GAP_INVALID_CONN_HDL == g_conn_hdl ) { return; } if( 0 == gs_notif_status ) { gs_notif_status = 1; uint8_t state = 1; (void)R_BLE_LSS_NotifySwitchState(g_conn_hdl, &state); (void)R_BLE_TIMER_Start(gs_notif_timer_hdl); } #else /* (APP_CFG_NOTIF_GUARD_EN != 0) */ uint8_t state = 1; R_BLE_LSS_NotifySwitchState(g_conn_hdl, &state); #endif /* (APP_CFG_NOTIF_GUARD_EN != 0) */ }
BLE server with necessary characteristics found on MQTT_WiFi_BLE_Bridge(ESP32)
RX23W sending notification to ESP32 on switch press, can see print below "Notify callback for characteristics ..... of data length 1"
ESP32 sending notification to MQTT broker
Event also can be detected on Smartphone, since we subscribed to the topic
And finally video in action, sorry for the raw quality, since i did not put more efforts on editing the video this time.
Would love to see Renesas enabling support for MacOS, GCC compiler for all of their chipset family(currently gcc is limited to few series of devices)