This is an old revision of the document!


Ambient climate station

Fodor Mihnea-Stefan 331CA

Introduction

The smart ambient station automatically monitors temperature and adjusts a cooling fan's speed based on predefined thermal thresholds. It also displays the current real-time clock and allows full manual control via an infrared remote.

The purpose of the project is to maintain a comfortable local climate through automated cooling, while providing visual feedback and auditory alerts. It includes a critical safety mechanism that immediately halts all operations if the device is tilted or knocked over.

The starting concept was a standard thermostat, which evolved into a robust embedded system featuring a state machine, hardware-level safety interrupts and custom communication protocol implementations without relying on heavy third-party Arduino libraries.

For the user it serves as a practical desktop cooling and timekeeping gadget. It offers a highly affordable alternative to commercial cooling devices, while providing the flexibility of full manual control to suit personal comfort.

General Description

The ATmega328P runs a continuous state machine. In Auto Mode, it reads the ADC, calculates the temperature using the Steinhart-Hart equation and adjusts the PWM output to the fan. In Manual Mode, the IR receiver triggers an interrupt that decodes the NEC signal, allowing the user to override the fan speed, toggle RGB disco mode or trigger alarm. The Tilt Sensor has the highest priority: if triggered, it overrides all states, cuts power to the fan, and displays an error (—-) on the clock display.

Hardware Design

Bill of materials:

  • ATmega328P
  • 10k NTC thermistor
  • DS3231 mini RTC module
  • TM1637 4-digit display
  • VS1838B infrared receiver & IR remote
  • SW-520D tilt sensor
  • sunon maglev 5V DC fan
  • buzzer
  • RGB LED
  • NPN transistor 2N2222
  • resistors
  • wires

Software Design

Development Environment:

  • Visual Studio Code with the PlatformIO extension
  • AVR-GCC managed automatically through the PlatformIO framework

Libraries: <avr/io.h>, <avr/interrupt.h>, <util/delay.h>, <math.h>, <stdlib.h>, <stdio.h>.

Algorithms:

  • State machine implemented via a switch-case and global volatile flags (sistem_blocat, mod_manual, sistem_pornit) to manage transitions between states.
  • Steinhart-Hart equation used to convert raw 10-bit ADC values from the NTC thermistor into accurate Celsius temperature readings.
  • NEC protocol decoder that measures high/low pulse durations using a delay-based timer to reconstruct the 32-bit hexadecimal IR code.
  • Instantaneous triggering on INT0 for the tilt sensor to immediately halt the system.
  • BCD to decimal conversion.

Results Obtained

The system successfully modulates fan speeds and updates RGB indicators based on real-time temperature fluctuations without blocking the main loop.

The custom NEC decoder accurately captures 32-bit remote codes, allowing seamless toggling between Auto and Manual modes, speed adjustments and effects.

The hardware initially suffered from false tilt-sensor triggers due to buzzer vibrations. This was successfully resolved via software debouncing logic and hardware piece arrangement.

The module correctly renders the current time fetched from the DS3231 via custom functions.

Conclusions

The project successfully bridges analog signal processing, digital communication, and power management within a single 8-bit microcontroller architecture. It was an interesting challenge for both software and hardware, requiring creative engineering solutions to overcome several technical obstacles.

Bibliography/Resources

pm/prj2026/bianca.popa1106/mihnea_stefan.fodor.1778940972.txt.gz · Last modified: 2026/05/16 17:16 by mihnea_stefan.fodor
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0