top of page
Search

Arduino Uno + ESP8266 D1 Mini Smart Room Controller: Build Your Own Sensor, AC Remote, And Web Dashboard

Writer: Sanzhi Kobzhan
Sanzhi Kobzhan
Aug 25
10 min read
Arduino Uno + ESP8266 D1 Mini Smart Room Controller
Arduino Uno + ESP8266 D1 Mini Smart Room Controller

Table of Contents:



Building a useful connected device does not require starting with an advanced microcontroller project. I wanted to create a compact system that could measure room temperature and humidity, publish those readings online, and control my air conditioner remotely from a website.


The final device combines an Arduino Uno, an ESP8266 D1 Mini, a DHT11 sensor, an infrared transmitter, HiveMQ, and a simple web dashboard.


This was also my first soldering project. I had never soldered electronic components before, so the project became as much about learning hardware assembly as writing code. By the end, the prototype had moved from a breadboard to a soldered device that could monitor the room and send real commands to an air conditioner.


Key Takeaways


  • An Arduino Uno can handle local sensor measurements and infrared AC control, while an ESP8266 D1 Mini handles Wi-Fi and MQTT communication.

  • A DHT11 provides simple temperature and relative-humidity measurements that can be published to HiveMQ and displayed on a website.

  • An infrared receiver can capture the signal produced by an existing AC remote, while an IR transmitter can reproduce that signal from Arduino code.

  • MQTT makes the system bidirectional: sensor readings travel from the device to the website, while AC ON/OFF commands travel from the website back to the device.


Why Measure Temperature And Humidity?


I became particularly interested in humidity monitoring because I had experienced mold problems at home caused by high indoor humidity. At the same time, I wanted the room to feel warm and comfortable when I returned home after being outside in cold winter weather. Monitoring both humidity and temperature gave me a practical reason to build the system beyond simply experimenting with sensors.


For a simple home project, the measurements can be used to trigger warnings, automate an air conditioner, or simply track whether a room is staying within a preferred range.

I used a DHT11 because it is inexpensive and straightforward to connect. It is not a precision environmental instrument, but it is practical for learning and basic room monitoring.


How The System Works


I divided the project into two controllers.

The Arduino Uno handles the physical room hardware. It reads the DHT11, and sends the infrared commands that operate the air conditioner.


The ESP8266 D1 Mini handles networking. It receives temperature and humidity data from the Uno, connects to Wi-Fi, publishes the readings to HiveMQ, and subscribes to commands sent from my website.


The architecture looks like this:

DHT11
   │
   ▼
Arduino Uno
   │
   │ ROOM|temperature|humidity
   ▼
ESP8266 D1 Mini
   │
   ▼
Wi-Fi
   │
   ▼
HiveMQ
   │
   ├────────► Website displays room data
   │
   └◄──────── Website sends AC ON/OFF
                  │
                  ▼
             D1 Mini
                  │
                  ▼
             Arduino Uno
                  │
                  ▼
          IR Transmitter
                  │
                  ▼
          Air Conditioner

HiveMQ uses MQTT's publish/subscribe model. A client can publish messages to a topic while another client subscribes to that topic and receives the messages.


Connecting The DHT11 To Arduino Uno


My DHT11 connection is simple:

DHT11              Arduino Uno

VCC  ────────────► 5V
GND  ────────────► GND
DATA ────────────► A0

Connecting The DHT11 To Arduino Uno
Connecting The DHT11 To Arduino Uno

The Arduino reads temperature and humidity every few seconds. The code can then decide whether conditions are normal, trigger automatic AC control, and periodically send the latest measurements to the D1 Mini.


For example, the serial message between the boards looks like:

ROOM|23.4|52.0

The first number is temperature in Celsius and the second is relative humidity.


Connecting The Arduino Uno And ESP8266 D1 Mini


The Uno and D1 Mini communicate through a serial connection.


Connecting The Arduino Uno And ESP8266 D1 Mini
Connecting The Arduino Uno And ESP8266 D1 Mini

