0% found this document useful (0 votes)
2 views

arduino program

The document contains two Arduino sketches: one for reading temperature and humidity from a DHT11 sensor and another for displaying static text on an SSD1306 OLED display. The first sketch initializes the DHT11 sensor and prints the readings to the Serial Monitor every two seconds. The second sketch sets up the OLED display, shows the name 'SURESH', and does not perform any further actions in the loop.

Uploaded by

Suresh Varuvel
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

arduino program

The document contains two Arduino sketches: one for reading temperature and humidity from a DHT11 sensor and another for displaying static text on an SSD1306 OLED display. The first sketch initializes the DHT11 sensor and prints the readings to the Serial Monitor every two seconds. The second sketch sets up the OLED display, shows the name 'SURESH', and does not perform any further actions in the loop.

Uploaded by

Suresh Varuvel
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <DHT.

h> // Define DHT11 settings


#define DHTPIN 2 // DHT11 data pin connected to digital pin 2
#define DHTTYPE DHT11 // Specify the sensor type
DHT dht(DHTPIN, DHTTYPE); // Create a DHT object
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud rate
Serial.println("DHT11 Temperature and Humidity Sensor");
dht.begin(); // Initialize the DHT11 sensor
}
void loop() {
// Read temperature and humidity values
float humidity = dht.readHumidity();
float temperature = dht.readTemperature(); // Celsius by default
// Print the values to Serial Monitor
Serial.print("Humidity: ");
Serial.print(humidity);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
delay(2000); // Wait 2 seconds before the next reading
}
-------------------------------------------------------------------------------------------------------------------------
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#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(115200);

if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64


Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0, 10);
// Display static text
display.println("SURESH");
display.display();
}
void loop() {
}
---------------------------------------------------------------------------------------------------------------------
Note SDA A4 SCL A5 VCC 5V

You might also like