Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/justin-marian/casamonitor

CasaMonitor: Home condition monitoring & control with: sensors, LEDs, fan, automation, real-time data, and customizable settings.
https://github.com/justin-marian/casamonitor

atmega328p avr gpio home-control i2c node-red platformio pwm real-time timers usart

Last synced: 2 months ago
JSON representation

CasaMonitor: Home condition monitoring & control with: sensors, LEDs, fan, automation, real-time data, and customizable settings.

Awesome Lists containing this project

README

        

# ๐Ÿก [CasaMonitor](https://ocw.cs.pub.ro/courses/pm/prj2024/fstancu/justin.popescu1605?hardware_design)

![AVR Atmega328P](https://img.shields.io/badge/AVR-Atmega328P-orange?logo=arduino) ![Build with PlatformIO](https://img.shields.io/badge/build%20with-PlatformIO-orange?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iMjUwMCIgaGVpZ2h0PSIyNTAwIiB2aWV3Qm94PSIwIDAgMjU2IDI1NiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCI+PHBhdGggZD0iTTEyOCAwQzkzLjgxIDAgNjEuNjY2IDEzLjMxNCAzNy40OSAzNy40OSAxMy4zMTQgNjEuNjY2IDAgOTMuODEgMCAxMjhjMCAzNC4xOSAxMy4zMTQgNjYuMzM0IDM3LjQ5IDkwLjUxQzYxLjY2NiAyNDIuNjg2IDkzLjgxIDI1NiAxMjggMjU2YzM0LjE5IDAgNjYuMzM0LTEzLjMxNCA5MC41MS0zNy40OUMyNDIuNjg2IDE5NC4zMzQgMjU2IDE2Mi4xOSAyNTYgMTI4YzAtMzQuMTktMTMuMzE0LTY2LjMzNC0zNy40OS05MC41MUMxOTQuMzM0IDEzLjMxNCAxNjIuMTkgMCAxMjggMCIgZmlsbD0iI0ZGN0YwMCIvPjxwYXRoIGQ9Ik0yNDkuMzg2IDEyOGMwIDY3LjA0LTU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w9IiNFNTcyMDAiLz48cGF0aCBkPSJNMTAxLjM3MSA3Mi43MDlsLTUuMDIzLTE4LjkwMWMyLjg3NC0xLjgzMiA0Ljc4Ni01LjA0IDQuNzg2LTguNzAxIDAtNS43LTQuNjItMTAuMzItMTAuMzItMTAuMzItNS42OTkgMC0xMC4zMTkgNC42Mi0xMC4zMTkgMTAuMzIgMCA1LjY4MiA0LjU5MiAxMC4yODkgMTAuMjY3IDEwLjMxN0w5NS44IDc0LjM3OGMtMTkuNjA5IDYuNTEtNDAuODg1IDIwLjc0Mi00MC44ODUgNTEuODguNDM2IDQ1LjAxIDU5LjU3MiA4NS4yNjcgNzMuMTg2IDg1LjI2N1Y2OC44OTJzLTEyLjI1Mi0uMDYyLTI2LjcyOSAzLjgxN3ptMTAuMzk1IDkyLjA5Yy04LjEzOCAxMC4yLTUyLjczNS0yNS44OC00NS4xNTQtNTEuNjQ1IDMuMDAyLTEyLjE0NSAxMy4xOS0xNy42MTIgMjEuNTExLTE2LjI4IDMwLjM1IDYuMTc1IDM1LjI2IDQ5LjM2OSAyMy42NDMgNjcuOTI2em0tMTguODItMzkuNDZhOS4zOTkgOS4zOTkgMCAwIDAtOS4zOTkgOS4zOTggOS4zOTkgOS4zOTkgMCAwIDAgOS40IDkuNCA5LjM5OSA5LjM5OSAwIDAgMCA5LjM5OC05LjQgOS4zOTkgOS4zOTkgMCAwIDAtOS4zOTktOS4zOTl6bS0yLjgxIDguNjcxYTIuMzc0IDIuMzc0IDAgMSAxIDAtNC43NDggMi4zNzQgMi4zNzQgMCAwIDEgMCA0Ljc0OHoiIGZpbGw9IiNGRjdGMDAiLz48L3N2Zz4=) ![Build Status](https://img.shields.io/badge/build-passing-brightgreen)

![License](https://img.shields.io/badge/license-GPL-blue?logo=gnu) ![C](https://img.shields.io/badge/code-C-blue?logo=c) ![C++](https://img.shields.io/badge/code-C++-blue?logo=cplusplus)

## Introduction

- **Node-RED API Dashboard:** [SW](https://drive.google.com/file/d/1zLRS86_t2jiu0NKJF-CHeEPyh4NjXHAV/view?usp=sharing)
- **Harware Interface:** [HW](https://drive.google.com/file/d/1L-0ANzF2LampGnMLCuwHAHUocGBix3rt/view?usp=sharing)

**CasaMonitor** is a project designed to enhance home comfort by allowing users to adjust environmental conditions directly from a computer, thereby improving energy efficiency during home activities, at this link you will see how it actualy works: [Diagram flow](https://drive.google.com/file/d/10yNvxCuC7T1XRNh7v7aW5A-qBJzTKchK/view?usp=sharing)

## Main Idea ๐Ÿ’ก

**The project** aims to provide an integrated system for monitoring and controlling environmental conditions and energy consumption in a living space. Sensors and a microcontroller (ยตC) connected via USB collect real-time data on temperature, humidity, and energy usage, allowing users to adjust these conditions through a graphical interface.

## Project Goal ๐ŸŽฏ

**The goal** is to give users better control over their living environment, optimizing comfort and energy efficiency. By using this system, energy costs can be reduced, and a more sustainable living environment can be achieved.

## Utility of the Monitor ๐Ÿก

CasaMonitor's control panel offers multiple benefits:

- **Improving comfort** by automatically adjusting temperature and humidity.
- **Efficiently monitoring** and managing household energy consumption.
- **Optimizing** the use of available resources.

## System Overview

The system uses **Node-RED** for managing data flow and logic between devices. It connects hardware devices and ensures no data loss during sensor data reception. The system communicates with the **Node-RED API** via USB.


CasaMonitor Idea

## Arduino UNO, USB Cable, Power Supply

- **Arduino UNO R3 ATmega328P**: The main microcontroller used for interfacing with various sensors and actuators.
- **USB 2.0 A-B Cable**: Connects the Arduino to a laptop for data transfer and power.
- **Power Supply (12V, 2A)**: Provides a stable 12V output suitable for powering multiple components like the LED strip, IR sensors, INA219, DHT22, and the cooling fan.

### Sensors: Temperature/Humidity, Current/Voltage, and Photoelectric

- **DHT22 Temperature-Humidity Sensor**: Connected to digital pin 12 on the Arduino, it measures environmental temperature and humidity. A pull-up resistor ensures stable data communication.
- **INA219 Current-Voltage Sensor**: Uses I2C protocol for communication, measuring current up to ยฑ3.2A with 10ยตA resolution, and bus voltage up to 26V.
- **IR Photoelectric Sensor (DS30P1)**: Detects motion up to 30 cm, connected to digital pin 8 on the Arduino. Provides PNP output for easy integration with control circuits.

### Control Components: Lighting and Cooling

- **IRF520 MOSFET Driver**: Controls high-current loads like the LED strip and cooling fan, supporting PWM signals for dimming the LED brightness.
- **12V LED Strip**: Provides dynamic lighting, controlled by the MOSFET through the Arduino.
- **12V 40mm Cooling Fan**: Activated based on temperature readings to maintain optimal room temperature.

### Prototyping and Connectivity

- **Breadboard and Jumper Wires**: Used for assembling and testing the circuit. Ensures flexibility for future modifications.
- **ON-OFF Switch**: Allows manual control of the lighting system, easily accessible for quick operation.


CasaMonitor Idea

### Software Design

The project uses various development environments and libraries to achieve its functionality:


Node-RED Interaction


CasaMonitor Control Panel

- **Development Environment:** PlatformIO
- **Libraries:** Node-RED, AVRlib

#### 1. Light Sliders

**Max Light:**

- For IR light or ON-OFF button.
- Adjusts light intensity and ON-OFF value.
- Used if motion or ON button is active.
- Defaults to Min Light if inactive.
- Sets range; min > max does nothing.

**Min Light:**

- Sets minimum light intensity without IR or ON-OFF.
- Activates minimum intensity when other options are inactive.

#### 2. Cooler Button

- Activates fan for cooling.

#### 3. Data Interface

- Temperature, Humidity, Current, Voltage, Power:
- Shows real-time values.
- Linear graphs track changes over time.

#### 4. Control Interface

- Sets light intensity and temperature preferences.
- Buttons for lights and fan.

#### 5. Temperature Slider

- Sets desired temperature.
- Fan activates if real temperature is higher.

The `platformio.ini` file is the main configuration file for the PlatformIO environment. It contains various settings that define how the project is built, uploaded, and monitored. Below is the detailed explanation of the `platformio.ini` configuration used in the CasaMonitor project:

```ini
[env:ATmega328p]
platform = atmelavr ; Specifies the platform as Atmel AVR
board = ATmega328p ; Defines the board as ATmega328p
framework = arduino ; Uses the Arduino framework
board_build.f_cpu = 16000000L ; Sets the CPU frequency to 16 MHz
board_build.mcu = atmega328p ; Specifies the MCU as ATmega328p
upload_port = COM4 ; Defines the COM port for uploading firmware
monitor_port = COM4 ; Sets the COM port for serial monitoring
monitor_speed = 9600 ; Sets the baud rate for serial communication
lib_deps =
adafruit/DHT sensor library@^1.4.3 ; Library for DHT temperature and humidity sensors
adafruit/Adafruit INA219@^1.1.1 ; Library for INA219 current sensor
adafruit/Adafruit Unified Sensor ; Unified sensor library for Adafruit sensors
adafruit/Adafruit BusIO@^1.7.3 ; I2C and UART communication library
```