Wi-Fi Signal Strength Mapper using ESP32

Hey there, fellow DIY enthusiasts! Today, I'll walk you through an exciting project: building an ESP32 Wi-Fi Signal Strength Mapper. This little device will help you map the Wi-Fi signal strength in different areas of your home or workspace, allowing you to find the best spots for strong and stable connectivity. It's a perfect blend of programming and electronics, leveraging the powerful capabilities of the ESP32. Let’s dive right into it!


Before we get started, make sure you have the following components:


- ESP32 development board (any model with Wi-Fi capability)

- Micro USB cable for programming the ESP32

- Laptop/PC with the Arduino IDE installed

- Breadboard and jumper wires (optional for testing)

- OLED Display (128x64 I2C) (optional, for displaying signal strength in real-time)

  

Step 1: Setting Up the Arduino IDE for ESP32


If you haven't set up the Arduino IDE to program the ESP32, follow these steps:


1. Open the Arduino IDE.

2. Go to File > Preferences.

3. In the Additional Boards Manager URLs field, paste the following link:

https://dl.espressif.com/dl/package_esp32_index.json

4. Go to Tools > Board > Boards Manager, search for "ESP32", and install the ESP32 by Espressif Systems package.

5. Select your ESP32 board from Tools > Board > ESP32 Dev Module.


Step 2: Understanding Wi-Fi Signal Strength Mapping


The ESP32 has a built-in Wi-Fi library that allows it to scan nearby networks and measure their RSSI (Received Signal Strength Indicator) values. The RSSI is a measure of the power level that a device receives from a Wi-Fi access point (AP). In simpler terms, it tells you how strong or weak the Wi-Fi signal is in a particular spot.


RSSI Range Interpretation:


- -30 dBm to -50 dBm: Excellent signal

- -51 dBm to -60 dBm: Good signal

- -61 dBm to -70 dBm: Fair signal

- -71 dBm to -90 dBm: Weak signal

- Below -90 dBm: Extremely poor or no signal


Step 3: Writing the Code


Now, let's write the code that will scan nearby Wi-Fi networks, read their RSSI values, and display the results either through the serial monitor or on an OLED display. If you don't have an OLED, you can skip the display part.


#include <WiFi.h>

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>


// Define OLED display width and height

#define SCREEN_WIDTH 128

#define SCREEN_HEIGHT 64


// Define the OLED reset pin (if required)

#define OLED_RESET -1


// Create an OLED display object

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


void setup() {

    // Initialize serial communication

    Serial.begin(115200);

    

    // Initialize the OLED display

    if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {

        Serial.println("OLED display failed to initialize");

        while (true);

    }


    display.clearDisplay();

    display.setTextSize(1);

    display.setTextColor(SSD1306_WHITE);

    display.setCursor(0, 0);

    display.println("Wi-Fi Signal Mapper");

    display.display();

    

    // Start Wi-Fi in station mode

    WiFi.mode(WIFI_STA);

    WiFi.disconnect();

    delay(100);

}


void loop() {

    Serial.println("Scanning for Wi-Fi networks...");

    int numberOfNetworks = WiFi.scanNetworks();

    

    display.clearDisplay();

    display.setCursor(0, 0);

    display.println("Scanning...");

    display.display();

    delay(500);


    for (int i = 0; i < numberOfNetworks; i++) {

        // Print each network's SSID and RSSI to the serial monitor

        Serial.print("Network: ");

        Serial.println(WiFi.SSID(i));

        Serial.print("Signal strength (RSSI): ");

        Serial.print(WiFi.RSSI(i));

        Serial.println(" dBm");


        // Display SSID and RSSI on OLED (if available)

        display.setCursor(0, (i * 10) + 10);

        display.print(WiFi.SSID(i).substring(0, 10)); // Display first 10 characters of SSID

        display.print(": ");

        display.print(WiFi.RSSI(i));

        display.print(" dBm");

        display.display();

        delay(500);

    }

    

    // Wait before scanning again

    delay(5000);

}


Step 4: Uploading the Code to the ESP32


1. Connect your ESP32 to your computer using the USB cable.

2. Select the correct Port and Board under the Tools menu.

3. Click the Upload button (right arrow icon) in the Arduino IDE.

4. Once the upload is complete, open the Serial Monitor (Tools > Serial Monitor) to see the Wi-Fi networks and their RSSI values.


Step 5: Testing the Mapper


Now that the code is running on the ESP32, it's time to test it out!


- Serial Monitor Output: As you move around with the ESP32, you will see the list of detected Wi-Fi networks and their corresponding RSSI values in the Serial Monitor. Note how the RSSI changes as you move closer or further from the Wi-Fi access point.


- OLED Display Output: If you're using an OLED display, it will show the SSID of the nearby networks and their signal strengths in dBm. This makes it even easier to visualize the strength of each network as you move around.


Step 6: Using the Mapper for Site Surveys


Now that you have a working Wi-Fi signal strength mapper, you can use it to:


- Find the Best Wi-Fi Spots: Walk around your space to identify areas with strong Wi-Fi signals.

