Skip to content

Latest commit

 

History

History

bluetooth_ethernet_gateway

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Bluetooth - Ethernet Gateway

Type badge Technology badge License badge SDK badge Build badge Flash badge RAM badge

Overview

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:

overview

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:

Gecko SDK version

Hardware Required

Connections Required

The hardware connection is shown in the image below:

hardware connection

  • The ETH WIZ Click can be plugged into the BGM220 Bluetooth Module Explorer Kit via the mikroBus socket

Setup

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.

Create a project based on an example project

  1. 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".

  2. Click Create button on Bluetooth - Ethernet Gateway examples. Example project creation dialog pops up -> click Create and Finish and Project should be generated. create_project

  3. Build and flash this example to the board.

Start with a "Bluetooth - SoC Empty" project

  1. Create a Bluetooth - SoC Empty project for your hardware using Simplicity Studio 5.

  2. Copy all attached files in the inc and src folders into the project root folder (overwriting existing).

  3. 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
  4. 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.
  5. Build and flash this example to the board.

  6. Use Simplicity Studio 5 launcher to run the Bluetooth - SOC Thunderboard sense 2 demo on the Thunderboard Sense 2 Thunderboard sense 2 demo

Note:

  • Make sure that the SDK extension already be installed and this repository is added to Preferences > Simplicity Studio > External Repos. external_repo

  • 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
    Project properties Enable printf floating point

How It Works

Application Overview

Application overview

Gateway Implementation

Application initialization

Application init

Sensor connect & upload sensor data to cloud service

Sensor connect

Application Workflows

  1. Initialize the peripherals and the Bluetooth stack.

  2. Initialize the ethernet module.

  3. Initialize the DHCP client on the ethernet module.

  4. Get the gateway IP, subnet mask, and local IP from the DHCP server.

  5. Setting DNS server.

  6. Get the IP of the remote server: dweet.io.

  7. Start scanning for thunderboard sense device filter the result by name: Thunderboard.

  8. 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.

  9. 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.
  10. In periodic timer handler, collect sensor data and send them to the remote server by using HTTP GET request.

LED

  • Indicate the Thunderboard Sense device is connected

Dweet cloud monitoring interfaces