This is the multi-page printable view of this section. Click here to print...

Return to the regular view of this page

As of 2025-07-24

TWELITE SPOT

Integrate TWELITE and Wi-Fi networks
The wireless LAN gateway TWELITE SPOT is a product that combines the low-power wireless microcontroller module TWELITE with the wireless LAN microcontroller module ESP32. By developing firmware for the ESP32, you can integrate the TWELITE network with Wi-Fi networks.

Expanding Possibilities with TWELITE and ESP32

TWELITE SPOT is a product that combines the compact, low-power, and pairing-free TWELITE seriesβ€”which allows many devices to be used simultaneouslyβ€”with the wireless LAN microcontroller module ESP32.

Appearance

Appearance

Internal Structure

Internal Structure

By developing firmware for the ESP32, you can implement systems such as the following:

Local ServerLocal GatewayIoT Gateway
Share data from TWELITE Child devices within the LANUse data from TWELITE Child devices within the LANUse data from TWELITE Child devices in the cloud

Local Server

The ESP32 is used as a server. For example, you can display acceleration data measured by a TWELITE CUE on a smartphone or operate the output ports of a TWELITE DIP from a smartphone.

Local Gateway

The ESP32 connects to the LAN. For example, data sent from TWELITE ARIA devices installed throughout a building can be received by TWELITE SPOT devices on each floor, aggregating temperature and humidity data from all floors on a server within the LAN.

IoT Gateway

The ESP32 connects to the Internet. For example, by attaching a TWELITE CUE and a magnet to a door, you can detect on the cloud whether the door remains open based on the acquired door open/close status.

Development with Arduino IDE and Dedicated Library

To build a system using TWELITE SPOT, you need to develop firmware for the ESP32.

Arduino IDE can be used for firmware development on the ESP32.

Development using Arduino IDE

Development using Arduino IDE

The MWings library, distributed via the Arduino Library Manager, makes it easy to receive packets from TWELITE Child devices and send commands to them.

Flow of the Start Guide

This start guide covers verifying TWELITE SPOT operation, setting up the ESP32 development environment, creating simple sketches, and writing them.

1. Verify TWELITE SPOT Operation

Get Started

Contents

Using the pre-installed app on TWELITE SPOT, view acceleration sensor wireless tag TWELITE CUE data on a smartphone.

Required Items

TWELITE SPOTTWELITE CUE
TWELITE ParentTWELITE Child

2. Perform Hello World on ESP32

Basics of Firmware Development Using ESP32

Contents

Set up the development environment, create and write a Hello World sketch, and verify operation.

Required Items

TWELITE SPOTTWELITE R3
TWELITE SPOT device to write firmwareUSB adapter to connect PC and TWELITE SPOT

3. Acquire Data from TWELITE CUE

Communication with TWELITE

Contents

Output acceleration data from TWELITE CUE via ESP32.

Required Items

TWELITE SPOTTWELITE CUETWELITE R3
TWELITE SPOT device to write firmwareTWELITE Child device to communicate with TWELITE SPOTUSB adapter to connect PC and TWELITE SPOT

1 - Getting Started

Display acceleration data from TWELITE CUE on your smartphone using TWELITE SPOT
TWELITE SPOT can host dynamic pages on a web server running on ESP32, distributing data received from TWELITE Child devices within the network.
Operation Image

Operation Image

Here, TWELITE SPOT functions as a wireless LAN access point.

What You Need

Confirm TWELITE SPOT Operation

1. Power On the Device ⚑

Connect the USB-C cable to the side of TWELITE SPOT and supply power from the USB AC adapter.

Connecting USB Power

Connecting USB Power

2. Power On TWELITE CUE ⚑

Insert a CR2032 coin battery into TWELITE CUE. It will start operating immediately.

Inserting Coin Battery

Inserting Coin Battery

3. Connect Your Smartphone πŸ“±

Connect your smartphone to the Wi-Fi network TWELITE SPOT (XXXX) from the Wi-Fi settings.

4. Open a Web Browser 🌐

Open a web browser on your smartphone and access spot.local.

You will see a screen like the following.

Top Page

Top Page

5. Open the CUE Viewer πŸ“ˆ

Tap on CUE Viewer to open the CUE viewer screen.

You will see a screen like the following.

CUE Viewer

2 - Basics of Firmware Development with ESP32

Try Hello World on ESP32 for TWELITE SPOT firmware development

ESP32 can build a system using wireless LAN on its own. For example, you can display data on a hosted web page, send data to a server within the LAN via WebSocket, or send REST API requests to cloud services.

TWELITE SPOT is a product that combines this ESP32 with TWELITE, enabling the use of many small, low-power wireless tags.

What You Need

Setting Up the Environment

1. Install the IDE πŸš›

If you have not installed Arduino IDE 1.x on your computer, please download the Legacy IDE (1.8.X) from the Arduino official download page and install it.

2. Install the Toolchain 🚚

If you have not installed Arduino core for the ESP32 in Arduino IDE 1.x, add the following URL to the Board Manager URLs and install the esp32 board definition.

https://espressif.github.io/arduino-esp32/package_esp32_index.json

3. Configure the Board Settings βš™οΈ

Configure Arduino core for the ESP32 to match TWELITE SPOT.

Select the Board Type

From the toolbar, select Tools -> Board -> ESP32 Arduino -> ESP32 Dev Module.

Location of ESP32 Dev Module

Location of ESP32 Dev Module

Configure Board Settings

Configure as shown in the figure below.

Settings after configuration

Settings after configuration

Prepare TWELITE SPOT

1. Remove the Cover ⛏️

Remove the cover on the top of the TWELITE SPOT case.

Switches and connectors will be exposed.

Names of each part

Names of each part

2. Connect TWELITE R3 / R2 πŸ”Œ

Connect TWELITE R3 / R2 to the 7P interface for ESP32 (marked ESP32).

Connection example (ESP32)

Connection example (ESP32)

3. Connect USB-C Power ⚑

Supply 5V power to the USB-C connector on the side.

Run the Sketch

In Arduino, programs/projects are called sketches.

1. Create the Sketch πŸ‘¨β€πŸ’»

Create a Hello World sketch that outputs a string from ESP32 to the serial port and displays it on the Arduino IDE serial monitor.

Sketch creation screen

Sketch creation screen

Start Arduino IDE and enter the following code.

void setup() {
  Serial.begin(115200);
  Serial.println("Hello, World!");
}

void loop() {
}

The contents of setup() run only once at startup. The contents of loop() run repeatedly without end.

On the second line, the baud rate (communication speed) of the serial port is set to 115200bps.

  Serial.begin(115200);

On the third line, the string "Hello, World!" is output to the serial port.

  Serial.println("Hello, World!");

2. Write the Sketch βš’οΈ

Select the Serial Port

From the Tools -> Serial Port menu, select the port for the connected device (TWELITE R series).

Serial port selection

Serial port selection

Start ESP32

Start ESP32 in programming mode.

Press the ESP32 reset switch EN(RST) and the ESP32 boot switch BOOT, then release them in the order EN(RST) -> BOOT.

Button locations

Button locations

Write the Sketch

Click the Upload button on the Arduino IDE toolbar.

Upload completion screen

Upload completion screen

3. Open the Serial Monitor πŸ–₯️

Open the Screen

Click the Serial Monitor button at the top right of Arduino IDE.

Serial monitor button at top right

Serial monitor button at top right

Configure Settings

Set the baud rate at the bottom right of the serial monitor screen to 115200.

Baud rate setting

Baud rate setting

4. Run the Sketch πŸš€

Restart ESP32

After writing is complete, press and release the ESP32 reset switch EN(RST) on TWELITE SPOT to reset ESP32.

Reset switch location

Reset switch location

Check the Serial Monitor

If the following string is displayed on the serial monitor, it was successful.

Hello, World!
Successful Hello World output

Successful Hello World output

3 - Receiving Data from a TWELITE Child

Output acceleration data received from TWELITE CUE to the serial monitor
TWELITE SPOT enables the use of numerous small, low-power wireless tags by combining ESP32 with TWELITE.

What You Need

Setting Up the Environment

1. Install the Development Environment πŸš›

If you have not set up the environment described in Basic Firmware Development Using ESP32, please do so first.

2. Configure the Board Settings βš™οΈ

Set the board type to ESP32 Dev Module and configure as shown below.

Settings After Configuration

Settings After Configuration

3. Install the Library 🚚

Install the MWings Library required to use TWELITE from ESP32.

Open Sketch -> Include Library -> Manage Libraries…

Location of Library Manager

Location of Library Manager

Type MWings in the search box and install MWings.

Library Manager

Library Manager

Prepare the TWELITE SPOT

1. Remove the Cover ⛏️

Remove the top cover of the TWELITE SPOT case.

2. Connect the Cables πŸ”Œ

Connect TWELITE R3 / R2 to the ESP32 7P interface labeled ESP32, then supply 5V power to the USB-C connector on the side.

Connection Example (ESP32)

Connection Example (ESP32)

Run the Sketch First

1. Open the Sample πŸ“‚

Launch Arduino IDE, then select File -> Examples -> MWings -> monitor_spot_app_cue.

monitor_spot_app_cue

2. Select the Serial Port βš™οΈ

From the Tools -> Port menu, select the port of the connected device (TWELITE R series).

Serial Port Selection

Serial Port Selection

3. Start the ESP32 πŸ‘‡

Start ESP32 in programming mode.

Press the reset switch EN(RST) and the ESP32 boot switch BOOT, then release in the order EN(RST) -> BOOT.

Button Locations

Button Locations

4. Write the Sketch βš’οΈ

Click the Upload button at the top of the Arduino IDE.

Upload Completion Screen

Upload Completion Screen

5. Open the Serial Monitor πŸ–₯️

Open the Window

Click the Serial Monitor button at the top right of the Arduino IDE.

Serial Monitor Button at Top Right

Serial Monitor Button at Top Right

Configure

Set the serial monitor baud rate to 115200.

6. Restart ESP32 πŸš€

After writing is complete, press and release the ESP32 reset switch EN(RST) on the TWELITE SPOT to reset the ESP32.

Reset Switch Location

Reset Switch Location

7. Confirm Startup πŸ’¬

If the following string appears on the serial monitor, startup was successful.

Monitor example for TWELITE SPOT: App_CUE (CUE Mode)
Successful Startup Display

Successful Startup Display

8. Start TWELITE CUE ⚑

Insert a CR2032 coin battery into the TWELITE CUE. It will start operating immediately.

Inserting the Coin Battery

Inserting the Coin Battery

9. Confirm Reception πŸ’¬

If the following string appears on the serial monitor, data reception from TWELITE CUE was successful.

Packet Number:     #3
Source Logical ID: 0x1
LQI:               147
Supply Voltage:    3310 mV
Accel Event:       Dice (1)
Accel X Axis [0]:  72 mG
Accel Y Axis [0]:  -64 mG
Accel Z Axis [0]:  1000 mG
Magnet State:      Leaving or Not found
Successful Reception Display

Successful Reception Display

Sketch Explanation

Here is a brief explanation of the sample sketch (monitor_spot_app_cue.ino).

Including the Library

Line 4 includes the MWings library you installed earlier.

#include "MWings.h"

Defining Pin Numbers

Lines 6-8 define the pin numbers.

const int RST_PIN = 5;
const int PRG_PIN = 4;
const int LED_PIN = 18;
NameDescription
RST_PINPin number connected to the TWELITE RST pin
PRG_PINPin number connected to the TWELITE PRG pin
LED_PINPin number connected to the ESP32 LED on the board

Defining TWELITE Settings

Lines 10-11 define the settings applied to the TWELITE Parent installed in TWELITE SPOT.

const uint8_t TWE_CHANNEL = 18;
const uint32_t TWE_APP_ID = 0x67720102;
NameDescription
TWE_CHANNELTWELITE frequency channel
TWE_APP_IDTWELITE application ID

Serial Port Setup

Lines 19-21 initialize the serial ports and output the startup message to the serial monitor.

  Serial.begin(115200);
  Serial.println("Monitor example for TWELITE SPOT: App_CUE (CUE Mode)");
  Serial2.begin(115200);

Serial is used for communication with the Arduino IDE serial monitor. The baud rate is set to 115200 bps to match the serial monitor settings.

Serial2 is used for communication with the TWELITE Parent installed on TWELITE SPOT. This is also set to 115200 bps to match the Parent’s initial settings.

TWELITE Initialization

Lines 24-26 call Twelite.begin() to configure and start the TWELITE Parent on TWELITE SPOT.

    Twelite.begin(Serial2,
                      LED_PIN, RST_PIN, PRG_PIN,
                      TWE_CHANNEL, TWE_APP_ID);
ParameterTypeDescription
Serial2HardwareSerial&Serial port used for communication with TWELITE
LED_PINintPin number connected to the status LED
RST_PINintPin number connected to the TWELITE RST pin
PRG_PINintPin number connected to the TWELITE PRG pin
TWE_CHANNELuint8_tTWELITE frequency channel
TWE_APP_IDuint32_tTWELITE application ID

Registering Packet Reception Event

Lines 29-49 call Twelite.on() to register the processing to be done when data is received from the TWELITE CUE.

Here, the received packet content is output to the serial monitor.

    Twelite.on([](const ParsedAppCuePacket& packet) {
        Serial.println("");
        Serial.print("Packet Number:     #");
        Serial.println(packet.u16SequenceNumber, DEC);
        Serial.print("Source Logical ID: 0x");
        Serial.println(packet.u8SourceLogicalId, HEX);
        Serial.print("LQI:               ");
        Serial.println(packet.u8Lqi, DEC);
        Serial.print("Supply Voltage:    ");
        Serial.print(packet.u16SupplyVoltage, DEC); Serial.println(" mV");
        Serial.print("Accel Event:       ");
        printAccelEvent(packet.u8AccelEvent);
        Serial.print("Accel X Axis [0]:  ");
        Serial.print(packet.i16SamplesX[0], DEC); Serial.println(" mG");
        Serial.print("Accel Y Axis [0]:  ");
        Serial.print(packet.i16SamplesY[0], DEC); Serial.println(" mG");
        Serial.print("Accel Z Axis [0]:  ");
        Serial.print(packet.i16SamplesZ[0], DEC); Serial.println(" mG");
        Serial.print("Magnet State:      ");
        printMagnetState(packet.u8MagnetState, packet.bMagnetStateChanged);
    });

This event is called only when a packet is received from the TWELITE CUE.

The received packet content is stored in the argument packet of type ParsedAppCuePacket.

packet contains the following data (the bold data are used in the code above).

DataTypeDescription
packet.u32SourceSerialIduint32_tSource Serial ID
packet.u8SourceLogicalIduint8_tSource Logical Device ID
packet.u16SequenceNumberuint16_tSequence Number
packet.u8Lqiuint8_tLQI (Radio Signal Quality Indicator)
packet.u16SupplyVoltageuint16_tSupply Voltage (mV)
packet.i16SamplesXint16_t[10]X-axis acceleration samples (mG)
packet.i16SamplesYint16_t[10]Y-axis acceleration samples (mG)
packet.i16SamplesZint16_t[10]Z-axis acceleration samples (mG)
packet.u8SampleCountuint8_tNumber of samples
packet.bHasAccelEventbooltrue if acceleration event is present
packet.u8AccelEventuint8_tAcceleration Event ID
packet.u8MagnetStateuint8_tMagnetic Event ID
packet.bMagnetStateChangedbooltrue if magnetic sensor state changed

Updating TWELITE Data

Line 55 calls Twelite.update().

    Twelite.update();

Twelite.update() reads packet data (ModBus ASCII format) from the TWELITE Parent one byte at a time.

4 - Related Information

For further study
This page summarizes materials useful for firmware development of TWELITE SPOT.

MWings Library

TWELITE Product Datasheets

TWELITE SPOT Manuals

Sketch Explanations

Others

Arduino

ESP32

Community

Libraries

Plugins