- Identify Dead Zones: Map out areas where the signal drops or is too weak to use.

- Optimize Router Placement: Use the RSSI values to help find the best place to position your router for optimal coverage.


Optional: Adding Data Logging


If you want to take this project a step further, you could add data logging to store the Wi-Fi signal strength values with timestamps in a microSD card or even send the data to a Google Sheet using the ESP32's Wi-Fi capabilities. That way, you can create a comprehensive map of your Wi-Fi signal strength over time!


Conclusion


And there you have it! A fully functional ESP32 Wi-Fi Signal Strength Mapper. This project is a great way to learn about Wi-Fi protocols, RSSI, and the ESP32's capabilities. Plus, it's super practical for everyday use in optimizing your home or office Wi-Fi setup.


I hope you found this tutorial helpful. Happy building, and see you in the next project!


Long-Range LoRa-Based Remote Actuator Control using ESP32

This project is ideal for controlling devices over long distances using LoRa (Long Range) technology, which is great for applications in rural areas, agriculture, and IoT networks where internet access is limited.


In this project, you'll use two ESP32 boards with LoRa modules to control an actuator remotely. One ESP32 with a LoRa module will act as the transmitter, sending control commands. The other ESP32 with a LoRa module will be the receiver, controlling the actuator based on the received commands.


Key components:

- ESP32 boards (2x)

- LoRa modules (e.g., SX1278 or RFM95)

- Actuator (e.g., relay module, servo motor)

- 3.7V LiPo batteries (optional for portability)

- Breadboard, jumper wires, and a 5V power supply


Software requirements:

- Arduino IDE with LoRa library (`arduino-lora` library)


Wiring the Components


#1. Transmitter Setup

ESP32 to LoRa Module (SX1278):

  - `MISO` (LoRa) to `GPIO19` (ESP32)

  - `MOSI` (LoRa) to `GPIO23` (ESP32)

  - `SCK` (LoRa) to `GPIO18` (ESP32)

  - `NSS/CS` (LoRa) to `GPIO5` (ESP32)

  - `RST` (LoRa) to `GPIO14` (ESP32)

  - `DIO0` (LoRa) to `GPIO26` (ESP32)

  - `3.3V` (LoRa) to `3.3V` (ESP32)

  - `GND` (LoRa) to `GND` (ESP32)


#2. Receiver Setup

ESP32 to LoRa Module (SX1278):

  - Same connections as the transmitter.


Connecting the Actuator (e.g., Relay) to ESP32:

  - `Signal` pin of the relay to `GPIO15` (ESP32)

  - `VCC` of the relay to `3.3V` or `5V`

  - `GND` of the relay to `GND` (ESP32)


Coding the Transmitter (ESP32)


#include <SPI.h>

#include <LoRa.h>


#define LORA_CS 5

#define LORA_RST 14

#define LORA_IRQ 26


void setup() {

  Serial.begin(115200);

  LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ);


  if (!LoRa.begin(433E6)) {

    Serial.println("Starting LoRa failed!");

    while (1);

  }


  Serial.println("LoRa Transmitter");

}


void loop() {

  // Example: Sending "ON" or "OFF" command to control the actuator

  String message;

  if (digitalRead(2) == HIGH) {  // Replace with your input logic

    message = "ON";

  } else {

    message = "OFF";

  }


  LoRa.beginPacket();

  LoRa.print(message);

  LoRa.endPacket();


  Serial.print("Sent message: ");

  Serial.println(message);


  delay(2000);  // Adjust delay as needed

}


Coding the Receiver (ESP32)


#include <SPI.h>

#include <LoRa.h>


#define LORA_CS 5

#define LORA_RST 14

#define LORA_IRQ 26

#define RELAY_PIN 15


void setup() {

  Serial.begin(115200);

  pinMode(RELAY_PIN, OUTPUT);

  LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ);


  if (!LoRa.begin(433E6)) {

    Serial.println("Starting LoRa failed!");

    while (1);

  }


  Serial.println("LoRa Receiver");

}


void loop() {

  int packetSize = LoRa.parsePacket();

  if (packetSize) {

    String receivedMessage = "";

    while (LoRa.available()) {

      receivedMessage += (char)LoRa.read();

    }


    Serial.print("Received: ");

    Serial.println(receivedMessage);


    // Control the actuator based on received message

    if (receivedMessage == "ON") {

      digitalWrite(RELAY_PIN, HIGH);

      Serial.println("Relay turned ON");

    } else if (receivedMessage == "OFF") {

      digitalWrite(RELAY_PIN, LOW);

      Serial.println("Relay turned OFF");

    }

  }

}


Explanation of the Code


Transmitter Code:

  - Initializes the LoRa module to operate at 433 MHz (you may need to adjust the frequency based on your region).

  - Sends "ON" or "OFF" messages based on input (e.g., a button press).

  - Uses `LoRa.beginPacket()` and `LoRa.endPacket()` to send data over the air.


