This tutorial will show how to make a Bluetooth Low Energy Internet of Things device to monitor the Electrical Conductivity of a hydroponic nutrient solution.
The hardware will be any ESP32 development board and an uFire Isolated EC Probe Interface.
We will display our data on a simple webpage that connects to our device through Web Bluetooth.
Step 1: Things You'll Need- Any ESP32 development board. This one seems reasonable, but any will work.
- A uFire Isolated EC Probe Interface board and a K1 conductivity probe. You can get them both at ufire.co
- Some odds and ends like wires and USB cables.
Now for the libraries:
- From in the Arduino IDE, goto Sketch / Include Library / Manage Libraries... and search for and install 'Isolated EC Probe Interface'.
- Search for and install 'ESP32 BLE Arduino'
- I will assume you are familiar with Arduino, the Arduino IDE, and have it installed already. If not, follow the links.
- 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.
The sketch for this project is quick and easy.
You can find it on the github page. It will also be in the BLE example under File / Examples / Isolated EC Probe Interface. And for good measure, it's attached to this tutorial as well.
#include "uFire_EC_BLE.h"<br>
// On the ESP32, the I2C pins can be chosen. In this case, sda=19 and scl=23
uFire_EC_BLE ec_ble(19, 23);
void setup() {
// start the BLE server
ec_ble.startBLE();
}
void loop() {
// loop through and take continous measurements
ec_ble.measureEC();
ec_ble.measureTemp();
}
Step 4: Displaying Our DataNow that the hardware is setup, we need a convenient way to display our data. For that, we will make a simple webpage that uses Web Bluetooth. If you aren't familiar with it, it's a Javascript API that is currently only available on Chrome. It allows you to connect to a BLE device from a webpage.
Have a look at the github repo.
As a quick overview:
- it uses bulma.io for styling
- Vue for front-end framework
- app.js contains all the javascript code
- index.html contains all the html
Some things to keep in mind, if you want to develop your own webpage:
- it needs to be served from an https server, you can't access it from a local file (file://).
- Only Chrome version 55+ works for this particular implementation and newer versions of Opera. You could write an app or program using the more traditional BLE APIs.
- Make sure Experimental Web Platform features is Enabled by going to chrome://flags/#enable-experimental-web-platform-features and restarting the browser. On newer versions of Chrome, this is enabled by default.
Now that everything is put together, programmed, and the website is being served, we can look at the end result.
Open the website, in our case, it lives at https://ufire.co/uFire_BLE/, click the Bluetooth icon in the upper right and choose the uFire EC device. Now you should be seeing the EC reading in mS and the temperature in C.
You can also set some calibration options.
Comments