This project aims to implement a simple Bluetooth-Ethernet Thin Gateway, the sensor measures and collects data from the device's environment and the gateway requests the results via BLE.
When the device is connected to a sensor peripheral the gateway reads the BLE characteristics to retrieve the measured temperature and humidity. The measurement results are uploaded to dweet.io via the Ethernet Click board.
The block diagram of this application is shown in the image below:
More detailed information can be found in the section How it works.
This code example referred to the following code example. More detailed information can be found here:
- GSDK v4.4.0
- Third Party Hardware Drivers v2.0.0.0
The hardware connection is shown in the image below:
- The ETH WIZ Click can be plugged into the BGM220 Bluetooth Module Explorer Kit via the mikroBus socket
To test this application, you can either create a project based on an example project or start with a "Bluetooth - SoC Empty" project based on your hardware.
-
From the Launcher Home, add your hardware to My Products, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project with the filter "ethernet".
-
Click Create button on Bluetooth - Ethernet Gateway examples. Example project creation dialog pops up -> click Create and Finish and Project should be generated.
-
Build and flash this example to the board.
-
Create a Bluetooth - SoC Empty project for your hardware using Simplicity Studio 5.
-
Copy all attached files in the inc and src folders into the project root folder (overwriting existing).
-
Open the .slcp file. Select the SOFTWARE COMPONENTS tab and install the software components:
- [Third Party Hardware Drivers] → [Interface] → [W5500 - ETH WIZ Click (Mikroe)]
- [Services] → [IO Stream] → [IO Stream: USART] → default instance name: vcom
- [Application] → [Utility] → [Log]
- [Platform] → [Driver] → [LED] → [Simple LED] → default instance name: led0
-
Import the GATT configuration:
- Open the .slcp file in the project.
- Select the CONFIGURATION TOOLS tab and open the "Bluetooth GATT Configurator".
- Find the Import button and import the gatt_configuration.btconf file.
-
Build and flash this example to the board.
-
Use Simplicity Studio 5 launcher to run the Bluetooth - SOC Thunderboard sense 2 demo on the Thunderboard Sense 2
Note:
-
Make sure that the SDK extension already be installed and this repository is added to Preferences > Simplicity Studio > External Repos.
-
SDK Extension must be enabled for the project to install some components.
-
Do not forget to flash a bootloader to your board, see Bootloader for more information.
-
Enable floating-point support for printf
- Right clicking on your project in the [Project Explorer] window and select properties and then select [C/C++ Build] > [Settings], then under [GNU ARM C Linker] > [General], check the [Printf float] checkbox
-
Initialize the peripherals and the Bluetooth stack.
-
Initialize the ethernet module.
-
Initialize the DHCP client on the ethernet module.
-
Get the gateway IP, subnet mask, and local IP from the DHCP server.
-
Setting DNS server.
-
Get the IP of the remote server:
dweet.io
. -
Start scanning for thunderboard sense device filter the result by name:
Thunderboard
. -
Connect to the device with the highest RSSI
-
If the BLE connection is established:
- Discover environment sensing service and temperature & humidity characteristic.
- Start a timer with period 3s to check the connection is timed out.
-
If failed to connect to the device then restart the scanning process.
-
-
When discovering service and characteristic is finished
- If the temperature & humidity characteristic are found then start a periodic timer to collect sensor data
- If no service and characteristic are found within 3s then restart the scanning process.
-
In periodic timer handler, collect sensor data and send them to the remote server by using HTTP GET request.
- Indicate the Thunderboard Sense device is connected
- These interfaces can be opened from a simple browser (except real-time stream) or most of them can be integrated into dashboards and other services.
- Follow URL: https://dweet.io/follow/<device_name>
- Example:
- Visual dashboard: https://dweet.io/follow/thunderboard-be-gateway
- Read all messages: https://dweet.io/get/dweets/for/thunderboard-be-gateway
- Real-time stream: https://dweet.io/listen/for/dweets/from/thunderboard-be-gateway