Receiver Code:

  - Waits for incoming LoRa packets and reads the message.

  - Controls the relay based on the message: "ON" activates the relay, "OFF" deactivates it.

  - Uses `LoRa.parsePacket()` to check for new incoming packets.


Testing and Deployment


1. Upload the transmitter code to one ESP32 and the receiver code to the other ESP32.

2. Power up both ESP32s, ensuring that the LoRa modules are properly connected.

3. Monitor the Serial Monitor of both ESP32s to check the status of sent and received messages.

4. Test the control functionality by simulating the input on the transmitter side (e.g., pressing a button or sending an "ON" command).

5. Observe the actuator's behavior connected to the receiver to ensure it reacts accordingly.


Tips for Optimizing Range


- Use antennas for both LoRa modules to maximize the range.

- Ensure there are minimal obstructions between the transmitter and receiver.

- Adjust the spreading factor (SF) in the LoRa library for better range or faster transmission.


Applications


- Remote farm irrigation control.

- Controlling remote lighting systems.

- Industrial automation in remote areas.

- Home automation across large properties.


This guide offers a comprehensive approach to building a Long-Range LoRa-Based Remote Actuator Control system, combining LoRa communication with the power of ESP32. By using this setup, you can achieve reliable control over distances, ideal for IoT and automation projects in areas with limited infrastructure.


ESP-NOW Based Long-Range Actuator Control

Welcome to the World of Wireless Actuator Control!  

In this project, we will build a long-range wireless actuator control system using ESP-NOW, a low-latency communication protocol developed by Espressif. With this project, you’ll be able to control various actuators such as relays, servo motors, or solenoids from a distance using ESP32 or ESP8266 microcontrollers.


This setup is ideal for applications where you need to control devices remotely, such as:

- Remote control of agricultural equipment (e.g., water pumps, valves)

- Long-distance home automation (e.g., garage doors, lights)

- Outdoor systems (e.g., garden irrigation)


What is ESP-NOW?


ESP-NOW is a proprietary protocol by Espressif that enables direct peer-to-peer communication between ESP32 or ESP8266 devices without the need for a Wi-Fi router. It operates on the 2.4 GHz band and supports data transfers up to 250 bytes per packet. Its key benefits include:

- Low Latency: Almost real-time communication with minimal delay.

- Long Range: Range can exceed 200 meters in open spaces.

- Power Efficiency: Ideal for battery-operated devices due to its low power consumption.

- Wi-Fi Independence: Devices communicate directly, making it perfect for remote areas.


Materials Required


Hardware:

- 2x ESP32 or ESP8266 boards (one for the transmitter and one for the receiver)

- Actuator (e.g., 5V relay module, servo motor, or solenoid)

- Breadboard and jumper wires

- Power supply (e.g., 5V USB power bank or adapter)

- 220-ohm resistor (if using a status LED)


Software:

- Arduino IDE with ESP32/ESP8266 core installed.

- ESP-NOW library (comes built-in with the ESP32 core).


Step 1: Setting Up the Arduino IDE


1. Install the ESP32/ESP8266 Core:

   - Open the Arduino IDE and go to File > Preferences.

   - In the Additional Board Manager URLs field, add:

     - For ESP32: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

     - For ESP8266: http://arduino.esp8266.com/stable/package_esp8266com_index.json

   - Go to Tools > Board > Boards Manager, search for ESP32 or ESP8266, and install the core.

   

2. Select the Board:

   - After installation, select your board under Tools > Board (e.g., ESP32 Dev Module).


Step 2: Understanding the Communication Protocol


ESP-NOW Workflow:

- The transmitter sends a command (e.g., “ON” or “OFF”) to the receiver.

- The receiver processes this command and activates or deactivates the actuator.

- ESP-NOW uses MAC addresses for direct communication between devices. Each ESP32/ESP8266 has a unique MAC address, which we will use to identify the transmitter and receiver.


Step 3: Building the Circuit


Transmitter Setup:

- Components: ESP32/ESP8266 board, a push-button (to send commands), and a 220-ohm resistor with an LED (for visual confirmation).

- Connections:

  - Connect one end of the push-button to GPIO 12 and the other end to GND.

  - Connect the 220-ohm resistor to GPIO 2, and the other end of the resistor to the anode (+) of the LED. Connect the cathode (-) to GND.


Receiver Setup:

- Components: ESP32/ESP8266 board, relay module, and the actuator (e.g., a motor or light).

- Connections:

  - Connect the relay module’s signal pin to GPIO 5 of the ESP32/ESP8266.

  - Connect the relay’s VCC and GND to 5V and GND of the ESP board, respectively.

  - Connect the actuator (e.g., a motor or solenoid) to the NO (Normally Open) and COM (Common) terminals of the relay.


Step 4: Writing the Code


#Transmitter Code (ESP32/ESP8266)

Copy this code into your Arduino IDE and upload it to the transmitter ESP32/ESP8266:


#include <esp_now.h>

#include <WiFi.h>


// Replace with the MAC address of the receiver ESP32/ESP8266

uint8_t receiverAddress[] = {0x24, 0x0A, 0xC4, 0x3E, 0x4A, 0x28}; // Change this to your receiver's MAC