My final wiring is:

D1 Mini TX ─────────────────────► Arduino D2

Arduino D3
     │
    1kΩ
     │
     ●──────────────────────────► D1 Mini D5
     │
    2kΩ
     │
    GND

Arduino GND ────────────────────► D1 Mini GND

The voltage divider on the Uno-to-D1 direction reduces the Uno's 5V logic signal before it

reaches the ESP8266 input.


Connecting The Arduino Uno And ESP8266 D1 Mini
Connecting The Arduino Uno And ESP8266 D1 Mini

The D1 Mini then converts the Uno's room measurement into JSON before publishing it to HiveMQ:

{
  "temperature": 23.4,
  "humidity": 52.0
}

Sending Room Data To HiveMQ


I use three MQTT topics:

Room measurements:
home/abc94821/room

Website AC commands:
home/abc94821/ac/command

AC status:
home/abc94821/ac/status

The D1 Mini publishes sensor readings to the room topic. My website reads the latest value and displays temperature and humidity.


The command path works in the opposite direction.


When I press an AC button on the website, the backend publishes either:

ON

or:

OFF

to the AC command topic.


sending room data to my website
sending room data to my website

The D1 Mini subscribes to that topic, receives the message, and forwards:

AC|ON

or:

AC|OFF

to the Arduino Uno.


This publish-and-subscribe structure is one of the reasons MQTT works well for small IoT projects: the website does not need a direct physical connection to the controller.


Learning The Air Conditioner Remote


Controlling the air conditioner was the most interesting part of the build.


An important distinction is that the air conditioner itself was not transmitting data for me to read. Instead, I first used an infrared receiver to capture the command sent by the original AC remote.


The temporary learning setup was:

IR Receiver         Arduino Uno

VCC ──────────────► 5V
GND ──────────────► GND
OUT ──────────────► D6

I pointed the original AC remote at the receiver and pressed the power button. Using the Arduino-IRremote library, I captured the raw timing sequence produced by the remote.


Air-conditioner remotes can use relatively long state messages. Rather than sending only a simple power bit, the remote may encode information such as operating mode, target temperature, fan settings, and power state.


Turning The Air Conditioner On And Off


I captured two different signals: one representing the AC ON state and another representing OFF.


Once those commands were verified, I no longer needed the infrared receiver in the finished device. I removed it and kept only the IR transmitter.


My final transmitter connection is:

IR Transmitter      Arduino Uno

VCC ──────────────► appropriate supply
GND ──────────────► GND
S   ──────────────► D5

When Arduino receives AC|ON from the D1 Mini, it transmits the stored ON infrared timing sequence. When it receives AC|OFF, it transmits the separate OFF sequence.


The Arduino-IRremote project demonstrates this same principle of transmitting captured raw timing arrays.


Adding Automatic AC Control


Remote control was useful, but automation made the device more practical.


My Arduino code can automatically request the ON state when:

Temperature < 20°C
OR
Humidity > 70%

The OFF condition is:

Temperature > 25°C
AND
Humidity < 70%

The gap between the temperature thresholds prevents the controller from rapidly switching between states around a single boundary.


The website buttons remain available even with automation enabled. This means I can use the system as a room controller while still having manual access when needed.


Controlling The AC From A Website


I built a small website that displays the latest temperature and humidity measurements and includes separate controls for turning the AC on and off.


The finished control path is:

Website
   │
   ▼
Backend
   │
   ▼
HiveMQ
   │
   ▼
ESP8266 D1 Mini
   │
   ▼
Arduino Uno
   │
   ▼
IR transmitter
   │
   ▼
Air Conditioner

When the Arduino executes a website command, it returns an acknowledgement to the D1 Mini. The D1 publishes that status to HiveMQ so the website can display the controller's latest reported AC state.


I also keep MQTT credentials on the backend rather than placing broker passwords directly in browser JavaScript. For any internet-connected hardware project, separating public frontend code from private credentials is an important design decision.


