Problem
First the problem: I must refill a 1,5Km far water tank, so I need two devices:
- a server that manages a pump: if the remote tank isn’t full the server start the pump with a relay and when the tank is full, stop the pump.
- Start-stop pump;
- Manage the remote message;
- Prevent dangerous action if the remote device is no more active;
- Monitor to select an operation mode and status.
- A client that is in a remote position (tank position) checks the water level and warns the Server if It’s all ok or the tank is full.
- Check the max and min level;
- Warn Server about status;
- Battery and solar-powered;
- Sleep mode if no more need.
A simple demo
Here is a simple demo video.
Devices
Microcontroller
As usual, I’m going to use a WeMos D1 mini because is small and powerful, and I’d like to use WiFi (in the next release) to manage the configuration, more information on this tutorial. “ESP8266 tutorial (WeMos D1)“.
You can find the WeMos D1 on WeMos D1 mini - NodeMCU V2 V2.1 V3 - esp01 - esp01 programmer
Communication
For communication, I’m going to use 2 Ebyte e32 devices; check the devices in this tutorial, “LoRa e32 devices“.
You can find the LoRa devices on AliExpress (433MHz 5Km) - AliExpress (433MHz 8Km) - AliExpress (433MHz 16Km) - AliExpress (868MHz 915MHz 5.5Km) - AliExpress (868MHz 915MHz 8Km)
Display
I love i2c devices, and in this project, I’m going to use an SDD1306, more information in this tutorial “OLED SDD1306“.
You can find here AliExpress I2C SPI SSD1306 0.91 0.96 inch OLED
Power supply
For the Server, I don’t have problems because It’s surely provided energy (to manage the pump), so a simple 5v voltage regulator (7805) for Microcontroller (selectable) and 3.3v (LM1117T-3.3) for all other components.
Pay attention. You can configure the PCB to power the E32 with 3.3v with LM1117 or from WeMos D1 or with 5v from 7805. With 5v, you can reach greater distances, but sometimes M0 and M1 can give problems.
For the client is more complex, because It’s become battery supplied, so I’m going to reuse a simple schema that you can find in this article “Emergency power bank homemade“, and a simple 6v solar panel; I chose to use an LM1117 for 3.3v for better battery management, but It isn’t so important, I’m going to do a variant to use 5v to give better performance.
Buttons
For the controls, I’m going to use pcf8574 with an encoder, more information is in this article “PCF8574 i2c digital I/O expander: Arduino, esp8266 and esp32, rotary encoder“.
You can find pcf8574 on AliExpress
You can find the encoder on AliExpress
Other components
Other simple components like 3.3v relay, electrolytic capacitors, 2n2222a transistor, LEDs, etc.
The relay on AliExpressYou can find the transistor on AliExpress
Start prototyping
To start prototyping, I use a series of shields created for this use, the result seems quite unstable, but It works very well.
All this shield is distributed for free, and you can buy the PCB from the PCB producer, the complete PCB of the Server, and the client. It’s also available.
For the Server I use:
For the client
Software
I use some libraries to manage devices and data.
For the Server I use:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "PCF8574.h"
#include "LoRa_E32.h"
#include <ArduinoJson.h>
The library for the display from Adafruit, my libraries for pcf8574 and LoRa E32, and a library to manage messages in JSON format.
For the client:
#include "LoRa_E32.h"
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
My LoRa E32 device library, the Arduino JSON, and the WiFi library manage sleep mode.
Demonstration video
Thanks
- LoRa remote water tank level and pump controller: intro
- LoRa remote water level and pump controller: server software
- LoRa remote water level and pump controller: client software
- LoRa remote water level and pump controller: server PCB
- LoRa remote water level and pump controller: client PCB
- LoRa remote water level and pump controller: assemble server and 3D printed case
- LoRa remote water level and pump controller: assemble client and 3D printed case