IoT Pool Monitoring With ThingsBoard

by ufire in Circuits > Arduino

5409 Views, 14 Favorites, 0 Comments

IoT Pool Monitoring With ThingsBoard

IMG_20180707_105837.jpg

This instructable will show how to monitor pH, ORP, and temperature of a pool or spa and upload the data to ThingsBoard.io's visualization and storage service.

Things You'll Need

The Software

  1. I will assume you are familiar with Arduino, the Arduino IDE, and have it installed already. If not, follow the links.
  2. Next thing is getting the ESP32 platform installed. For some reason, this hasn't been simplified by the available platform management features the IDE has to offer, so you'll need to go to the github page and follow the appropriate installation instructions.
  3. Now for the libraries: From in the Arduino IDE, goto Sketch / Include Library / Manage Libraries...
    1. Search for and install 'ArduinoJson' version 5.13.2.
    2. Search for and install 'PubSubClient'.
    3. Search for and install 'Isolated ISE Probe Interface'.

Configure UFire Devices

Because the uFire devices communicate through I2C, they need unique addresses. The ISE probe we are using to measure pH and ORP are the same, so by default they come with the same address. The address can be changed though, and that is what we will do now.

From the Arduino IDE, go to 'Files / Example / ISE Probe Interface' and select 'Shell'. This is a convenient to use shell-like interface for using and configuring uFire devices. It works best on a simple ATMega device like an Uno, Mini, or Nano. It currently crashes on an ESP32. Upload the sketch to your device, make sure one of the uFire devices is connected and run the following command.

i2c 3e

That should have changed the I2C address of the device permanently to hex 0x3E. Now you can address both devices with a unique address.

Making Connections

The ESP32 we are using has WiFi and BLE interfaces, so that just needs a
power supply. You'll probably want a USB cable supplying power, but a battery is another option. Many ESP32s can be bought with battery charging circuitry already on the board.

The uFire devices that we will be measuring pH, ORP, and temperature connect to the ESP32 by the I2C bus. With the ESP32, you can choose any two pins for I2C. Both devices will be on the same bus, so the SCL and SDA pins will be the same. If you look at the code (next step), you will see these two lines.

ISE_pH  pH(19, 23);
ISE_ORP ORP(19, 23, 0x3E);

I decided to use pin 19 for SDA and pin 23 for SCL. So Connect the ESP32's 3.3v (or whatever the pin may be called on your particular board) to the first uFire device's 3.3/5v pin, GND to GND, 19 to SDA, and 23 to SCL.

The pinout on your ESP32 may be different from the picture.

Get ThingsBoard Running

ThingsBoard is an online service, that among other things, receives sensor input and visualizes them in the form of charts and graphs. There are several installation options. For this instructable, it will be using a local installation running on a dedicated computer.

Visit ThingsBoard.io's installation instructions and choose the install the appropriate selection for you.

I installed the Docker image which allowed me to access the installation by going to http://localhost:8080/.

As described here, the default login username and password is tenant@thingsboard.org and tenant.

Setup a Device

  1. Once you login to ThingsBoard, click 'Devices'.
  2. On the next page, you'll see an orange '+' on the bottom right, click it and the 'Add Device' dialog will appear. Fill in the 'Name' field with whatever you'd like to call our device. Then under 'Device Type', enter 'ESP32', although it could be anything. Click 'Add'.
  3. Click the newly created device's entry in the list and you'll see quite a bit of information about it. Leave this screen open and go to the next step.

Sketch

You can take a look at the source here.

  1. Copy the files into an Arduino project.
  2. Edit Watson.h.
    1. Change ssid and password to your WiFi network information.
    2. From the previous step's open screen, click 'COPY DEVICE ID' and change the 'char device[]' variable to the copied values. Do the same for 'COPY ACCESS TOKEN' to the 'char token[]' variable.
    3. Finally, change the 'char server[]' variable to the IP address of the computer running ThingsBoard. Mine was '192.168.2.126'. No 'http', slashes, or anything else, just the IP address.
  3. Upload it to your ESP32 and take a look at the 'LATEST TELEMETRY' tab. It should show you your data coming in.

Setup a Dashboard

tb_telemetry.png

From within the 'LATEST TELEMETRY' tab, you should see our three data points, C, mV, and pH. If you click the checkbox on the left of each item, you can then click 'SHOW ON WIDGET'. You'll be presented with a lot of charting options. Pick the one you like, then click 'ADD TO DASHBOARD'.

ThingsBoard provides lots of options from this point on so I'll leave that up to you to explore.