Search models, users, collections, and posts

ESP32 C3 Soil Moisture Sensor Bluetooh low energy

IP Report

Print Profile(1)

All
P1S
X1
X1 Carbon
X1E
H2D
P1P
A1 mini
A1
H2D Pro
H2S
P2S
H2C
X2D
A2L

0.08mm layer, 3 walls, 15% infill
0.08mm layer, 3 walls, 15% infill
Designer
3.7 h
2 plates
5.0(1)

Open in Bambu Studio
Boost
7
34
1
0
15
3
Released 

Description

Boost Me (for free)

Thank you for boosting

This is a Soil moisture sensor configured with ESP Home via BLE Communication using two AAA batteries

 

Used parts:

 

https://www.amazon.de/dp/B07V2BBVQR?ref=ppx_yo2ov_dt_b_fed_asin_title

https://www.amazon.de/dp/B0D7MMN2TG?ref=ppx_yo2ov_dt_b_fed_asin_title

https://www.amazon.de/dp/B0BZHSCFK4?ref=ppx_yo2ov_dt_b_fed_asin_title

https://www.amazon.de/dp/B078HV79XX?ref=ppx_yo2ov_dt_b_fed_asin_title

 

Here is the yaml code of the ble server (the sensor itself)

 

esphome:

  name: ble-server-2

  friendly_name: ble-server-2


 

esp32:

  board: esp32-c3-devkitm-1

  framework:

    type: arduino


 

# Enable logging

logger:

  level: NONE

  baud_rate: 0


 

deep_sleep:

  sleep_duration: 60min

  run_duration: 5s

   


 

sensor:

  - platform: adc

    pin: 0

    name: "Feuchtigkeit Garten 1"

    id: gartensensorhumidity1

    update_interval: 1s

    attenuation: 12db

    raw: true

    sampling_mode: avg

    unit_of_measurement: "V"

    accuracy_decimals: 4

    filters:

      - multiply: 0.00095238 # Convert raw to voltage (for 12db attenuation)

      - median:

          window_size: 2

          send_every: 1

          send_first_at: 1

      - clamp:

          min_value: 0

          max_value: 3.3


 

esp32_ble_server:

  manufacturer: "Espressif"

  manufacturer_data: [0xFF, 0xFF, 0xF1, 0x00]

  services:

    - uuid: "2A1C"

      advertise: true

      characteristics:

        - uuid: "2A6F"

          id: GartenSensor1

          notify: true

          read: true

          value: !lambda |-

            float v = id(gartensensorhumidity1).state;

            if (isnan(v)) v = 0.0;

            union {

              float f;

              uint8_t b[4];

            } u;

            u.f = v;

            return std::vector<uint8_t>(u.b, u.b + 4);


interval:

  - interval: 2s

    then:

      - ble_server.characteristic.notify:

          id: GartenSensor1

  - interval: 5s

    then:

      - lambda: |-

          float v = id(gartensensorhumidity1).state;

          if (isnan(v)) v = 0.0;

          union {

            float f;

            uint8_t b[4];

          } u;

          u.f = v;

          id(GartenSensor1).set_value(std::vector<uint8_t>(u.b, u.b + 4));

   

   

You need another bluetooth receiver (client) to catch the message form the server, you can use another esp32 of any kind.

The range is not very long so you might need to place it near to the sensor!

 

Heres the yaml code for the BLE Client:

 

esphome:

  name: "ble-client"

  friendly_name: BLE Client

  min_version: 2025.5.0

  name_add_mac_suffix: true

  on_boot:

    then:

      - lambda: |-

          esp_err_t errRc=esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_DEFAULT,ESP_PWR_LVL_P9);

          esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_ADV, ESP_PWR_LVL_P9);

          esp_ble_tx_power_set(ESP_BLE_PWR_TYPE_SCAN ,ESP_PWR_LVL_P9);

esp32:

  board: esp32dev

  framework:

    type: esp-idf

   

wifi:

  fast_connect: true

  networks:

    - ssid: 'YOUR SSID'

      password: !secret wifi_password

  manual_ip:

    static_ip: xxx.xxx.xxx.xxx

    gateway: xxx.xxx.xxx.xxx

    subnet: xxx.xxx.xxx.xxx

    dns1: xxx.xxx.xxx.xxx



 

api:

  encryption:

    key: "encryptionkey"

logger:


 

ota:

  - platform: esphome

    id: ota_esphome


 

esp32_ble_tracker:

  scan_parameters:

    interval: 1100ms

    window: 1100ms

    active: true



 

ble_client:


 

#ESP32C3 Nr.2 (Mini gehäuse super small

#MAC:ADDRESS:OF:YOUR:SENSOR

  - mac_address: MAC:ADDRESS:OF:YOUR:SENSOR

    id: ESP32C3_Sensor2

    on_connect:

      then:

        - logger.log: "Connected to Humidity Sensor BLE Server"

    on_disconnect:

      then:

        - logger.log: "Disconnected from Humidity Sensor BLE Server"




 

sensor:

 

#ESP32C3 Nr.2 (gehäuse super small AAA)

  - platform: ble_client

    type: characteristic

    ble_client_id: ESP32C3_Sensor2

    service_uuid: "2A1C"

    characteristic_uuid: "2A6F"

    name: "Humidity Sensor3"

    id: humidity_sensor3

    notify: true

    update_interval: never

    lambda: |-

      if (x.size() != 4) {

        ESP_LOGW("ble_sensor", "Unexpected value size: %d", x.size());

        return NAN;

      }

      union {

        float f;

        uint8_t b[4];

      } u;

      u.b[0] = x[0];

      u.b[1] = x[1];

      u.b[2] = x[2];

      u.b[3] = x[3];

      return u.f;


 

  - platform: template

    name: "Soil Moisture 3 %"

    id: humidity_percentage3

    unit_of_measurement: "%"

    device_class: humidity

    accuracy_decimals: 0

    update_interval: 5s

    lambda: |-

      float dry = 3.0; //adjust here dry for calibration

      float wet = 2.0; //adjust here wet for calibration

      if (isnan(id(humidity_sensor3).state)) {

      return {};

      }

      float voltage = id(humidity_sensor3).state;

      float percent = (dry - voltage) / (dry - wet) * 100.0;

      percent = clamp(percent, 0.0f, 100.0f);  // Ensure 0–100%

      return percent;




 

Comment & Rating (1)

(0/1000)

License

This user content is licensed under a Standard Digital File License.

You shall not share, sub-license, sell, rent, host, transfer, or distribute in any way the digital or 3D printed versions of this object, nor any other derivative work of this object in its digital or physical format (including - but not limited to - remixes of this object, and hosting on other digital platforms). The objects may not be used without permission in any way whatsoever in which you charge money, or collect fees.