const int buttonPin = 12; // GPIO pin connected to the button

const int ledPin = 2; // GPIO pin connected to an indicator LED


struct_message {

  char command[10];

} dataToSend;


void setup() {

  pinMode(buttonPin, INPUT_PULLUP);

  pinMode(ledPin, OUTPUT);

  

  // Initialize Wi-Fi and ESP-NOW

  WiFi.mode(WIFI_STA);

  esp_now_init();

  esp_now_add_peer(receiverAddress, ESP_NOW_ROLE_COMBO, 1, NULL, 0);

}


void loop() {

  // Check button state and send command

  if (digitalRead(buttonPin) == LOW) {

    strcpy(dataToSend.command, "ON");

    digitalWrite(ledPin, HIGH); // Turn on LED when sending "ON"

  } else {

    strcpy(dataToSend.command, "OFF");

    digitalWrite(ledPin, LOW); // Turn off LED when sending "OFF"

  }

  

  // Send command over ESP-NOW

  esp_now_send(receiverAddress, (uint8_t *)&dataToSend, sizeof(dataToSend));

  delay(1000); // Adjust delay for how frequently data is sent

}


#Receiver Code (ESP32/ESP8266)

Copy this code into your Arduino IDE and upload it to the receiver ESP32/ESP8266:


#include <esp_now.h>

#include <WiFi.h>


const int relayPin = 5; // GPIO pin connected to the relay module


struct_message {

  char command[10];

} incomingData;


void setup() {

  pinMode(relayPin, OUTPUT);

  WiFi.mode(WIFI_STA);

  esp_now_init();

  esp_now_register_recv_cb(OnDataReceive);

}


void OnDataReceive(const uint8_t * mac, const uint8_t *incomingData, int len) {

  memcpy(&incomingData, incomingData, sizeof(incomingData));

  

  if (strcmp(incomingData.command, "ON") == 0) {

    digitalWrite(relayPin, HIGH); // Activate relay

  } else if (strcmp(incomingData.command, "OFF") == 0) {

    digitalWrite(relayPin, LOW); // Deactivate relay

  }

}


void loop() {

  // Loop can remain empty; the callback handles the incoming data

}


Step 5: Pairing the Devices


1. Get the MAC Address:

   - Upload a simple sketch to each ESP32 that prints the MAC address using `WiFi.macAddress()`.

   - Replace `receiverAddress` in the transmitter code with the receiver’s MAC address.


2. Upload the Code: Load the transmitter code onto one ESP32 and the receiver code onto the other.


Step 6: Testing and Debugging


1. Power On both devices.

2. Press the Button on the transmitter:

   - The LED on the transmitter should light up when sending the “ON” command.

   - The actuator connected to the relay on the receiver should activate accordingly.

3. Troubleshooting Tips:

   - If there’s no response, check the wiring and ensure both devices are within range.

   - Ensure the MAC address in the transmitter code matches the receiver’s address.

   - Adjust `delay()` values for optimal responsiveness.


Step 7: Optimizing for Range and Power


1. Improve Range:

   - Use an external antenna if available.

   - Place the devices at a higher elevation and avoid obstacles like walls.

2. Power Management:

   - Use deep sleep mode for battery-operated devices when idle.

   - Activate the transmitter only when sending commands to reduce power consumption.


Testing and Troubleshooting


1. Verify MAC Address: Ensure the MAC address in the transmitter code matches the receiver.

2. Check Serial Monitor: Use the Serial Monitor to debug and verify if commands are being sent and received.

3. Verify Connections: Double-check wiring to ensure all connections are correct and secure.

4. Adjust Delays: Modify the delay() values in the transmitter code for optimal response time.


Conclusion


With this setup, you have a robust, long-range wireless control system for various applications. ESP-NOW offers a simple yet powerful way to connect devices without needing a Wi-Fi network. Try integrating sensors or automating the control logic for even more versatile projects!


Building an Internet Radio Using an ESP32

I've always been fascinated by how compact devices can connect to the internet and play music from all around the world. With a bit of curiosity and a lot of tinkering, I decided to build an internet radio using an ESP32. This little microcontroller is packed with features—Wi-Fi, Bluetooth, and a ton of GPIO pins—making it perfect for this project.


In this article, I'll take you through the entire process, from gathering the materials to setting up the code, and then assembling everything into a functional internet radio. So, grab your ESP32 and let's get started!


Materials Needed


Before jumping into the build, here’s a list of materials you’ll need:

- ESP32 Dev Board: I used the ESP32 DevKit V1, which is widely available and easy to work with.

- I2S Audio Decoder: An I2S decoder like the MAX98357A or the VS1053 is perfect for converting digital audio signals to analog output.

- Speaker: A small 3W speaker works great for this project, but you can use any small speaker that suits your needs.

- Jumper Wires: For connecting everything together.

- Breadboard: For prototyping the circuit before soldering.

- Power Supply: A USB cable for the ESP32 or a 5V power adapter.


