Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home IoT & Smart Home

BLE Mesh Network: Smart Lighting Control with ESP32

BLE Mesh Network: Smart Lighting Control with ESP32

March 11, 2026 /Posted byJayesh Jain / 0

BLE Mesh Network: Smart Lighting Control with ESP32

A BLE mesh network for smart lighting control with ESP32 gives you the ability to control dozens or even hundreds of lights across a large space — a home, office, factory floor, or retail store — using a single Bluetooth Low Energy infrastructure. Unlike point-to-point BLE, mesh networking allows every node to relay messages, creating a self-healing, range-extending communication fabric that does not depend on a central hub or WiFi router. In this guide, we explore the architecture, the ESP-BLE-Mesh stack, hardware selection, and a complete implementation walkthrough suitable for Indian makers and professionals.

Table of Contents

  1. Introduction to BLE Mesh Networking
  2. Why ESP32 Is Perfect for BLE Mesh Lighting
  3. System Architecture and Node Roles
  4. Provisioning and Network Configuration
  5. Code Implementation: Light Node and Switch Node
  6. Scaling Up: Multi-Room and Commercial Deployments
  7. Frequently Asked Questions

Introduction to BLE Mesh Networking

Bluetooth Mesh (standardised by the Bluetooth SIG in 2017) is a many-to-many topology built on top of Bluetooth Low Energy advertising. Each node in the mesh can send, receive, and relay messages — a process called message relaying or managed flooding. Because there is no single point of failure, the network continues to function even if several nodes go offline.

Key BLE Mesh concepts you need to understand before building:

  • Nodes: Any device participating in the mesh. Can be a light, a switch, a sensor, or a gateway.
  • Elements: Addressable sub-units within a node. A single ESP32 can have multiple elements (e.g., two independently controllable LED channels).
  • Models: Standard or vendor-specific state machines assigned to elements. The Generic OnOff Server model is used for simple on/off lights; the Light Lightness Server model for dimmable lights.
  • Provisioner: The device (typically a smartphone app or a dedicated ESP32) that adds new nodes to the network, assigns addresses, and distributes encryption keys.
  • Publish/Subscribe: Nodes publish state changes to group addresses; other nodes subscribed to the same address act on the messages. This is how you control a room full of lights with a single button press.
Ai Thinker NodeMCU-32S-ESP32 Development Board

Ai Thinker NodeMCU-32S-ESP32 Development Board – IPEX Version

The NodeMCU-32S with its dual-core Xtensa processor and integrated BLE 4.2 is an ideal platform for BLE mesh lighting nodes at an affordable price.

View on Zbotic

Why ESP32 Is Perfect for BLE Mesh Lighting

The ESP32 is one of the very few microcontroller modules that supports full BLE Mesh out of the box, thanks to Espressif’s open-source ESP-BLE-Mesh component included in ESP-IDF v4.0+. Here is why it stands out for lighting applications in India:

Feature ESP32 Nordic nRF52840 Silicon Labs EFR32
BLE Mesh support Yes (ESP-IDF) Yes (Zephyr) Yes (Simplicity)
WiFi (for gateway) Yes (built-in) No No (separate chip)
Cost in India ₹200-400 ₹800-1500 ₹1000-2000
Arduino support Yes Partial Limited
PWM channels 16 8 8

The dual-radio architecture of ESP32 also enables a crucial use case: a single node can act as both a BLE Mesh relay and a WiFi gateway simultaneously, bridging the mesh network to the internet for remote control via MQTT or HTTP APIs.

System Architecture and Node Roles

A typical ESP32 BLE Mesh smart lighting deployment consists of the following node types:

1. Light Node (Server)

This is the light fixture itself — an ESP32 module connected to an LED driver, relay, or PWM-controlled dimmer. It implements the Generic OnOff Server model and/or the Light Lightness Server model. It listens for messages addressed to its unicast address or subscribed group addresses, and controls the light output accordingly.

2. Switch Node (Client)

A wall switch or wireless button implements the Generic OnOff Client model. When pressed, it publishes an OnOff Set message to a group address. All light nodes subscribed to that group address respond simultaneously — creating a many-to-one or many-to-many control relationship.

3. Sensor Node (optional)

A PIR motion sensor or ambient light sensor node can automatically publish messages to turn lights on/off based on occupancy or lux levels. This is particularly useful for corridors, stairwells, and offices in Indian commercial buildings trying to reduce electricity bills.

4. Gateway Node

An ESP32 acting as both BLE Mesh node and WiFi station. It receives mesh messages and forwards them to an MQTT broker (running on a cloud server or locally on a Raspberry Pi), enabling smartphone and voice assistant control without a separate hub.

AC 220V PIR Human Body Motion Sensor

AC 220V Security PIR Human Body Motion Sensor Detector

Add occupancy-based automation to your BLE mesh lighting system — have lights turn on automatically when someone enters a room.

View on Zbotic

Provisioning and Network Configuration

Provisioning is the process of bringing an unprovisioned device (a fresh ESP32) into the mesh network. The Bluetooth Mesh standard defines two provisioning bearers: PB-ADV (advertising) and PB-GATT (for mobile apps). For an ESP32-based system, you have two options:

Option A: Smartphone Provisioner App
Use the nRF Mesh app (Nordic Semiconductor, available for Android and iOS) or Espressif’s EspBlufiApp. These apps scan for unprovisioned devices, assign network and application keys, configure publish/subscribe addresses, and set relay/proxy flags. This is the easiest approach for small deployments.

Option B: ESP32 Provisioner Node
For commercial or large-scale deployments, dedicate one ESP32 as the provisioner. This node runs the provisioner role code from ESP-IDF’s BLE Mesh examples and can automatically provision new nodes when they are powered on, using a pre-shared provisioning key baked into the firmware. This enables factory-floor provisioning without any app.

After provisioning, you configure:

  • AppKey binding: Each model on each node must have an AppKey bound to it before it can send or receive messages.
  • Publication address: The address a node publishes its state changes to. For a switch, this is typically a group address like 0xC000 (“Living Room Lights”).
  • Subscription address: The address a node listens on. For a light node in the living room, subscribe to 0xC000.

Code Implementation: Light Node and Switch Node

The following examples use ESP-IDF v5.x with the esp-ble-mesh component. The Arduino BLE Mesh library exists but is limited; for production projects, use ESP-IDF directly or via PlatformIO.

Light Node (Generic OnOff Server)

// Simplified light node — see ESP-IDF examples for full implementation
#include "esp_ble_mesh_defs.h"
#include "esp_ble_mesh_common_api.h"
#include "esp_ble_mesh_networking_api.h"
#include "esp_ble_mesh_provisioning_api.h"
#include "esp_ble_mesh_config_model_api.h"
#include "esp_ble_mesh_generic_model_api.h"

#define LED_PIN GPIO_NUM_2

// Called when OnOff Set message received
static void generic_onoff_set(esp_ble_mesh_generic_server_cb_event_t event,
                               esp_ble_mesh_generic_server_cb_param_t *param) {
    if (param->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET) {
        uint8_t state = param->value.set.onoff.onoff;
        gpio_set_level(LED_PIN, state);
        ESP_LOGI("LIGHT", "Light turned %s", state ? "ON" : "OFF");
    }
}

Switch Node (Generic OnOff Client)

// Send OnOff Set message to group address 0xC000
void send_light_toggle(bool on) {
    esp_ble_mesh_generic_client_set_state_t set = {
        .onoff_set = {
            .op_en = false,
            .onoff = on ? 1 : 0,
            .tid = tid++,
        }
    };
    esp_ble_mesh_client_common_param_t common = {
        .opcode = ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET,
        .model = onoff_client_model,
        .ctx = {
            .net_idx = APP_NET_IDX,
            .app_idx = APP_KEY_IDX,
            .addr = 0xC000, // Group address
            .send_ttl = 7,
        },
        .msg_timeout = 0,
    };
    esp_ble_mesh_generic_client_set_state(&common, &set);
}
Ai Thinker ESP32-C3-01M Wi-Fi + BLE Module

Ai Thinker ESP32-C3-01M Wi-Fi + BLE Module

The compact C3 module supports BLE Mesh and is perfect for embedding inside light fixtures where space is limited.

View on Zbotic

Scaling Up: Multi-Room and Commercial Deployments

BLE Mesh is designed to scale. The standard supports up to 32,767 unicast addresses per network, and with proper group address planning you can control thousands of lights independently and in groups. Here is a practical room/zone addressing scheme for a typical Indian office building:

Zone Group Address Nodes
All lights (master) 0xFFFF (broadcast) All nodes
Floor 1 0xC001 All floor 1 nodes
Conference Room A 0xC010 Conf room lights
Corridor 0xC020 Corridor fixtures

For ranges larger than a single floor (BLE typically covers 10-20 metres per hop), the relay feature automatically extends coverage. Enable the relay feature on nodes that are physically spread out to create a reliable message path. In very large buildings, you may need to tune the TTL (Time To Live) value — the number of relay hops a message can take — to ensure messages reach far nodes without creating excessive network traffic.

Frequently Asked Questions

Q: What is the maximum range of a BLE Mesh network with ESP32?

A: Each ESP32 node has a BLE range of approximately 10-30 metres depending on obstacles. With relay nodes every 10-15 metres, a mesh network can theoretically cover an entire building floor. The maximum path length (TTL) defaults to 7 hops, giving roughly 70-200 metres of end-to-end range in a chain topology, and much more in a dense mesh.

Q: Can I mix ESP32 BLE Mesh nodes with commercial smart bulbs?

A: Only if the commercial bulbs support the Bluetooth Mesh standard (not all do — some use proprietary protocols). Bulbs certified as “Bluetooth Mesh” compliant (check the Bluetooth SIG qualification list) should interoperate with ESP32 mesh nodes that implement the same standard models. However, vendor-specific models will not be compatible.

Q: Does BLE Mesh work without a smartphone or hub?

A: Yes. Once provisioned, a BLE Mesh network operates entirely independently. A wall switch node can control light nodes directly with no hub, no internet, and no smartphone. A gateway is only needed if you want remote control from outside the building or voice assistant integration.

Q: How does BLE Mesh handle power outages?

A: When power is restored, each node boots up and re-joins the network using its stored provisioning data (stored in NVS flash). There is typically a 2-5 second startup delay per node. Nodes restore their last known state if you implement state persistence using the Preferences/NVS library.

Build Your BLE Mesh Lighting System

Get all the ESP32 modules, sensors, and accessories you need to build a professional BLE mesh smart lighting system. Zbotic.in offers fast delivery across India with genuine components.

Shop IoT Components at Zbotic

Tags: BLE Mesh, Bluetooth Mesh, ESP32, IoT home automation, Smart Lighting
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
ESP32 Interrupt Handling: GPIO...
blog esp32 interrupt handling gpio interrupt tutorial and code 595558
blog esp32 camera streaming mjpeg video to browser tutorial 595560
ESP32 Camera Streaming: MJPEG ...

Related posts

Svg%3E
Read more

IoT Home Insurance Sensor Kit: Leak, Smoke, and Motion

April 1, 2026 0
Table of Contents IoT and Home Insurance Water Leak Detection Smoke and Fire Detection Motion and Intrusion Sensing Building the... Continue reading
Svg%3E
Read more

IoT Pet Tracker: GPS Collar with Geofencing Alerts

April 1, 2026 0
Table of Contents Introduction and Overview Hardware Components Required GPS Module Integration with ESP32 Cloud Platform Setup Real-Time Tracking Dashboard... Continue reading
Svg%3E
Read more

IoT Aquaponics Controller: Fish and Plant Automation

April 1, 2026 0
Table of Contents The Water Monitoring Challenge in India Sensor Technologies for Water Building the Sensor Node Data Transmission and... Continue reading
Svg%3E
Read more

IoT Composting Monitor: Temperature and Moisture Tracking

April 1, 2026 0
Table of Contents Why Temperature Monitoring Matters Sensor Selection Guide Hardware Assembly and Wiring Firmware Development Cloud Data Logging Alert... Continue reading
Svg%3E
Read more

IoT Beehive Monitor: Weight, Temperature, and Humidity

April 1, 2026 0
Table of Contents Why Monitor Beehives Weight Measurement System Temperature and Humidity Sensing Building the Monitor Data Analysis for Bee... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now