Smart Boat 13: Engine Temp Monitor using ESP32 and DS18B20

3 min read 2 hours ago
Published on Oct 10, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

In this tutorial, you'll learn how to set up an advanced engine temperature monitoring system for your boat using the ESP32 microprocessor and DS18B20 one-wire temperature sensors. This system can withstand extreme temperatures up to 125°C and is designed to help you monitor critical areas of your engine, providing alerts for any abnormal temperature changes. Properly monitoring engine temperature can prevent serious issues, ensuring your boating experience is safe and enjoyable.

Step 1: Gather Your Materials

Before diving into the setup, ensure you have the following components:

  • ESP32 microprocessor (38 pins or 30 pins)
  • DS18B20 temperature sensors
  • 4.7K ohm resistors for each sensor
  • Dupont breakout cables
  • 12V to 5V converter
  • INA219 module for monitoring current
  • Junction box (80mm x 80mm) for housing components

You can find these components on platforms like Amazon or AliExpress through the provided links.

Step 2: Understand the Sensor Locations

Strategically placing your temperature sensors is crucial for effective monitoring:

  1. Near the Coolant: Monitor coolant temperature to prevent overheating.
  2. Thermostat Area: Track the temperature right before it enters the engine block.
  3. Raw Water Elbow: Measure the temperature to ensure proper water flow.
  4. Alternator: Monitor for potential overheating, especially when using lithium batteries.

Step 3: Connect the DS18B20 Sensors

Follow these steps to wire the DS18B20 sensors:

  1. Connect the VCC pin of each sensor to the 5V output of the ESP32.
  2. Connect the GND pin to the ground of the ESP32.
  3. Connect the data pin of each sensor to a designated GPIO pin on the ESP32.
  4. Place a 4.7K ohm resistor between the VCC and data pin of each sensor.

Step 4: Program the ESP32

You will need to write a program to read the temperatures from the DS18B20 sensors. Here’s a basic outline of the code:

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 4 // Replace with your GPIO pin

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);
  sensors.begin();
}

void loop() {
  sensors.requestTemperatures();
  Serial.print("Temperature for sensor 1 is: ");
  Serial.println(sensors.getTempCByIndex(0)); // Adjust index for multiple sensors
  delay(1000);
}

Step 5: Set Up Alerts for Abnormal Temperatures

To prevent engine issues, configure alerts in your code. You can use conditional statements to trigger notifications:

if (sensors.getTempCByIndex(0) > 100) { // Set your critical temperature
  Serial.println("Warning: High temperature detected!");
  // Add notification code here (e.g., send email, push notification)
}

Step 6: Integrate with Home Assistant

To visualize and manage your temperature readings:

  1. Install Home Assistant on your server or Raspberry Pi.
  2. Use the ESPHome integration to connect your ESP32.
  3. Define the temperature sensors in your ESPHome configuration.

Step 7: Create a Dashboard

Using Home Assistant, create a dashboard to display real-time temperature readings:

  1. Navigate to the dashboard settings.
  2. Add a gauge for each temperature sensor.
  3. Customize the appearance and thresholds for alerts.

Step 8: Set Up Automation

Implement automation to handle alerts:

  1. Go to the automation section in Home Assistant.
  2. Create a new automation that triggers when a temperature exceeds your threshold.
  3. Choose actions such as sending notifications or turning off the engine.

Conclusion

You've now set up a comprehensive engine temperature monitoring system using the ESP32 and DS18B20 sensors. By strategically placing sensors and configuring alerts, you can prevent potential engine failures. Consider expanding your setup by adding more sensors or integrating additional features. Happy boating!