From Breadboard To A Soldered Device


The early version of the project was assembled on a breadboard. That made it easy to move wires, test different pins, and diagnose communication problems between the Uno and D1 Mini.


After the system worked reliably, I transferred the connections to perfboard and soldered the components. I had no previous soldering experience, so this was my first attempt at turning a breadboard prototype into a more permanent device.


Arduino Uno Humidity and Temperature controller.
Arduino Uno Humidity and Temperature controller.

The result is not a commercial smart-home product. It is more valuable to me as a working example of how sensors, microcontrollers, Wi-Fi, MQTT, infrared control, and a web interface can be combined into one small custom system.


Final Wiring Overview


ARDUINO UNO

A0  ← DHT11 DATA
D2  ← D1 Mini TX
D3  → voltage divider → D1 Mini D5
D5  → IR transmitter

DHT11

VCC  → 5V
GND  → GND
DATA → A0


D1 MINI

TX → Uno D2
D5 ← Uno D3 through voltage divider
G  → Common GND
5V → Power supply


IR TRANSMITTER

S   → Uno D5
GND → Common GND
VCC → Appropriate supply

This final version no longer needs the LCD or IR receiver. The receiver was useful only while learning the AC remote commands.


Uploading The Code To Arduino Uno And ESP8266 D1 Mini


After wiring the hardware, the next step is uploading a separate sketch to each controller. I used Arduino IDE for both the Arduino Uno and the ESP8266 D1 Mini. Arduino IDE lets you select the board, choose the USB serial port, compile the sketch, and upload it directly to the connected controller.


Because the Uno and D1 Mini run different code, I recommend keeping them as two separate Arduino sketches, for example:

Arduino_Uno_Room_Controller.ino
ESP8266_D1_Mini_MQTT.ino

Download code for Arduino Uno.


Download code for ESP D1 Mini.


Uploading The Arduino Uno Code

  1. Connect the Arduino Uno to your computer with its USB cable.

  2. Open Arduino IDE.

  3. Open the Uno sketch (and paste the code):

File
→ Open
→ Arduino_Uno_Room_Controller.ino
  1. Select the board:

Tools
→ Board
→ Arduino AVR Boards
→ Arduino Uno

The Arduino Uno uses the arduino:avr:uno board platform.

  1. Select the USB port:

Tools
→ Port

On macOS, the port will usually look similar to:

/dev/cu.usbmodem...

or, depending on the USB interface used by the board:

/dev/cu.usbserial...

The exact number at the end will vary from computer to computer.

A simple way to identify the correct port is to disconnect the Uno, look at the available ports, reconnect it, and select the new port that appears.

  1. Make sure the libraries used by the sketch are installed. My Uno code requires:

DHT sensor library
IRremote

SoftwareSerial is included with the Arduino AVR platform.

  1. Click the checkmark button to verify the sketch.

  2. Click the Upload arrow.

Arduino IDE will compile the code and transfer it to the Uno through the selected serial port.

  1. Wait until Arduino IDE reports:

Done uploading.

The Uno can then be disconnected from USB and powered as part of the finished device.


Uploading The ESP8266 D1 Mini Code

The D1 Mini requires the ESP8266 board package before Arduino IDE can recognize it correctly.

  1. Connect the D1 Mini to the computer with a USB data cable.

  2. In Arduino IDE, open:

Arduino IDE
→ Settings / Preferences
  1. Find:

Additional Boards Manager URLs

Add:

The ESP8266 project's documentation recommends installing the ESP8266 platform through Arduino's Boards Manager using this package URL.

  1. Open:

Tools
→ Board
→ Boards Manager
  1. Search for:

esp8266
  1. Install:

esp8266 by ESP8266 Community
  1. After installation, select:

Tools
→ Board
→ ESP8266 Boards
→ LOLIN(WEMOS) D1 R2 & mini

This is the board selection I use for the D1 Mini.

  1. Select:

Tools
→ Port

On macOS, the D1 Mini may appear as something similar to:

