Skip to content

Data Collecting Device

Yasantha Niroshan edited this page Oct 2, 2024 · 7 revisions

IntelliBee Data Collection Device

This embedded device is part of the IntelliBee (Smart Hive Monitoring System for Meliponiculture). It is responsible for collecting environmental data (temperature, humidity, and sound) from the bee hive, which will be used for developing machine learning models to detect bee swarming and diseases.

Prototype

Prototype

Features

  • Environment Sensing - Collect temperature and humidity data.
  • Sound Monitoring - Records sound activity in the hive using a microphone sensor.
  • Data Logging - Data and Logs are stored in SD Card
  • WiFi Connectivity - The device connects to a WiFi network to synchronize time via NTP.
  • Power Efficiency - Uses deep sleep mode to save power between data collection intervals.
  • Error Handling - A state machine controls the device's operation with retries and error logging.

Hardware

Components

  • ESP32 - Main microcontroller.
  • AHTX0 Sensors - Two temperature and humidity sensors.
  • MicroSD Card Module: To log data.
  • MAX9814 Microphone - Captures sound data for analysis of bee activity

Connectivity

Component Pin/Connection Description
AHT10 Inside SDA = GPIO26, SCL = GPIO27 AHT10 Sensor inside the hive
AHT10 Outside SDA = GPIO32, SCL = GPIO33 AHT10 Sensor outside the hive
SPI for SD Card SD_SCLK = GPIO18, SD_MISO = GPIO19, SD_MOSI = GPIO23, SD_CS = GPIO5 SD card module for logging data
LED_PIN GPIO2 LED indicator
MIC_PIN_OUT GPIO34 Microphone input

Image

Software

Requirements

Image

Functionality

1. WiFi Setup

  • Connects to a predefined WiFi network using credentials.
  • Retries connecting to WiFi up to a maximum number of times.
  • If unsuccessful, the device goes into sleep mode and restarts later.

2. Time Synchronization

  • Uses an NTP server to synchronize time.
  • The time is used for timestamping data logs.

3. Sensor Setup

  • Initializes two AHTX0 sensors on separate I2C buses.
  • Logs a warning if the sensors cannot be initialized.

4. SD Card Initialization

  • Configures the SD card module using SPI.
  • Creates a new file in the /data directory with a timestamped filename for logging.

5. Logging Data

  • Logs Tempurature and Humidity Data
  • Logs 30 seconds sound data sampled at 1khz
  • Logs are written to the SD card in a text file.

6. Power Management

  • After completing its tasks, the device enters deep sleep mode for a set interval to conserve power.

State Machine for Operation

The device uses a state machine to transition between various stages

  1. WiFi Initialization
  2. Time Synchronization
  3. Sensor Initialization
  4. SPI Initialization
  5. SD Card Mounting
  6. Data Logging: Logs sensor data to the file.
  7. Sleep Mode: The device enters deep sleep to conserve power.

If any step fails, the device retries before proceeding or going force restart

State Diagram

Configuration

  • WiFi Credentials: Modify the ssid and password in the configurations.h file to match your network.
  • NTP Server: You can change the NTP server URL in configurations.h.
  • Directory Path: The directory where files are saved is defined in DIR_PATH in configurations.h.

Clone this wiki locally