Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

IoT liquid (oil) level monitoring system

By EG Projects

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:


  • 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

  • How to use IoT-based D2D automation

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

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.

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!


Featured Tutorials

  • Designing Gate Driver Circuit and Switching Mechanism for Modified Sine Wave Inverter – (Part 9/17)
  • Completing Modified Sine Wave Inverter Design with Full Bridge Circuit and Step Up Transformer – (Part 10/17)
  • Designing an Offline UPS – Part (12 /17)
  • How to reduce Switching Time of a Relay – (Part 15/17)
  • Testing MOSFET – (Part 16/17)
  • Driving High Side MOSFET using Bootstrap Circuitry – (Part 17/17)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Designing Gate Driver Circuit and Switching Mechanism for Modified Sine Wave Inverter – (Part 9/17)
  • Completing Modified Sine Wave Inverter Design with Full Bridge Circuit and Step Up Transformer – (Part 10/17)
  • Designing an Offline UPS – Part (12 /17)
  • How to reduce Switching Time of a Relay – (Part 15/17)
  • Testing MOSFET – (Part 16/17)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd ldr led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics Research robot samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Please help to identify the signal input port on board
  • Hotplugging UART
  • RF switch selection
  • sensitivity in filters and number of bits of system
  • MDO4104-6 Front Panel Not Working

RSS Electro-Tech-Online.com Discussions

  • software PWM
  • Combination of Wires of two DC motor giving Output current.
  • Passthrough charging-simple but impossible to achieve?
  • geared motor to revolve oval platform
  • None existant errors (MPLAB X)
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 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 | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering