Weeks 3 and 4 - Smart Environmental and Activity Logger

This project used the sensing and wireless capabilities of the Xiao nRF52840 Sense to create a data logging system. A key feature of the design was the inclusion of a voltage divider, allowing us to monitor the battery power to halt or continue data logging relative to the voltage provided by the battery.

Voltage Divider

We implemented voltage divider comprised of three resistors rated at 680Ω, 2.2kΩ, and 10kΩ. Two resistors are connected together in series, while the third resistor is connected to ground.

Circuit diagram
Circuit diagram

This is how we calculated the voltage for our battery monitor.

Voltage divider equation and our resistor configuration
Voltage divider equation and our resistor configuration

The image below shows how the circuit was implemented on a breadboard.

Breadboard layout
Breadboard layout

Data logging

The function on the next page uses the reading from pin A0 to calculate the battery voltage from the analog-to-digital converter (ADC) and prints the system status on the OLED. Our full code can be downloaded here.

Function to calculate battery voltage from the ADC
Function to calculate battery voltage from the ADC

Bluetooth connectivity

Connecting to our microcontroller using Bluetooth
Connecting to our microcontroller using Bluetooth

Successful connection
Successful connection

Sending a message to start logging data
Sending a message to start logging data

Sending a message to stop logging data
Sending a message to stop logging data

Voltage measurement and sensor output

These screenshots show how our sensor readings and system status messages are printed to the serial monitor and written to the SD card. The datalog.txt file can be downloaded here.

Serial monitor output showing the system status
Serial monitor output showing the system status

Data written to SD card
Data written to SD card

Displaying battery voltage and data logging status on the OLED

Displaying battery voltage and data logging status on the OLED
Displaying battery voltage and data logging status on the OLED

Displaying a message when battery voltage is below 3.3V threshold
Displaying a message when battery voltage is below 3.3V threshold

Demo

Video of the functional prototype


More posts

Week 14 - Real-Time Operating System (RTOS)

An introduction to real-time operating systems (RTOS) for embedded systems.

View post

Week 13 - Motor Controller

A simple DC motor controller using pulse-width modulation (PWM).

View post