Step 1: Setting Up the ESP32 Development Environment


To program the ESP32, you'll need the Arduino IDE installed on your computer. If you haven’t installed it yet, you can download it from the [Arduino website](https://www.arduino.cc/en/software).


Once you have the IDE installed, follow these steps to set up the ESP32 board:

1. Open the Arduino IDE and go to File > Preferences.

2. In the "Additional Board Manager URLs" field, add the following URL:

https://dl.espressif.com/dl/package_esp32_index.json


3. Go to Tools > Board > Board Manager, and search for "ESP32" and install the package.


With this, your Arduino IDE is ready to program the ESP32.


Step 2: Wiring the I2S Decoder to the ESP32


The I2S interface allows the ESP32 to communicate with audio decoders for outputting sound. Here’s how I connected my MAX98357A I2S decoder to the ESP32:


- MAX98357A Pinout:

- LRC (WS): Connect to GPIO 25 of the ESP32.

- BCLK: Connect to GPIO 26.

- DIN (SD): Connect to GPIO 22.

- VIN: Connect to 5V from the ESP32.

- GND: Connect to GND on the ESP32.


Make sure all the connections are firm and double-check the wiring before proceeding. I used a breadboard for this stage to make adjustments easier.


Step 3: Finding Streaming URLs


To make the internet radio work, you’ll need the streaming URL of an internet radio station. There are many directories like [Radio Browser](https://www.radio-browser.info/) or [Shoutcast](https://www.shoutcast.com/) where you can find streaming links.


I chose a station with a simple MP3 stream URL:

http://stream.live.vc.bbcmedia.co.uk/bbc_radio_one


Step 4: Writing the Code


Now, it’s time to get the ESP32 to play that stream. I used the `ESP32-audioI2S` library, which simplifies streaming audio over the internet. Here’s the step-by-step process for setting it up:


1. Install the Audio Library:

   - In the Arduino IDE, go to Sketch > Include Library > Manage Libraries.

   - Search for `ESP32-audioI2S` and install it.


2. The Code:

   Here’s the code I used for streaming audio from an internet station:


   #include "Arduino.h"

   #include "Audio.h"

   #include "WiFi.h"


   const char* ssid = "Your_SSID";

   const char* password = "Your_PASSWORD";

   const char* streamURL = "http://stream.live.vc.bbcmedia.co.uk/bbc_radio_one";


   Audio audio;


   void setup() {

     Serial.begin(115200);

     WiFi.begin(ssid, password);

     while (WiFi.status() != WL_CONNECTED) {

       delay(500);

       Serial.print(".");

     }

     Serial.println("Connected to WiFi");


     audio.setPinout(26, 25, 22);

     audio.connecttohost(streamURL);

   }


   void loop() {

     audio.loop();

   }


Replace `Your_SSID` and `Your_PASSWORD` with your Wi-Fi credentials. This code initializes the Wi-Fi connection, sets up the I2S audio pins, and streams music from the URL.


Step 5: Uploading the Code


Connect your ESP32 to the computer using a USB cable. Select the correct board and COM port from Tools > Board and Tools > Port. Then, click the upload button in the Arduino IDE.


Once the code is uploaded, open the Serial Monitor to check the connection status. If everything is set up correctly, you should see the ESP32 connecting to your Wi-Fi and then streaming the audio.


Step 6: Testing the Audio Output


With the code running, you should start hearing music from the connected speaker. The quality depends on the strength of your Wi-Fi connection and the bitrate of the stream. For me, it was an exciting moment to hear the audio playing from the speaker—proof that everything was working as planned!


Step 7: Building a Custom Enclosure


To give my internet radio a polished look, I decided to build a simple enclosure using an old wooden box. I drilled holes for the speaker and the ESP32's USB port, allowing easy access for reprogramming.


Inside, I mounted the ESP32 and the audio decoder with double-sided tape, ensuring the wires were neatly arranged. A bit of hot glue kept everything in place. It gave the project a nice finished look, making it presentable as a desk accessory.


Step 8: Adding a Display (Optional)


If you want to get fancier, you can add an OLED display to show the station name, song information, or even just a simple equalizer. The I2C OLEDs are pretty straightforward to use with the ESP32.


Here’s a small snippet to get started with a 128x64 OLED:


#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>


#define SCREEN_WIDTH 128

#define SCREEN_HEIGHT 64

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);


void setup() {

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

  display.display();

  delay(2000);

  display.clearDisplay();

  display.setTextSize(1);

  display.setTextColor(SSD1306_WHITE);

  display.setCursor(0,0);

  display.println("Internet Radio");

  display.display();

}


This code will display a simple “Internet Radio” message on the OLED screen. From here, you can customize the display to show any information you want.


Step 9: Troubleshooting Tips


Here are a few common issues I faced during the build and how I solved them:

- No Audio Output: Double-check your I2S connections and ensure the audio decoder is receiving power.

- Frequent Wi-Fi Drops: Make sure you have a strong Wi-Fi signal. Moving closer to the router helped stabilize my connection.

