กลับไปหน้ารวมไฟล์
building-a-wireless-temperature-sensor-battery-powered-7c1772-en.md

Introduction

In the world of IoT (Internet of Things), wireless temperature sensors play a crucial role in monitoring environmental conditions such as temperature and humidity. Whether you're interested in home automation, smart agriculture, or simply experimenting with new technologies, creating your wireless sensor network can be an exciting and rewarding project. In this article, we'll walk you through building a wireless temperature and humidity sensor using the ESP32 microcontroller and the ESP-NOW communication protocol.

What is ESP-NOW?

ESP-NOW is a low-power, peer-to-peer wireless communication protocol developed by Espressif, the maker of the ESP32 microcontroller. Unlike Wi-Fi or Bluetooth, ESP-NOW allows devices to communicate directly with each other without the need for a router or access point. This makes it ideal for applications that require low latency and minimal power consumption, such as battery-powered sensors.

Step 1: Designing

Requirements

  1. The sensor should be wireless
  2. It should be battery-powered
  3. it should last up to 6 months on a single charge

Components Required

To get started, you'll need the following components:

  1. ESP32 microcontroller: The heart of the project, known for its powerful processing capabilities and built-in wireless features. We are going to use ESP8685-WROOM-03 which is a module in the family of ESP32-C3 series chips.
  2. DHT11 or DHT22 sensor: A reliable sensor used to measure temperature and humidity.
  3. Battery: We will use a 3.7V 500mAh battery to power the system.MCP1700: A 3.3V voltage regulator with low dropout voltage.

AMS1117 3.3 vs MCP1700 3.3

The AMS1117 is a cheap and reliable voltage regulator IC. But it has a dropout voltage of 1V. because our battery gives a maximum of 4.2 volts at full charge, We cannot drive 3.3V out of AMS1117 IC with that voltage. Hence we will be using MCP1700 which has a dropout voltage of 150mV only.

Step 2: Designing and Ordering PCBs

  1. Compact in design
  2. Battery Input pads
  3. LED light for indication
  4. A button

Once finished I uploaded my design onto Altium365 to share it with you all.

Get a free trial of Altium Designer with 365 and 25% off your purchase: https://www.altium365.com/yt/robocircuits

Now, the PCB design was ready. then it's time to order the PCBs from NextPCB.

Wait for your package to arrive.

Step 3: Assembly

PCBs were assembled in two phases

1. SMD Assembly

2. THT Assembly

undefined

Step 4: Writing the Code and Testing

With the hardware set up, it's time to write the code. We'll be using the Arduino IDE to program the ESP32. If you haven't already, install the ESP32 board support in the Arduino IDE using this article.

Low-Power Optimization: Wireless Temp Node

Running an Arduino on batteries usually kills the power bank in two days. The Wireless Battery-Powered Temp Sensor focuses not on the sensors, but on extreme Power Profiling, achieving months or even a year of battery life on a single coin cell!

Deep Sleep Operations

The magic here is the `LowPower` or `avr/sleep.h` libraries. We implemented deep sleep functionality in ESP8685 to save as much power as we could.

  1. The Wake Up: The Arduino wakes up instantly.
  2. The Job: It quickly reads the sensor, powers up the radio module, blasts the data packet to a central hub in just milliseconds, and shuts the radio down.
  3. The Coma: It commands the processor to enter a "Deep Sleep" state. In this state, it shuts off its internal clocks and peripherals, drawing only a few microamps of current.

Let’s calculate the battery life with the new timings:

Step 1: Calculate the total current consumption for one cycle (active + sleep).

Active mode:

  1. Current: 80mA
  2. Duration: 0.3 seconds
  3. Energy consumed: 80 mA x 0.3 seconds= 24 mA-seconds

Deep sleep mode:

  1. Current (estimated): ~0.01mA (10µA)
  2. Duration: 60 seconds (1 minute)
  3. Energy consumed: 0.01 mA x 60 seconds = 0.6 mA-seconds

Total energy consumption per cycle:

  1. 24 mA-seconds + 0.6 mA-seconds = 24.6 mA-seconds

Step 2: Calculate the number of cycles per hour.

  1. Each cycle duration: 0.3 seconds + 60 seconds = 60.3 seconds
  2. Number of cycles per hour: approx 59.7 cycles/hour

Step 3: Calculate the total energy consumption per hour.

  1. 59.7 cycles/hour x 24.6 mA-seconds/cycle = 1468.62 mA-seconds/hour
  2. Convert mA-seconds to mAh: 0.41mAh/hour

Step 4: Calculate the battery life.

  1. Battery capacity: 500mAh
  2. Battery life: 1219.5 hours

Conclusion:

The ESP32 will run for approximately 1219.5 hours on a 500mAh battery with the given power consumption pattern. This is roughly 50.8 days.

Hardware Optimization

  • ESP32-C3 (ESP8685-WROOM-03): You cannot use a board with a power-hungry USB chip and always-on LEDs. We use a raw module optimized for low-power operation.
  • ESP-NOW Protocol: Allows for direct, low-latency, and low-power communication without a router.
  • MCP1700 Voltage Regulator: Selected for its very low dropout voltage to maximize battery usage.
  • 3.7V 500mAh Battery.

This project proves you are ready to design commercial-grade IoT sensors.

Code

ESP-NOW temperature sensor code is given with this article just upload it.

ESP-NOW Slave CodeSlave Code for Heltec ESP32 LoRa V2. To program an ESP32 LoRa V2 from Heltec you may need to read this article.

On testing the sensor was working perfectly. It was transmitting values over the ESP-NOW protocol to the slave device successfully.

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
  - "1x altium designer"
author: "robocircuits"
category: "Sensors & Environment"
components:
  - "1x DHT11 Temperature & Humidity Sensor (4 pins)"
  - "1x Arduino® Nano ESP32"
  - "1x Soldering Iron Tip, Drag Hoof"
description: "Cut the cord! Build an ultra-low-power environmental sensor that runs on coin-cell batteries for months, transmitting via nRF24L01 radio."
difficulty: "Intermediate"
documentationLinks: []
downloadableFiles:
  - "https://projects.arduinocontent.cc/f5b81ab6-0ec3-47ee-bb45-d8ad73934762.ino"
  - "https://projects.arduinocontent.cc/487854eb-8a48-4b4f-9017-dae1d32a2d45.ino"
encryptedPayload: "U2FsdGVkX18zGE6h2/2Y5/Xc3f4M46QUrCVTkE/6Wig4bc+DH261WD5fzHUynllM31Z/FOUl0ze826eyppDsS/sUCVi9U4vQnxSctIPJvAb+mc5zIz2lN3dP1srSOjaI"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/building-a-wireless-temperature-sensor-battery-powered-7c1772_cover.jpg"
lang: "en"
likes: 1
passwordHash: "d17c335484ca806141e0553ebd64d7fd0647dbd89feb3443ed2d57fe014d3f51"
price: 2450
seoDescription: "Build a battery-powered Wireless Temperature Sensor using ESP-NOW and Deep Sleep for efficient power saving and data transmission with Arduino."
tags:
  - "Environmental Sensing"
  - "Internet Of Things"
title: "Building a Wireless Temperature Sensor battery-powered"
tools: []
videoLinks:
  - "https://youtu.be/GtVXOUcxrew"
views: 1136