A product and project has huge difference may they have same technology but still a different things. project is a good way to show the working and technology of that particular system, but product need to be a part of day to day life.

So Product should be easy to use and must practically possible to solve problems. In this post we will learn a simple way to make project which can be use as product.

We need DHT11 sensor with 10k resistor ,Oled i2c Display, Arduino Pro Mini, Battery Holder, Switch, Double Sided Foam Tape and Small little cute Wires.

Product is compact no extra components use. so connect Arduino with wires small enough to just connect with display.

4 wires sck, sda, vcc and gnd Solder it from back side of pcb.

Past switch on side of holder with Foam Tape also past Foam Tape for Arduino and display.

Connect Battery VCC to one side of switch.
Connect VCC throw switch to Arduino and DH11 Sensor
Then flip and past and connect ground wire.
Define the sensor input in code and upload it to Arduino
Connect sensor wire to defined pin and
your compact cute product is ready.
Press the button for 3 sec and Woalaa it will show Humidity and Temperature of that Particular Area

Before uploading the code install #include libraries

#include "DHT.h"
#define DHT11Pin 9
#define DHTType DHT11
//OLED
#include <Wire.h>

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

DHT HT(DHT11Pin,DHTType);
float humi;
float tempC;
float tempF;

//OLED define
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(9600);
  //For DHT11
  HT.begin();
  //For OLED I2C
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  display.display(); //Display logo
  delay(1000); 
  display.clearDisplay();
}

void loop() {
 delay(1000);
 humi = HT.readHumidity();
 tempC = HT.readTemperature();
 tempF = HT.readTemperature(true);

 Serial.print("Humidity:");
 Serial.print(humi,0);
 Serial.print("%");
 Serial.print(" Temperature:");
 Serial.print(tempC,1);
 Serial.print("C ~ ");
 Serial.print(tempF,1);
 Serial.println("F");

 display.clearDisplay();
 oledDisplayHeader();
 

 oledDisplay(3,5,28,humi,"%");
 oledDisplay(2,70,16,tempC,"C");
 oledDisplay(2,70,44,tempF,"F");
 
 display.display(); 
 
}
void oledDisplayHeader(){
 display.setTextSize(1);
 display.setTextColor(WHITE);
 display.setCursor(0, 0);
 display.print("Humidity");
 display.setCursor(60, 0);
 display.print("Temperature");
}
void oledDisplay(int size, int x,int y, float value, String unit){
 int charLen=12;
 int xo=x+charLen*3.2;
 int xunit=x+charLen*3.6;
 int xval = x; 
 display.setTextSize(size);
 display.setTextColor(WHITE);
 
 if (unit=="%"){
   display.setCursor(x, y);
   display.print(value,0);
   display.print(unit);
 } else {
   if (value>99){
    xval=x;
   } else {
    xval=x+charLen;
   }
   display.setCursor(xval, y);
   display.print(value,0);
   display.drawCircle(xo, y+2, 2, WHITE);  // print degree symbols (  )
   display.setCursor(xunit, y);
   display.print(unit);
 }
 
}

Leave a Reply