LevelmetingWaterputV4

Public

@mathiasvan

Download board files

Files for version 1. Pick what you came for.

Share LevelmetingWaterputV4

Check access before sharing the link.

Who can open this board

Anyone can open this board. No sign-in is required.

This link opens the latest version. Copying it does not grant additional access.

Loading 3D model… large boards can take a moment.

README

Levelmeting Waterput V4

Description

This project is V4 in the levelmeting waterput project. It uses the QDY30A level sensor with RS485 protocol because all the previous sensors broke.

This project uses the ModbusMaster library which can be installed from the Library Manager in the Arduino IDE.

Components

Diagram

Thanks lejmr for this diagram. I used it to test my sensor. It is wrong for the TX and RX pins, they should be swapped. (See below for more.) The rest is the same as in this diagram.

My adaptation: I used pin 2 on the ESP32 to connect the DE and RE pins from the MAX485 module.

See the final KiCad diagram under the waterputv4Schematics folder. Here is a screenshot in case you don't have KiCad.

Testing the sensor

This took a lot of trial and error but I got it working in the end. Some important remarks:

  1. R0 from the MAX485 module should be connected to RX on the ESP32 and DI to TX. This is wrong in the original diagram I used.
  2. The provided screw terminals on the MAX485 module are useful to connect the sensor to.
  3. You cannot use the Serial port for debugging as you need the TX and RX pins to communicate with the sensor. I used the Bluetooth Serial library instead. You need to download the Bluetooth Serial app on your phone to connect to the wireless Serial.
  4. When uploading the code, disconnect TX, RX, 5V and GND from the MAX485 and ESP32.
  5. The test code is in the folder testcode.

Final integration

  • I have been using ThingSpeak for all the previous versions and it works quite well to store the data.
  • The Bluetooth Serial library took too much space, so I have switched to the TelnetStream library. You need to install PuTTY and enter the IP adress which can be obtained from the Serial monitor. After this, it connects to the modbus sensor and from that moment on, all logging will happen with the telnet stream on PuTTY.
  • You need to add a credentials.h file in the same folder as the final code. You need to fill this template with your own credentials.
#define mySSID "xxxxx"
#define myPASSWORD "xxxxx"
#define myChannelNumber 111111
#define myWriteAPIKey "xxxxxx"

Telnet Commands

After connecting to your ESP32 using PuTTY (see IP address in Serial Monitor), you can use the following commands in the telnet console:

  • ping
    The ESP32 will respond with pong, show the current sensor height, and display the time remaining until the next automatic data upload to ThingSpeak.

  • send data
    Immediately triggers a sensor reading and uploads the value to ThingSpeak, regardless of the regular upload interval.

Example session:

> ping
pong
Doing a height reading...
Data at adress 4: 158
Converted height: 15.8cm
15.80
Time to next data send: 122 seconds

> send data
Sending data now...
Data at adress 4: 158
Converted height: 15.8cm
Height: 15.8cm
Uploading data to ThingSpeak...
Successful upload to ThingSpeak.
Height: 15.80 uploaded to ThingSpeak server.

If you enter an unknown command, nothing will happen. Commands are case-sensitive.

Tip:
Make sure you have connected to the correct IP address and that your ESP32 is powered and connected to WiFi.

Wishlist

  • Add reconnect wifi command.
  • OTA updates

Resources

Comments

No comments yet. Be the first to ask about this board.

Ask about this board

Sign in to BoardRepo

New here? Signing in creates your account; there is no separate sign-up.