/dev/cu.usbserial-...

or:

/dev/cu.wchusbserial...

The exact name depends on the USB-to-serial chip used by the board.

Again, the easiest way to identify it is to disconnect the D1 Mini, check the port list, reconnect it, and select the port that appears.

  1. Install the libraries required by the D1 code:

PubSubClient

The ESP8266 Wi-Fi and secure Wi-Fi libraries are provided by the ESP8266 board package itself.

  1. Open the D1 Mini sketch (copy the code):

ESP8266_D1_Mini_MQTT.ino
  1. Before uploading, enter your own Wi-Fi and HiveMQ credentials in the appropriate configuration section.

For example:

const char* WIFI_SSID =
  "YOUR_WIFI_NAME";

const char* WIFI_PASSWORD =
  "YOUR_WIFI_PASSWORD";

and your HiveMQ connection information.

Do not publish a version of the sketch containing real Wi-Fi or MQTT passwords. If you share the code publicly, replace them with placeholders.

  1. Click Verify.

  2. Click Upload.

  3. Wait for the ESP8266 upload to complete. The final console output commonly ends with a reset of the ESP8266 after flashing.


Upload The Boards Separately

I recommend programming one board at a time:

1. Connect Uno by USB
2. Select Arduino Uno + Uno port
3. Upload Uno sketch

4. Disconnect Uno USB
5. Connect D1 Mini by USB
6. Select LOLIN(WEMOS) D1 R2 & mini + D1 port
7. Upload D1 sketch

This avoids accidentally uploading the wrong program to the wrong board or selecting the wrong serial port.


Once both sketches are installed, reconnect the Uno and D1 Mini using the project wiring. The Uno handles the DHT11 and infrared transmitter, while the D1 Mini handles Wi-Fi and HiveMQ communication.


What I Learned From The Project


The most useful lesson was that a connected device does not have to be built around one controller doing everything.


The Uno is well suited to the physical side of the project: reading a sensor and generating the infrared signal. The D1 Mini handles the networking side, while HiveMQ connects the hardware to the website.


That separation also makes troubleshooting easier. If room measurements stop appearing online, I can check the Uno-to-D1 serial link and MQTT separately. If AC control fails, I can follow the command from the website to HiveMQ, then to the D1, Uno, and finally the IR transmitter.


Frequently Asked Questions


Can I Build This Project Without Previous Soldering Experience?

Yes. I built the first version on a breadboard and only soldered it after the system was working. This was my first soldering project, so testing the circuit before making permanent connections was particularly useful.


Why Use Both Arduino Uno And ESP8266 D1 Mini?

The Uno handles the sensor and infrared hardware, while the D1 Mini provides Wi-Fi connectivity. The split is not mandatory, but it creates a clear separation between local hardware control and network communication.


Do I Need The IR Receiver In The Final Device?

No. I used the receiver to learn the original remote's infrared commands. Once the ON and OFF timing arrays were captured and tested, the final controller only needed the IR transmitter.


Does The Website Connect Directly To The Arduino?

No. The website communicates through HiveMQ. Commands are published to an MQTT topic, the D1 Mini receives them, and the Uno performs the infrared transmission.


Can Other Sensors Or Devices Be Added?

Yes. The same architecture can be expanded with additional environmental sensors, relays, displays, or other controllers. MQTT topics can also be added for new measurements and commands without rebuilding the entire communication model.


From Hardware Projects Back To Investor Tools


InvestorCalculators.net is primarily a collection of practical calculators for investors. While this Arduino project is different from a valuation model, the underlying idea is similar: take raw inputs, process them systematically, and turn them into information or actions that are easier to use.


If you are here for investing rather than electronics, you can also use the site's free tools for discounted cash flow analysis, Piotroski F-Score analysis, bond yield calculations, retirement planning, mortgage analysis, and other financial decisions. The goal is the same across the site: make useful calculations and decision tools accessible without unnecessary complexity.

 
 
 

Comments


bottom of page