ATtiny85

ATtiny85 and DHT21 Temperature & Humidity Sensor and SSD1306 Oled Display, Arduino

ATtiny85 and DHT21:

 

ATtiny85 and DHT21 Temperature & Humidity Sensor and SSD1306 Oled Display, Arduino- If you are just getting started with the ATtiny85 microcontroller then I highly recommend you should read my previous article on the ATtiny85 microcontroller because if you want to program this tiny microcontroller using the Arduino IDE then, first of all, you will need to burn a bootloader on the ATtiny85 microcontroller and besides this, you must also know about its technical specifications, how to add the ATtiny85 microcontroller in the Arduino IDE, and how to externally power up this microcontroller.

Anyway, in today’s article, we are going to make a Temperature and Humidity monitoring system using the most popular DHT21 Temperature and Humidity sensor, and the I2C-supported SSD1306 Oled display module.

allpcb circuit

The image showcases a collection of temperature and humidity sensors from the DHT series. The DHT series includes popular sensors such as DHT11, DHT22, and DHT21. These sensors are compact modules designed to measure temperature and humidity in various environments. The image displays the different sensor models side by side, highlighting their physical similarities and variations. The DHT series sensors are commonly used in projects that require accurate and reliable temperature and humidity measurements, such as weather monitoring systems, home automation, and climate control applications.

Instead of using the DHT21 Sensor, you can also use the DHT11 Temperature and Humidity Sensor. If you haven’t purchased a temperature and humidity sensor yet, then I would recommend that you buy the DHT21 sensor. Because it’s fast and accurate compared to the DHT11 sensor. I have used these sensors in several beginner, intermediate, and advanced level projects.

Normally, I use the same Adafruit_GFX.h and Adafruit_SSD1306.h libraries when I use the SSD1306 Oled display module with the Arduino Uno, Arduino Nano, ESP32, and ESP8266 etc. But in the case of ATtiny85 these libraries didn’t work. So, later in this article, I will explain; which libraries to download and how to use them. So, without any further delay let’s get started!!!




Amazon Links:

Arduino Nano USB C type (Recommended)

ATtiny85 Controller

SSD1306 Oled Display Module

DHT21 Temperature and Humidity Sensor

Arduino Uno

*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.

ATtiny85 and DHT21 Circuit Diagram:

The image showcases a DHT21 sensor connected to an ATtiny85 microcontroller using the Arduino IDE. The DHT21 sensor is a temperature and humidity sensor module, while the ATtiny85 is a small, low-power microcontroller. The sensor is mounted on a breadboard, and wires connect its data, power, and ground pins to the corresponding pins on the ATtiny85 microcontroller. The Arduino IDE is displayed on the screen, indicating that the user is programming the ATtiny85 to read and process temperature and humidity data from the DHT21 sensor. This setup allows for temperature and humidity monitoring and control using the ATtiny85 microcontroller.

Connect the VCC and GND pins of the DHT21 Temperature and Humidity sensor to the 5V and GND pins on the ATtiny85 microcontroller. Pin4 on the ATtiny85 is the Ground while Pin8 is the VCC. Connect the Data wire of the DHT21 sensor to Pin6 which is the digital pin D1 as per the ATtiny85 Pinout diagram.

Similarly, connect the VCC and GND pins of the I2C supported SSD1306 Oled display module to the 5V and GND pins on the ATtiny85 microcontroller. Connect the SCL and SDA pins of the Oled display module to the pins 7 and 5 on the ATtiny85 microcontroller.

The image displays the ATtiny85 microcontroller, focusing specifically on the SCL (Serial Clock) and SDA (Serial Data) pins. The ATtiny85 is a compact microcontroller with a limited number of pins. The SCL and SDA pins are part of the I2C (Inter-Integrated Circuit) communication protocol. The SCL pin is used for synchronizing data transfer between devices, while the SDA pin is responsible for transmitting and receiving data. These pins are essential for connecting the ATtiny85 to other I2C-compatible devices, enabling data exchange and communication in various projects and applications.

Pin7 is the SCL and Pin5 is the SDA as you can see in the ATtiny85 Pinout Diagram. You can use AAA batteries to power up your project, or you can use any 5V regulated power supply.



The image features a DHT sensor connected to an ATtiny85 microcontroller. The DHT sensor is a temperature and humidity sensor module, while the ATtiny85 is a small, low-power microcontroller. The DHT sensor is mounted on a breadboard, and wires connect its data, power, and ground pins to the corresponding pins on the ATtiny85 microcontroller. This setup allows the ATtiny85 to read temperature and humidity data from the DHT sensor, making it suitable for various applications requiring environmental monitoring and control.

In my case, I am using my designed 5V and 3A power supply. As you can see I have connected the 5v and GND wires to the VCC and GND pins on the ATtiny85 microcontroller. I have a very detailed article on how to design a 5V and 3A power supply in Altium designer. So, that’s all about the connections. Now, let’s go ahead and install the required libraries.



ATtiny85 Arduino Libraries for SSD1306:

Make sure you have the latest version of the Arduino IDE installed on your computer or laptop. Anyway, we are going to install three libraries, one for the DHT21, and the other two libraries for the SSD1306 Oled display module. For this, go to the Sketch Menu, then to Include Library, and click on the Manage libraries.

The image showcases the installation process of the DHT11 library for the ATtiny85 microcontroller in the Arduino IDE. The Arduino IDE (Integrated Development Environment) is a software platform used for programming microcontrollers. In the image, the user is navigating through the Arduino IDE menus to add support for the DHT11 library specifically designed for the ATtiny85 microcontroller. They are selecting the appropriate library manager and clicking on the install button. This action enables users to utilize the DHT11 temperature and humidity sensor with the ATtiny85 microcontroller, expanding the range of compatible libraries for their projects.

search for the dht. As you can see I have already installed this library. And this is the same library I have been using with Arduino Uno and Arduino Nano. And it’s also compatible with the ATtiny85.

The image showcases the installation process of the DHT11 library for the ATtiny85 microcontroller in the Arduino IDE. The Arduino IDE (Integrated Development Environment) is a software platform used for programming microcontrollers. In the image, the user is navigating through the Arduino IDE menus to add support for the DHT11 library specifically designed for the ATtiny85 microcontroller. They are selecting the appropriate library manager and clicking on the install button. This action enables users to utilize the DHT11 temperature and humidity sensor with the ATtiny85 microcontroller, expanding the range of compatible libraries for their projects.



Next, we are going to install the TinyWireM library. This is the one I am going to install. The TinyWireM library has been installed.

The image showcases the TinyWireM Arduino library specifically developed for the SSD1306 OLED display module with the ATtiny85 microcontroller. The ATtiny85 is a compact microcontroller with limited resources, while the SSD1306 OLED display module offers high-resolution display capabilities. The TinyWireM library provides an optimized I2C communication protocol implementation for the ATtiny85 microcontroller, enabling seamless and efficient communication with the SSD1306 OLED display. This library allows ATtiny85-based projects to display text, graphics, and other visual elements on the SSD1306 OLED display, expanding the visual output options for ATtiny85-based applications.

Next we are going to install the Tiny4kOLED library. This is the library that we need to install and as you can see this library is created for an ATtiny85 to use an I2C supported SSD1306 Oled display module. So, let’s go ahead and install this library.

The image represents the Tiny4kOLED library specifically designed for the SSD1306 OLED display module with the ATtiny85 microcontroller. The ATtiny85 is a small, low-power microcontroller, while the SSD1306 OLED display module is a compact display unit with high-resolution capabilities. The library, named Tiny4kOLED, enables easy integration and control of the SSD1306 OLED display with the ATtiny85 microcontroller. It provides a set of functions and commands that allow users to display text, graphics, and other visual elements on the OLED display, enhancing the visual output capabilities of the ATtiny85-based projects.

The library has been installed. I am also going to install the TinyOLED-Fonts library, although I don’t need this library, but as this library has a collection of fonts; so, I think, I may need this library.

The image represents the TinyOLED Fonts library specifically developed for the SSD1306 OLED display module with the ATtiny85 microcontroller. The ATtiny85 is a small, low-power microcontroller, while the SSD1306 OLED display module is a compact display unit with high-resolution capabilities. The TinyOLED Fonts library is designed to enhance the text rendering capabilities of the ATtiny85 microcontroller on the SSD1306 OLED display. It provides a collection of font styles and sizes that can be easily integrated into projects, enabling the display of text with various visual appearances, enhancing readability and aesthetics in ATtiny85-based applications.

All the libraries are installed and now let’s take a look at the programming.




Programming:

I have added the required libraries. The DHT21 Data wire is connected to the PB1 pin which is the physical pin number 6 or the digital Pin1.

This part of the code is to display the thermometer icon on the Oled Display module. And then the rest of the code is almost the same.



Now, the final step is to upload this program. As you know, the ATtiny85 has no USB support so we will need to use an Arduino board to upload the program. So, next I am going to explain how to connect your ATtiny85 with the Arduino Uno.

The image showcases an ATtiny85 microcontroller connected to an Arduino Uno board for the purpose of uploading a program. The ATtiny85 is a compact microcontroller with limited programming capabilities, while the Arduino Uno is a more powerful development board. In the image, wires are used to establish a connection between specific pins on both boards, enabling the transfer of the program from the Arduino Uno to the ATtiny85. This configuration allows users to leverage the programming capabilities of the Arduino Uno to develop and upload programs to the ATtiny85 microcontroller, expanding its functionality and programming options.

Connect pin 1 of the ATtiny85 which is also the reset pin to pin 10 of the Arduino which is the SS (Slave Select).

Connect pin 4 which is the ground pin to the Ground pin of the Arduino.

Connect pin 5 which is the MOSI pin to pin 11 of the Arduino which is the MOSI (Master-out, Slave In).

Connect pin 6 which is the MISO pin to pin 12 of the Arduino which is the MISO (Maser-In, Slave Out).

Connect pin 7 which is the SCK pin to pin 13 of the Arduino which is the SCK (Serial Clock).

Connect pin 8 of the ATtiny85 which is the VCC pin to the Arduino 5V pin.

Finally, connect a 10uF capacitor between the Reset and GND pins of the Arduino. Make sure you connect the +Ve leg of the capacitor with the Reset pin and the other leg of the capacitor with the GND. So, that’s all about the connections.

Connect Arduino Uno with the Laptop and Upload this program. But first, you will need to add the ATtiny85 controller in the Arduino IDE.



ATtiny85 in Arduino IDE:

The ATtiny85 microcontroller is not pre-installed in the Arduino IDE and you can confirm this by going to the Tools Menu and then to board, you will see a long list of the Arduino boards, but you won’t find ATtiny85. So, this means you will have to manually install the ATtiny85 as a board in the Arduino IDE.

For this, copy the board manager URL link given below.

https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

Then come back to the Arduino IDE, go to the File Menu, and then to Preferences, and paste the link in the Additional Boards Manager URLs.

The image demonstrates the process of adding the ATtiny85 microcontroller to the Arduino IDE using the board manager. The user is shown accessing the Arduino IDE's board manager, which provides a graphical interface for managing microcontroller boards. A hyperlink labeled 'how-to-add-ATtiny85-in-the-Arduino-ide-board-manager' is visible in the image, indicating a resource or tutorial explaining the steps for adding the ATtiny85 board. This feature allows users to expand the range of supported microcontrollers in the Arduino IDE, enabling them to program and develop projects specifically for the ATtiny85 microcontroller.

Put a comma if you have added other boards otherwise you can directly paste the board URL link and then click on the OK button.



Go to the Tools Menu, then to board, and click on the Boards Manager. Search for the ATtiny and install it.

The image illustrates the process of installing an ATtiny85 board in the Arduino IDE. The Arduino IDE (Integrated Development Environment) is a software platform used for programming microcontrollers. In the image, the user is navigating through the Arduino IDE menus to add support for the ATtiny85 board. They are selecting the appropriate board manager and clicking on the install button. This action enables users to program the ATtiny85 microcontroller using the Arduino IDE, expanding the range of compatible boards for their projects.

You can see the ATtiny85 is included in this boards Package. Anyway, you can see I have already installed this board.

Now, to confirm that the ATtiny85 Microcontroller is added, go to the Tools Menu, then to Board and you can see the ATtinny Microcontrollers.

The image showcases the installation process of the ATtiny85 microcontroller board in the Arduino IDE. The Arduino IDE (Integrated Development Environment) is a software platform used for programming microcontrollers. In the image, the user is navigating through the Arduino IDE menus to add support for the ATtiny85 microcontroller board. They are selecting the appropriate board manager and clicking on the install button. This action enables users to program the ATtiny85 microcontroller using the Arduino IDE, providing an integrated development environment with familiar tools and features for ATtiny85-based projects.

You can see different variants of the ATtiny microcontrollers. So, let’s go ahead and select the ATtiny85 controller.

Now, let’s go ahead and upload the program.

Note: Make sure you have installed the Bootloader on the ATtiny85; if not then read my getting started article on the ATtiny85.

The image showcases a temperature and humidity monitoring system implemented using the ATtiny85 microcontroller. The system consists of the ATtiny85 microcontroller, a DHT sensor (such as DHT11 or DHT22), and supporting components. The ATtiny85 is programmed to read temperature and humidity data from the DHT sensor. The data is then processed and displayed on a display module or transmitted to a connected device for monitoring purposes. This setup enables the ATtiny85 microcontroller to provide real-time temperature and humidity monitoring capabilities, making it suitable for various applications requiring environmental data monitoring.




Everything looks good and now let’s power up this project.

The image showcases an ATtiny85 microcontroller project featuring a DHT21 temperature and humidity sensor and an SSD1306 OLED display, all connected to an Arduino board. The compact ATtiny85 chip is the main controller, responsible for reading temperature and humidity data from the DHT21 sensor. The data is then displayed on the small, high-resolution OLED display (SSD1306), providing real-time temperature and humidity readings. The Arduino board acts as the power source and facilitates the communication between the ATtiny85, DHT21 sensor, and SSD1306 display, enabling a compact and efficient temperature and humidity monitoring system.

I was able to monitor the Temperature and Humidity % on the SDD1306 OLED display Module. Next, I applied temperature, as you can see rise in the temperature.

The image showcases an ATtiny85 project designed specifically for beginners. It features a minimalistic setup with the ATtiny85 microcontroller at the center. Surrounding the microcontroller are a variety of basic electronic components such as resistors, capacitors, LEDs, and push buttons. The project aims to provide an entry-level learning experience for beginners to explore the functionalities of the ATtiny85 microcontroller. It offers an opportunity to gain hands-on experience in coding, circuitry, and basic electronics, fostering a foundation for further exploration and development in the world of microcontrollers.

For practical demonstration, watch the video tutorial given below.

Watch Video Tutorial:

 

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button