- Code Upload Failures: Press and hold the "BOOT" button on the ESP32 while uploading the code if you encounter issues.


Final Thoughts


Building this internet radio was a fulfilling experience. It’s amazing how the ESP32, a little board, can turn into a streaming device that plays music from across the globe. Plus, I now have a cool internet radio that I built myself, adding a touch of personal flair to my workspace.


If you're looking to dive deeper into the world of DIY electronics, an ESP32 internet radio is a fantastic project. Not only does it provide a practical application, but it also opens up a whole new world of possibilities for integrating the ESP32 with other gadgets and services. Happy tinkering!


Remote Data Logger with Google Sheets using ESP32

Hey there, fellow DIY enthusiasts! Have you ever wished you could remotely log sensor data and store it neatly in a Google Sheets spreadsheet? Well, I did, and that’s how I ended up building my very own ESP32 remote data logger. The ESP32 is an incredible little microcontroller, perfect for projects that require Wi-Fi connectivity. So, I thought, why not use it to gather sensor data and have it all automatically logged in a Google Sheet for easy access? In this guide, I'll walk you through every step I took to bring this project to life, from setting up the ESP32 to coding it to talk with Google Sheets.


Why This Project?


Before diving into the build, let me tell you why I found this project exciting. As someone who’s into home automation, I love keeping track of environmental data like temperature and humidity. But running to the sensor to get readings? Not so much. By setting up the ESP32 to log data to Google Sheets, I can access those readings from anywhere—whether I’m on the couch or halfway across the world. Plus, Google Sheets is free and easy to use, which made it the perfect choice for storing my data.


Materials I Used:


Here’s everything I needed to get started:

- ESP32 Development Board (I used a standard ESP32 DevKitC)

- USB Cable (for programming the ESP32)

- DHT22 Sensor (measures temperature and humidity)

- Breadboard and some jumper wires

- Laptop with Arduino IDE installed (v2.0 or later)

- A Google account (for setting up Google Sheets)


Step 1: Setting Up the ESP32 with the Arduino IDE


First things first, I needed to make sure my Arduino IDE was ready for the ESP32. Here’s how I did it:


1. Install the ESP32 Board:

   - I opened up my Arduino IDE, went to File > Preferences, and pasted this URL into the Additional Board Manager URLs field:

https://dl.espressif.com/dl/package_esp32_index.json

   - Then, I headed to Tools > Board > Board Manager, searched for "ESP32", and clicked Install.


2. Connect the ESP32:

   - With my ESP32 plugged into the laptop via a USB cable, I selected the correct board and port from Tools > Board and Tools > Port.

   - For my setup, I used the "ESP32 Dev Module."


3. Test the Setup:

   - To make sure everything was working, I uploaded the WiFiScan example sketch from File > Examples > WiFi > WiFiScan. If you see a list of available networks in the Serial Monitor, you’re good to go!


Step 2: Wiring the Sensor


Next, it was time to connect the DHT22 temperature and humidity sensor to the ESP32. Here’s the wiring setup I used:


- VCC of the DHT22 connected to the 3.3V pin on the ESP32.

- GND of the DHT22 to the GND of the ESP32.

- Data Pin of the DHT22 to GPIO 4 on the ESP32 (you can use a different pin if you like, but remember to update the code).


I opted for the DHT22 because it’s a bit more accurate than the DHT11, but the DHT11 would work fine for this project too.


Step 3: Preparing Google Sheets for Data Logging


With the ESP32 and sensor ready, I turned my attention to Google Sheets. Here’s how I set up the spreadsheet:


1. Create a New Google Sheet:

   - I went to [Google Sheets](https://sheets.google.com) and created a new sheet titled "ESP32 Data Logger". 

   - I kept the first row for headers: Timestamp, Temperature, and Humidity.


2. Create a Google Apps Script:

   - From the Google Sheets interface, I navigated to Extensions > Apps Script. This is where I wrote a simple script that would allow my ESP32 to send data directly to the sheet.

   - I deleted any existing code in the script editor and replaced it with this:


     function doGet(e) {

         var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

         var row = [];

         var d = new Date();

         row.push(d);

         for (var param in e.parameter) {

             row.push(e.parameter[param]);

         }

         sheet.appendRow(row);

         return ContentService.createTextOutput("Success");

     }


   - I saved the script and deployed it as a Web App by clicking on Deploy > New Deployment, selecting Web App, and setting access to Anyone. This generated a Web App URL—make sure to copy it, as we’ll need it in the next step!


Step 4: Writing the Arduino Code


With my Google Sheets ready to receive data, it was time to code the ESP32. Here’s the code I used:


#include <WiFi.h>

#include <HTTPClient.h>

#include "DHT.h"


#define DHTPIN 4  // Pin where the DHT22 is connected

#define DHTTYPE DHT22


const char* ssid = "your_SSID";  // Replace with your Wi-Fi SSID

const char* password = "your_PASSWORD";  // Replace with your Wi-Fi Password

const char* serverURL = "your_google_script_url";  // Replace with your Web App URL


DHT dht(DHTPIN, DHTTYPE);


void setup() {

    Serial.begin(115200);

    WiFi.begin(ssid, password);

    

    while (WiFi.status() != WL_CONNECTED) {

        delay(1000);

        Serial.println("Connecting to WiFi...");

    }

    

    Serial.println("Connected to WiFi");

    dht.begin();

}


void loop() {

    if (WiFi.status() == WL_CONNECTED) {

        float temperature = dht.readTemperature();

        float humidity = dht.readHumidity();

        

        if (!isnan(temperature) && !isnan(humidity)) {

            HTTPClient http;

            String url = String(serverURL) + "?temp=" + temperature + "&humidity=" + humidity;

            

            http.begin(url);

            int httpResponseCode = http.GET();

            

            if (httpResponseCode > 0) {

                String response = http.getString();

                Serial.println("Response: " + response);

            } else {

                Serial.println("Error sending request");

            }

            

            http.end();

        } else {

            Serial.println("Failed to read from DHT sensor!");

        }

    } else {

        Serial.println("WiFi Disconnected");

    }

    

    delay(60000);  // Log data every 60 seconds

}


Step 5: Testing the ESP32 Data Logger


With the code uploaded, I opened the Serial Monitor and watched as my ESP32 connected to Wi-Fi and started sending data to my Google Sheets. After a few seconds, I switched to my Google Sheet, and there it was—fresh rows of temperature and humidity data, complete with timestamps!


Troubleshooting Tips


Along the way, I ran into a couple of hiccups, so here are a few tips if you encounter similar issues:

- Wi-Fi Connection Issues: Double-check your SSID and password. I also found that bringing the ESP32 closer to my router helped stabilize the connection.

- Google Script Issues: If you get "permission denied" errors, make sure your Web App URL has access set to "Anyone."

- Sensor Readings Not Displaying: Ensure that the sensor is wired correctly, and double-check that you’ve specified the right GPIO pin in the code.


Conclusion: What’s Next?


And that’s it! I now have a fully functional ESP32 remote data logger that sends sensor data straight to Google Sheets. This setup is a great foundation for future projects—imagine monitoring plant soil moisture, tracking energy consumption, or even logging weather data. With a bit of creativity, you can tailor this project to fit a wide range of use cases.


Happy logging, and see you in the next project!


Boosting My IoT Network: ESP32 into a Wi-Fi Repeater

As a DIY enthusiast, I'm always on the lookout for ways to improve the connectivity of my IoT devices around the house. I have several gadgets like smart lights, sensors, and a few home automation devices, but sometimes they struggle to maintain a strong connection in certain parts of my home. That's when I thought, "Why not use an ESP32-S3 as a Wi-Fi repeater?".


The ESP32-S3 is a powerful microcontroller with enhanced Wi-Fi capabilities compared to its predecessor, and it seemed like the perfect solution to extend the reach of my home network without investing in an expensive mesh router. Here’s how I managed to turn my ESP32-S3 into a Wi-Fi repeater, and I’ll walk you through each step, from setting up the hardware to configuring the software.


Why I Chose the ESP32-S3 for This Project


Before diving into the setup, let me explain why I picked the ESP32-S3. The ESP32-S3 is an upgraded version of the standard ESP32, featuring more processing power, additional GPIO pins, and better support for AI and machine learning applications. These features make it ideal for Wi-Fi-related projects and ensure stable performance, especially when dealing with multiple connected devices. And since it comes with both Wi-Fi and Bluetooth, it’s great for any IoT project that requires flexible communication capabilities.


What I Needed for the Project


To get started, I gathered the following items:


- ESP32-S3 Development Board (I used the ESP32-S3 DevKitC)

- Micro-USB Cable (to power and program the ESP32-S3)

- Computer (running the Arduino IDE, which I’ll explain how to set up)

- Wi-Fi Network (the one I wanted to extend)


I also made sure I had a decent power source because I wanted my repeater to run reliably without interruptions. I planned to power the ESP32-S3 using a USB adapter, but even a simple USB port on a computer could work for testing.


Step 1: Setting Up the Arduino IDE for ESP32-S3


The first step was setting up the Arduino IDE to support the ESP32-S3. If you're new to this, don't worry—it's pretty straightforward:


1. I opened the Arduino IDE on my computer.

2. Went to File > Preferences.

3. In the Additional Boards Manager URLs field, I pasted the following URL:

https://dl.espressif.com/dl/package_esp32_index.json
4. Then, I went to Tools > Board > Boards Manager, searched for "ESP32," and installed the ESP32 package. This gave me access to a wide range of ESP32 boards, including the ESP32-S3.

5. After installation, I selected ESP32S3 Dev Module from the Tools > Board menu, making sure the right board was selected.


This setup allowed my Arduino IDE to recognize the ESP32-S3 and made it ready for programming.


Step 2: Installing the Necessary Libraries


Since I was planning to use the ESP32-S3 as a Wi-Fi repeater, I needed a library to manage its dual-mode Wi-Fi capability—acting both as a client to connect to my main Wi-Fi and as an Access Point (AP) for other devices.


I found a very useful library for this purpose on GitHub, the ESP32 Wi-Fi Repeater by Martin Ger. I downloaded the library from the repository:


- The library is available at:  

https://github.com/martin-ger/esp_wifi_repeater


I extracted the contents into the Arduino libraries folder on my computer. With this library in place, I could easily configure the ESP32-S3 to function as a repeater.


Step 3: Connecting the ESP32-S3 to My Computer


I connected the ESP32-S3 to my computer using a micro-USB cable. It's important to ensure that the right **COM port** is selected under **Tools > Port** in the Arduino IDE. This way, the IDE can properly communicate with the ESP32-S3 for uploading code.


Step 4: Configuring the Wi-Fi Repeater Code


Now came the fun part—writing the code to turn the ESP32-S3 into a Wi-Fi repeater. I created a new sketch in the Arduino IDE and wrote the following code:


#include <WiFi.h>

#include <WiFiAP.h>

#include <WiFiSTA.h>


// Configuration settings

const char* ssid = "YOUR_SSID";         // Replace with your Wi-Fi network SSID

const char* password = "YOUR_PASSWORD"; // Replace with your Wi-Fi network password


void setup() {

  Serial.begin(115200);


  // Start the Wi-Fi connection

  WiFi.mode(WIFI_AP_STA);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {

    delay(500);

    Serial.print(".");

  }


  Serial.println("");

  Serial.println("Wi-Fi connected!");

  Serial.print("IP address: ");

  Serial.println(WiFi.localIP());


  // Set up the Access Point (AP)

  WiFi.softAP("ESP32_S3_Repeater", "12345678"); // AP SSID and password

  Serial.println("Access Point configured.");

  Serial.print("AP IP address: ");

  Serial.println(WiFi.softAPIP());

}


void loop() {

  // Keep the repeater running

  delay(1000);

}


In this code:

- I replaced `YOUR_SSID` and `YOUR_PASSWORD` with the credentials of my home Wi-Fi network.

- I configured the ESP32-S3 to act as both a client to connect to my existing Wi-Fi and as an access point called ESP32_S3_Repeater with a password of 12345678.


Step 5: Uploading the Code and Testing


With the code ready, I clicked the Upload button in the Arduino IDE. After a few moments, the ESP32-S3 began to run the program. I opened the Serial Monitor (set to 115200 baud) to see the status of the connection.


The output showed that the ESP32-S3 successfully connected to my Wi-Fi network, and the access point was up and running. Here’s what I did to test it:


1. I checked the ESP32_S3_Repeater network on my phone and connected to it using the password 12345678.

2. Once connected, I browsed the internet and tested a few IoT devices like a smart light and a temperature sensor that were out of range before. They connected to the ESP32-S3 repeater without a hitch, and the signal strength was noticeably better.


Step 6: Optimizing the Wi-Fi Repeater for Better Performance


After getting the basic setup working, I wanted to optimize my ESP32-S3 repeater for the best performance:


- Positioning: I placed the ESP32-S3 in a spot where it had a strong signal from my main router. This way, it could effectively extend the coverage without losing too much speed.

- Channel Adjustment: I modified the channel in the code to avoid interference with nearby Wi-Fi networks. Choosing a less crowded channel made a noticeable difference in stability.

- Power Supply: I used a 5V/2A USB adapter to ensure that the ESP32-S3 received enough power, especially since it was running continuously.


Troubleshooting Along the Way


As with any DIY project, I hit a few bumps in the road. Here are some common issues I encountered and how I fixed them:


- ESP32-S3 Not Connecting to Wi-Fi: At first, I couldn’t get the ESP32-S3 to connect to my Wi-Fi. It turned out that my router was set to WPA3 encryption, which isn’t always supported by the ESP32-S3. Switching the router to WPA2 solved this.

- Low Signal Strength: I found that placing the ESP32-S3 closer to the router significantly improved signal quality. Walls and metal objects can interfere, so positioning is key.

- Device Fails to Connect to Repeater: If my devices didn’t connect to the repeater, a quick restart of the ESP32-S3 usually did the trick. It’s important to ensure the repeater is running smoothly.


The Results: A Stable and Extended IoT Network


After setting up and tweaking my ESP32-S3 Wi-Fi repeater, I was impressed by how much better my IoT devices performed. The ESP32-S3 effectively extended the range of my home network, ensuring that my smart devices stayed connected even in areas with weaker signals.


This project was a fun and practical way to use the ESP32-S3’s capabilities, and it saved me from having to invest in additional networking equipment. Plus, it gave me the flexibility to adjust the setup as my needs change.


Conclusion: Empowering My IoT Projects with DIY Solutions


Turning an ESP32-S3 into a Wi-Fi repeater is a great way to improve connectivity for your IoT devices without breaking the bank. Whether you're a fellow tinkerer like me or just looking for a simple solution to extend your Wi-Fi range, this project is a rewarding way to make the most of your ESP32-S3.


I hope this guide helps you boost your own IoT network and sparks your next DIY project. Happy building!