Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

IoT liquid (oil) level monitoring system

By EG Projects November 7, 2021

In this article, we will make a device that will monitor liquid levels in water/oil or any tank. The monitored level information will be sent to a monitoring station. This can be helpful to monitor some water tanks installed at a place where humans cannot frequently reach and at places that are toxic, like labs where liquid chemicals are stored in large containers. 

link: https://www.sparkfun.com/products/242

Components required

Tools Required/ libraries required
Arduino IDE
Arduino Library – Wi-Fi manager

Technical Insights
We will be using an IR distance measuring sensor to measure the level of liquid-filled in containers or tanks. The sensor’s output is measured in a unit and stored in a microcontroller; in this case, Arduino UNO. The sensor data is then sent using ESP to the thingspeak server for monitoring. 

Block Diagram

Figure 1 Liquid level monitoring system

IR sensor is connected to Arduino Uno and sending sensor data to it. The ESP is connected to the Arduino and Wi-Fi router, with a ThingSpeak library for communication purposes.

Circuit Diagram

Figure 2 Atmega 328 board with ESP

How the system works

  • When powered on for the first time, the ESP generates a hotspot named “OilTank -1” displayed on an OLED display.
  • We need to connect to it and open url http://192.168.4.1/ to set up the ESP.
  • Then from the configuration panel, we can set which Wi-Fi ESP will connect to. We just enter the SSID and password of the Wi-Fi.
  • After connecting to Wi-Fi, the name of Wi-Fi is displayed on the OLED screen.
  • A battery also operates the device, so battery percentage is also shown on the screen and the tank’s liquid level.
  • Now after connecting to the internet, the device sends data every 20 Seconds to the thingspeak server.
  • If the Wi-Fi is disconnected, on the screen, you will see that Wi-Fi is disconnected, and ESP will generate a hotspot again.

Understanding the source code
To understand the code, there are two files; one is for ESP, and another is for Arduino.

ESP.ino
We are also using a Wi-Fi library for ESP to easily configure ESP using its hotspot without writing Wi-Fi information in the code. We are connected with thingspeak API when the internet is connected. The code is designed to send anything coming to serial, which is not a command for ESP to the thingspeak API dashboard.

So, let’s take a look at the code.

  • In the setup function we are creating a hotspot using WiFi-Manger library
    wifiManager.autoConnect(“OilTank-1”);
  • If the hotspot is created, ESP was not previously connected to Wi-Fi which is now available. The hotspot is a blocking loop for the program, so we send a “setup” command before creating a hotspot. That means the setup information will be displayed on the screen.
  • If the hotspot is OFF the, we send the “conn” command, which means the ESP is connected to Wi-Fi, and the program follows.
    Serial.print(“conn”);
  • ESP is also listening for some commands on which it replies to Arduino

  • If none of those commands are recognized, then this data will be the tank level data which will be sent using the thingspeak library
    ThingSpeak.writeField(myChannelNumber, 1, recivedData, myWriteAPIKey);

Arduino.ino
Arduino is installed with an OLED library to display the OLED data; it also communicates with ESP on serial communication.
Arduino code is also taking analog values from the sensor on analog pin A2 and calculates voltages. From there, we can map that to tank level.

The function tank_data() takes reading on analog pin 2 and then calculates the voltage reading and then send that to ESP in a period of 20 seconds.
val = analogRead(A2);
voltage = ((val * 3.3000) / 1024.0);

There are a few commands for OLED, which Arduino is receiving from ESP at serial.

This is how we can make a Liquid level monitoring system.

Board.ino source code:

ES.ino source code:

Video demo:

https://www.engineersgarage.com/wp-content/uploads/2021/11/Demo.mp4

You may also like:


  • How to use IoT-based D2D automation

  • IoT-based, pre-paid electricity system

  • IoT-based smart remote classrooms

  • IoT-based patient health register

  • IoT-based water geyser

  • An IoT-based virtual doctor

Filed Under: Applications, Electronic Projects, Featured, IoT applications
Tagged With: Arduino, Atmega, ESP, IoT, oled, ThinkSpeak, Wi-Fi
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • High Side current sensing
  • The comparison of different Tcl script checkers
  • Voltage mode pushpull is a nonsense SMPS?
  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • How to simulate power electronics converter in PSpice?

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe