I’m setting up a discus fish tank, and maintaining the right water temperature is critical for their health. That’s what inspired me to build this project.
In this first version, I interfaced a DS18B20 temperature sensor with the nRF7002DK using Zephyr RTOS. The sensor reads the water temperature digitally, and the values are displayed in real time.
The project is still in its initial stage, but my goal is to extend it with BLE notifications, so the tank temperature can be monitored wirelessly from a phone or IoT dashboard.
This guide can also help anyone trying to learn how to interface DS18B20 with Zephyr or thinking of building a similar smart aquarium monitoring system.
Why DS18b20 sensor?The DS18B20 is one of the most popular and reliable digital temperature sensors:
- Accuracy: ±0.5 °C (–10 °C to +85 °C)
- Completely waterproof & submersible, perfect for aquariums
- Works over 1-Wire protocol (only one data pin needed)
- Multiple sensors can be connected on the same bus
- Widely available and low cost
It’s an excellent choice for DIY projects like aquariums, terrariums, and general environmental monitoring.
Project Goals & Possible Extensions✅ Read DS18b20 values on the nRF7002-DK using Zephyr.✅ Provide a clear device tree binding so others can replicate easily.➡️ Future goal: Add BLE notifications to push real-time sensor data to a smartphone app.➡️ Potential extensions:
- Log data to cloud (AWS IoT / Azure / GCP)
- Add multiple sensors (CO2, light, pH for aquariums)
- Build a complete smart tank monitoring system
Wiring DS18b20
- Red wire → 3.3V
- Black wire → GND
- Yellow wire → GPIO pin (with 4.7kΩ pull-up resistor to 3.3V)
prj.conf
CONFIG_LOG=y
#Required to print floating point
CONFIG_CBPRINTF_FP_SUPPORT=y
Note: We will use GPIO to communicate with the DS18B20 sensor via the 1-Wire protocol directly.
devicetree file `boards/nrf7002dk_nrf5340_cpuapp_ns.overlay`
/{
aliases{
ds18b20 = &ds18b20;
};
// Gpio initialization can be done either by leds or buttons
button {
compatible = "gpio-keys";
ds18b20:ds18b20_0 {
gpios = < &gpio1 11 GPIO_ACTIVE_HIGH >;
label = "DS18B20";
};
};
};
Testing and resultsI was able to test the change in temperature the results are as below
This is just the beginning. Next steps include:
- Sending BLE notifications to a mobile app
- Logging temperature data over Wi-Fi to the cloud
- Adding safety triggers (alerts if temperature goes out of range)
This makes it a scalable project that others can adapt for aquariums, terrariums, hydroponics, or any water-based project.
Comments