IoT Hydroponics - Using Adafruit IO for EC, PH and Temperature Logging

Published

Introduction: IoT Hydroponics - Using Adafruit IO for EC, PH and Temperature Logging

About: Add the ability to measure pH, ORP, EC or salinity to your Arduino or Raspberry Pi project.

This instructable will show how to monitor EC, pH, and temperature of a hydroponics setup and upload the data to Adafruit's IO service.


Adafruit IO is free to get started with. There are paid plans, but the free plan is more than enough for this project.

Step 1: Things You'll Need

Step 2: 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:
    1. From in the Arduino IDE, goto Sketch / Include Library / Manage Libraries... and search for and install 'EC_Salinity'.
    2. Search for and install 'ISE Probe Interface'.
    3. Search for and install 'Adafruit MQTT Library'.
    4. Search for and install 'ArduinoHttpClient'.
    5. And finally search for an install 'Adafruit IO Arduino'.

Step 3: 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 mains 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 EC, pH 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);
EC_Salinity mS(19, 23);

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 EC uFire device's 3.3/5v pin, GND to GND, 19 to SDA, and 23 to SCL. Now connect the uFire pH board to the EC board, pin for pin. The pinout on your ESP32 may be different from the picture.

Step 4: Make an Adafruit Account

You'll need to make account on io.adafruit.com. Follow the link to 'Get Started for Free'.

Once that is finished, head back to io.adafruit.com and you should be looking at your empty Dashboards list. On the left you'll see a menu item called 'View AIO Key', click it and a dialog will open. You will see a textbox labeled 'Username' and 'Active Key'. You'll need both of those for the next step.

Step 5: The Sketch

The sketch for this is the absolute minimum to get our data and upload it. There are a lot of things to improve on this, power management, over-the-air configuration, sensor calibration... lots of things, but this is just a demonstration and a starting point, so we will keep it simple.

Upload this into the Arduino IDE, make sure you choose the right board from the Tools menu. ESP32 Dev Module will more than likely work. Some boards will work at higher baud rates, but nearly all of them will work at 115,200. Change the line AdafruitIO_WiFi io to your specific information. The 'Username' and 'Active Key' is the Adafruit information you just found, WiFi SSID is the name of your WiFi network, and WiFi password is the password for that network.

#include "AdafruitIO_WiFi.h"<br>#include "ISE_pH.h"
#include "ECSalinity.h"

ISE_pH pH(19, 23);
EC_Salinity mS(19, 23);

AdafruitIO_WiFi  io("Username", "Active Key", "WiFi SSID", "Wifi password");
AdafruitIO_Feed *ph   = io.feed("pH");
AdafruitIO_Feed *temp = io.feed("C");
AdafruitIO_Feed *ec   = io.feed("mS");

void setup() {
  io.connect();
  mS.setK(1.0);
}

void loop() {
  io.run();

  ph->save(pH.measurepH());
  delay(3000);
  temp->save(pH.measureTemp());
  delay(3000);
  ec->save(mS.measureEC());
  delay(3000);
}

Step 6: The Adafruit Dashboard

If everything has gone smoothly, you've connected everything, uploaded the sketch, and made an account, you should be able to watch the data coming in.

Go to io.adafruit.com again and select the 'Feeds' menu item on the left. This is a sort of log of all of your datastreams. You should see all three pieces of data updating, one every three seconds.

Now you can turn that data into a Dashboard. I'll leave the specifics of that to you, the Adafruit website should have all the information you need.

Share

    Recommendations

    • Clocks Contest

      Clocks Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Oil Contest

      Oil Contest

    Discussions