Search models, users, collections, and posts

Environmental Sensor

Print Profile(1)

All
A1 mini
X1E
X1
P1P
H2D Pro
H2D
H2C
A1
P1S
P2S
X1 Carbon
H2S
X2D
A2L

0.22mm layer, 2 walls, 10% infill
0.22mm layer, 2 walls, 10% infill
Designer
3.7 h
1 plate

Open in Bambu Studio
Boost
6
19
4
0
14
3
Released 

Bill of Materials

List other parts
  • Arduino UNO x 1:
  • display LCD 20x4 x 1:
  • sensore DHT22 x 1:
  • arduino cables x 1:

Description

Content has been automatically translated.
Show original

Boost Me (for free)

THANK YOU FOR SUPPORTING ME IN NEW TECH PROJECTS!

                                                                       ^ ON-BOARD SENSOR ^    

Transform your sensors into an elegant design object. This case was designed for those who love **clean** and **minimalist** aesthetics, without sacrificing precise environmental monitoring. Perfect for your desk, lab, or nightstand.

🌟 Main Features

  • **Modern Unibody Design:** Clean lines with rounded corners for a professional look that conceals electronic components.
  • **Optimized Ventilation:** The front and side slots are not just an aesthetic detail, but ensure a constant airflow to the sensors for accurate temperature and humidity readings.
  • **Integrated Display:** Custom housing for standard LCD screens (like the classic 20x4), with a bezel that enhances readability.
  • **Clean Cable Access:** Dedicated rear/side slot for the USB power cable, keeping cable management tidy.

🛠️ Technical Specifications and Hardware

The case is versatile and can accommodate various configurations. It has been tested with:

  • **Microcontroller:** Arduino uno
  • **Display:** LCD 20x4 with I2C interface.
  • **Sensors:** DHT11/DHT22 or BME280.
  • **Extra Components:** Sufficient internal space for mini breadboards or custom soldered circuits.

(customizable code with your own name)

HERE IS THE ARDUINO CODE TO INSERT:

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

#include <DHT.h>


 

#define DHTPIN 2

#define DHTTYPE DHT22

#define LEDPIN LED_BUILTIN


 

DHT dht(DHTPIN, DHTTYPE);

LiquidCrystal_I2C lcd(0x27, 20, 4);


 

// ===== ICONS =====

byte termometro[8] = {B00100,B01010,B01010,B01010,B01110,B01110,B11111,B01110};

byte goccia[8] = {B00100,B01110,B01110,B11111,B11111,B11111,B01110,B00100};

byte bar0[8] = {B00000,B00000,B00000,B00000,B00000,B00000,B00000,B00000};

byte bar1[8] = {B10000,B10000,B10000,B10000,B10000,B10000,B10000,B10000};

byte bar2[8] = {B11000,B11000,B11000,B11000,B11000,B11000,B11000,B11000};

byte bar3[8] = {B11100,B11100,B11100,B11100,B11100,B11100,B11100,B11100};

byte bar4[8] = {B11110,B11110,B11110,B11110,B11110,B11110,B11110,B11110};

byte bar5[8] = {B11111,B11111,B11111,B11111,B11111,B11111,B11111,B11111};


 

// Custom wave for second screen

byte onda0[8] = {B00000,B00000,B00000,B00000,B00000,B00000,B00000,B00000};

byte onda1[8] = {B00000,B00000,B00000,B00000,B00000,B00000,B11111,B11111};

byte onda2[8] = {B00000,B00000,B00000,B00000,B11111,B11111,B11111,B11111};

byte onda3[8] = {B00000,B00000,B11111,B11111,B11111,B11111,B11111,B11111};

byte onda4[8] = {B11111,B11111,B11111,B11111,B11111,B11111,B11111,B11111};


 

bool allarmeTemp = false;

bool allarmeHum = false;


 

// Mini-game drop

int dropRow = 0;

const int dropColumn = 18; // second to last column

bool dropActive = true;


 

// --- Statistics ---

float tMin = 100, tMax = -100;

float hMin = 100, hMax = -100;


 

// --- Screen ---

bool showMain = true;

unsigned long lastSwitch = 0;

const unsigned long screenDelay = 15000; // 15 seconds


 

// --- PC Message ---

bool showProf = false;

unsigned long profStart = 0;

const unsigned long profDuration = 5000;


 

// --- Second screen wave animation ---

int wavePattern[20]; // custom character index for each column


 

void setup() {

  Serial.begin(9600);

  lcd.init();

  lcd.backlight();

  dht.begin();

  pinMode(LEDPIN, OUTPUT);


 

  // Create icons

  lcd.createChar(0, termometro);

  lcd.createChar(1, goccia);

  lcd.createChar(2, bar0);

  lcd.createChar(3, bar1);

  lcd.createChar(4, bar2);

  lcd.createChar(5, bar3);

  lcd.createChar(6, bar4);

  lcd.createChar(7, bar5);

  lcd.createChar(2, onda0);

  lcd.createChar(3, onda1);

  lcd.createChar(4, onda2);

  lcd.createChar(5, onda3);

  lcd.createChar(6, onda4);


 

  // initialize wave

  randomSeed(analogRead(0));

  for(int i=0;i<20;i++) wavePattern[i]=random(0,5);

}


 

void loop() {

  // Serial read

  if(Serial.available()){

    String s = Serial.readStringUntil('\n');

    s.trim();

    if(s=="10"){

      showProf = true;

      profStart = millis();

    }

  }


 

// Prof Timer

  if(showProf && millis()-profStart>profDuration) showProf=false;


 

  float h = dht.readHumidity();

  float t = dht.readTemperature();


 

  if (isnan(h) || isnan(t)) {

    lcd.clear();

    lcd.setCursor(0,1);

    lcd.print(" Sensor error ");

    delay(2000);

    return;

  }


 

  // Update statistics

  if(t < tMin) tMin = t;

  if(t > tMax) tMax = t;

  if(h < hMin) hMin = h;

  if(h > hMax) hMax = h;


 

  if (t > 30.0) allarmeTemp = true;

  if (t < 28.0) allarmeTemp = false;

  if (h > 90.0) allarmeHum = true;

  if (h < 85.0) allarmeHum = false;


 

  bool allarme = allarmeTemp || allarmeHum;


 

  unsigned long now = millis();

  if(now - lastSwitch >= screenDelay && !showProf){

    showMain = !showMain;

    lastSwitch = now;

  }


 

  lcd.clear();


 

  // Show PC message

  if(showProf){

    lcd.setCursor(0,1);

    lcd.print("      Prof: 10?      ");

    delay(100);

    return;

  }


 

  if(showMain){

    // ===== MAIN SCREEN =====

    if(allarme) digitalWrite(LEDPIN,HIGH);

    else digitalWrite(LEDPIN,LOW);


 

    lcd.setCursor(0,0); lcd.print("-------Hello--------");


 

    // Temperature

    lcd.setCursor(0,1); lcd.write(byte(0));

    lcd.print(" Temp:    "); lcd.print(t,1); lcd.print("C     ");


 

    // Humidity

    lcd.setCursor(0,2); lcd.write(byte(1));

    lcd.print(" Humidity: "); lcd.print(h,1); lcd.print("%   ");


 

    // Fluid bar

    int totalBlocks=20;

    int filled=map(h*10,0,1000,0,totalBlocks*5);

    lcd.setCursor(0,3);

    static bool blink=false; blink=!blink;

    for(int i=0;i<totalBlocks;i++){

      int blockValue = filled-(i*5);

      if(blockValue>=5) lcd.write(byte(7));

      else if(blockValue>0) lcd.write(byte(2+blockValue));

      else lcd.write(byte(2));

    }


 

    // Mini-game drop

    if(dropActive){

      lcd.setCursor(dropColumn,dropRow); lcd.print(" ");

      dropRow++;

      bool splash=false;

      if(dropRow>3){ dropRow=0; splash=true; }

      lcd.setCursor(dropColumn,dropRow); lcd.write(byte(1));

      if(splash){ lcd.setCursor(19,3); if(blink) lcd.write(byte(7)); else lcd.write(byte(2)); }

    }


 

    delay(300);

  }

  else{

    // ===== SECONDARY SCREEN =====

    lcd.setCursor(0,0); lcd.print("Environment Statistics");

    lcd.setCursor(0,1); lcd.print("T: min "); lcd.print(tMin,1); lcd.print(" max "); lcd.print(tMax,1);

    lcd.setCursor(0,2); lcd.print("H: min "); lcd.print(hMin,1); lcd.print(" max "); lcd.print(hMax,1);


 

    // Last row wave animation

    lcd.setCursor(0,3);

    for(int i=0;i<20;i++){

      lcd.write(wavePattern[i]+2); // custom wave offset

    }

    // Update wave

    for(int i=0;i<20;i++){

      int delta=random(-1,2);

      wavePattern[i]+=delta;

      if(wavePattern[i]<0) wavePattern[i]=0;

      if(wavePattern[i]>4) wavePattern[i]=4;

    }


 

    delay(500);

  }

}

Comment & Rating (4)

(0/1000)

License

This user content is licensed under a Standard Digital File License.

You shall not share, sub-license, sell, rent, host, transfer, or distribute in any way the digital or 3D printed versions of this object, nor any other derivative work of this object in its digital or physical format (including - but not limited to - remixes of this object, and hosting on other digital platforms). The objects may not be used without permission in any way whatsoever in which you charge money, or collect fees.