Whether Station Using Attiny85 Microcontroller With Oled Display
by Mr Shubham in Circuits > Microcontrollers
994 Views, 6 Favorites, 0 Comments
Whether Station Using Attiny85 Microcontroller With Oled Display
Welcome to the world of DIY weather monitoring with our DIY Weather Station project! Are you curious about the temperature and humidity levels around you? Do you want a compact and affordable solution to keep track of the weather conditions? Look no further! In this project, we will guide you through the process of building a weather station using the ATtiny85 microcontroller, a DHT22 temperature and humidity sensor, and a 1306 OLED display.
Our weather station project is designed to provide real-time temperature and humidity readings displayed on a compact OLED screen. With this project, you can monitor the current weather conditions right at your fingertips. Whether you want to check the temperature in your room, your greenhouse, or any other space, this DIY weather station has got you covered.
By following our step-by-step instructions, you'll not only gain hands-on experience in building electronic circuits but also learn how to program the ATtiny85 microcontroller and interface it with the DHT22 sensor and OLED display. This project is perfect for beginners and hobbyists who want to explore the world of microcontrollers and sensors.
The ATtiny85 microcontroller acts as the brain of our weather station, collecting temperature and humidity data from the DHT22 sensor and displaying it on the OLED screen. The compact size of the ATtiny85 makes it ideal for small-scale projects like this, offering low power consumption and versatility.
So, get ready to dive into the exciting world of weather monitoring as we guide you through each step, from gathering the components to uploading the code and assembling the circuit. Let's embark on this DIY adventure and create our very own Weather Station using the ATtiny85, DHT22 sensor, and OLED display!
Supplies
These were the materials used in this building as hardware -
- ATtiny85 microcontroller - It will serve as the brain of the weather station, collecting and processing data.
- DHT22 temperature and humidity sensor - This sensor will measure the temperature and humidity levels in the environment.
- 1306 OLED display - The OLED display will show the real-time temperature and humidity readings.
- Breadboard - It will provide a platform for prototyping and connecting the components.
- Jumper wires - These wires will be used to establish connections between the components on the breadboard.
- USBasp programmer (or any other suitable programmer) - This programmer must upload the code to the ATtiny85 microcontroller.
Ensure these components are ready before you begin building the weather station.
Open WWW. Wokwi.Com
Open a web browser and visit the Wokwi Simulator website by typing "wokwi.com" in the browser's address bar.
By following this step, you'll be able to access the Wokwi Simulator platform directly from your web browser.
Select ATTINY85 Microcontroller
Scroll down on the Wokwi Simulator website to explore the available microcontrollers. Locate and select the "ATtiny85" microcontroller from the list.
By following this step, you will select the ATtiny85 microcontroller as the target microcontroller for your project on the Wokwi Simulator platform.
Add the Components at Workplace
Add the required materials to your workplace, including the DHT22 temperature and humidity sensor and the 1306 OLED display.
- Take the DHT22 sensor and place it on your work surface.
- Locate the 1306 OLED display and place it next to the DHT22 sensor.
Make the Connections With ATTINY85
Make the connections between the components as follows:
- DHT22 Sensor:
- Connect the VCC pin of the DHT22 sensor to the VCC (power) pin of the ATtiny85.
- Connect the GND (ground) pin of the DHT22 sensor to the GND (ground) pin of the ATtiny85.
- Connect the data pin of the DHT22 sensor to PB1 (digital pin 6) of the ATtiny85.
- 1306 OLED Display:
- Connect the VCC (power) pin of the OLED display to the VCC (power) pin of the ATtiny85.
- Connect the GND (ground) pin of the OLED display to the GND (ground) pin of the ATtiny85.
- Connect the SDA (data) pin of the OLED display to PB0 (digital pin 5) of the ATtiny85.
- Connect the SCL (clock) pin of the OLED display to the PB2 (digital pin 7) of the ATtiny85.
By completing this step, you will have successfully made the necessary connections between the DHT22 sensor and the ATtiny85 microcontroller, as well as between the OLED display and the ATtiny85. Ensure the connections are secure, and double-check the pin assignments to avoid any potential errors.
Add the Code Into Coding Section
Add The Below Code Into The Editor:
#include <dht.h>
#include <TinyWireM.h>
#include <Tiny4kOLED.h>
#define DHT22_PIN PB1
const unsigned char img_heart_small[] PROGMEM = {
0x00, 0x00, 0xc0, 0xe0, 0xe0, 0xe0, 0xc0, 0x80, 0x80, 0x80, 0xc0, 0xe0, 0xe0, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00
};
const unsigned char img_heart_big[] PROGMEM = {
0xe0, 0xf0, 0xf8, 0xf8, 0xf8, 0xf8, 0xf0, 0xe0, 0xe0, 0xe0, 0xf0, 0xf8, 0xf8, 0xf8, 0xf8, 0xf0, 0xe0, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00
};
const unsigned char img_thermometer[] PROGMEM = {
0x00, 0xfe, 0x03, 0xfe, 0x50,
0x00, 0xff, 0x00, 0xff, 0x55,
0x60, 0x9f, 0x80, 0x9f, 0x65,
};
dht DHT;
void splash() {
oled.clear();
oled.setCursor(15, 1);
oled.print(F("Technical Shubham"));
oled.setCursor(35, 3);
oled.print(F("Temperature"));
oled.setCursor(35, 5);
oled.print(F("And "));
oled.setCursor(35, 7);
oled.print(F("Humidity "));
}
void heartBeat() {
static char big = 1;
static long startTime = 0;
long currentTime;
// Get current time
currentTime = millis();
// Update if 200ms passed
if ((currentTime - startTime) > 200) {
startTime = currentTime;
big = 1 - big;
if (big) {
oled.bitmap(20, 4, 37, 6, img_heart_big);
} else {
oled.bitmap(20, 4, 37, 6, img_heart_small);
}
}
}
void prepareDisplay() {
unsigned int i, k;
unsigned char ch[5];
oled.clear();
oled.begin();
oled.setCursor(18, 0);
oled.print(F("Technical Shubham"));
oled.setCursor(1, 2);
oled.print(F("temperature-humidity"));
oled.bitmap(105, 4, 110, 7, img_thermometer);
oled.setCursor(57, 4);
oled.print(F("24.0C"));
oled.setCursor(57, 5);
oled.print(F("40.0%"));
oled.bitmap(10, 5, 17, 2, img_heart_small);
}
float getTemperature() {
return DHT.temperature;
}
float getHumidity() {
return DHT.humidity;
}
void setup() {
pinMode(DHT22_PIN, INPUT);
oled.begin(128, 64, sizeof(tiny4koled_init_128x64br), tiny4koled_init_128x64br);
// Two fonts are supplied with this library, FONT8X16 and FONT6X8
oled.setFont(FONT6X8);
// To clear all the memory
oled.clear();
oled.on();
splash();
delay(3000);
prepareDisplay();
}
void loop() {
static long startTime = 0;
long currentTime;
DHT.read22(DHT22_PIN);
// Get current time
currentTime = millis();
// Checks 1 second passed
if ((currentTime - startTime) > 1000) {
startTime = currentTime;
// Update temperature
float temperature = getTemperature();
// Set cursor
oled.setCursor(57, 4);
// Print to display
oled.print(temperature, 1);
oled.print("C ");
// Update humidity
float humidity = getHumidity();
// Set cursor
oled.setCursor(57, 5);
// Print to display
oled.print(humidity, 1);
oled.print("% ");
oled.bitmap(105, 4, 110, 7, img_thermometer);
}
heartBeat();
}
The provided code for the DIY Weather Station requires several libraries to function properly. These libraries include DHTlib, TinyWireM, and Tiny4kOled. The DHTlib library is used for interacting with the DHT22 temperature and humidity sensor, allowing the code to read temperature and humidity values accurately. The TinyWireM library is utilized for I2C communication, enabling the ATtiny85 microcontroller to communicate with the 1306 OLED display. Lastly, the Tiny4kOled library provides the necessary functions to control and display content on the OLED screen. By including these libraries in your Arduino sketch, you ensure that all the required functionalities and communication protocols are properly implemented, allowing the DIY Weather Station to operate seamlessly.
If You Want to Make It on Hardwear Follow Below Steps :
To upload the code to the ATtiny85 using an external programmer, you would typically follow these steps:
- Connect the USBASP programmer (or any other suitable programmer) to your computer using a USB cable.
- Make sure you have the necessary drivers and software installed for your specific programmer. The USBasp programmer usually requires the "avrdude" software and associated drivers.
- Open the Arduino IDE on your computer and select the appropriate board and programmer settings. In this case, you would select "ATtiny85" as the board and choose the correct programmer option.
- Connect the USBASP programmer to the ATtiny85 microcontroller. Ensure that the pin connections are correct, including the MISO, MOSI, SCK, and RESET pins.
- In the Arduino IDE, click on "Upload" to compile the code and upload it to the ATtiny85 microcontroller. The IDE will use the external programmer to communicate with the ATtiny85 and transfer the code.
RESULT
The DIY Weather Station is now complete! With the ATtiny85 microcontroller, DHT22 sensor, and 1306 OLED display connected and powered up, you can now monitor live temperature and humidity readings on the OLED display. The display will continuously update with the latest data, allowing you to stay informed about the current environmental conditions in real time. I made the coding with the help of the ChatGPT chatbot You can use it to make a customizable animation in the display Enjoy the convenience of having this compact weather station at your disposal, providing you with accurate and easily accessible information about the temperature and humidity levels wherever you are.