Skip to content

mayth/env_reporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32 Environment Reporter

This measures temperature and humidity using SHT3x, then broadcasts them using BLE.

Prerequisites

SDK Config

This app requires BLE (NimBLE) and C++ exceptions feature.

This works only as a BLE broadcaster, so the other roles can be disabled.

WiFi and SNTP configuration is required for system time synchronization.

  • Component config
    • Bluetooth -> Enabled
    • Bluetooth controller
      • Bluetooth controller mode -> BLE only
    • Bluetooth Host -> NimBLE - BLEOnly
    • NimBLE Options
      • Enable BLE Peripheral role -> Disabled
      • Enable BLE Central role -> Disabled
      • Enable BLE Observer role -> Disabled
  • Compiler options
    • Enable C++ exceptions -> Enabled
  • Environment Reporter Configuration
    • WiFi SSID -> set SSID
    • WiFi Password -> set password
    • SNTP Server -> set NTP server
    • SHT3x I2C Address -> choose 0x44 or 0x45

A minimal configuration is included in this repository, see sdkconfig.defaults.

Advertisement packet

This broadcasts a measurement result in PDU payload in advertising packet. There is no need to connect to this device (the device is non-connectable).

Data format in Ad structure is described below (these fields are stored in this order):

Length      uint8_t  = 15;      // in bytes
AdType      uint8_t  = 0x16;    // Service Data
Service     UUID16   = 0x181A;  // Environmental Sensing Service
TimeStamp   uint64;             // Timestamp of measurement
Temperature uint16;             // 16bit raw sensor value
Humidity    uint16;             // 16bit raw sensor value

NOTE: they are stored in little endian.

The table below shows conversions from raw value to human-readable value.

Item Conversion formula
Temperature -45.0 + 175.0 * (x / 65535.0)
Humidity 100.0 * (x / 65535.0)

Interval of Advertising

After powering-on, this works as follows:

  1. measures the environment
  2. advertise for 120 seconds
  3. sleep for 480 seconds
  4. after wake-up, go (1)

so, this device is activated every 10 minutes. You can modify the interval by changing kInterval, kAdvertisingDuration (a sleep duration is calculated from them). Please note that increasing advertising duration also increases power consumption.

Observer

Observer example: env_scanner

Acknowledgements

About

Environment (temperature & humidity) reporter using BLE, works with ESP32 & SHT3x

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors