Cheaper alternative to Atlas Scientific?

Home Assistant automation projects, questions, etc. go here.
Baylos
LED-Curious
LED-Curious
Reactions:
Posts: 22
Joined: Sat Nov 07, 2020 11:49 am

Hi,

PH probe works well. I expand the recalibration from 4 weeks to 8 weeks.

In very raw cases the PH value was going crazy (14 pHs). After reset of the ESP, everything was fine again. Just in case I ordered isolating circuit, but not been installed yet.

The key difference is public support. I would guess that with Atlas probes there is more support available. In Europe it was difficult for me to get them, so DFRobot was easier. If you do not want to spend time on your programming I would recommend Atlas.


Greetings
rogueacres
LED-Curious
LED-Curious
Reactions:
Posts: 4
Joined: Mon Feb 07, 2022 1:28 am

When you set this all up. did you ever try adding a custom component or did you configure through esphome at all? Trying to figure out a way to do this all through ESP home
Baylos
LED-Curious
LED-Curious
Reactions:
Posts: 22
Joined: Sat Nov 07, 2020 11:49 am

Hi,

I use Arduino and MQTT. It works fine for me.


BR
rogueacres
LED-Curious
LED-Curious
Reactions:
Posts: 4
Joined: Mon Feb 07, 2022 1:28 am

how do you send the calibration messages to the device from home assistant? An automation to send a message over MQTT?

Also, I spent a chunk of my weekend and have essentially rebuilt the framework into ESPhome. The one part I can't figure out and maybe you can help me is this:

Code: Select all

voltage = ads.readADC_SingleEnded(0) / 10;
can you explain to me where that gets the pin/pins to read the data in from? Once I can figure out that I think i will have it built in ESPhome and shared back. Here is my current code which is "working" but not reading in correct voltages. Also what is the //* Index section about? should i be pointing those to my ADS1115 pins somehow?

Here is my current code:

Code: Select all

#include <Arduino.h>
#include "DFRobot_ESP_PH_WITH_ADC.h"
#include "OneWire.h"
#include "DallasTemperature.h"
#include "Adafruit_ADS1X15.h"
#include "EEPROM.h"
#include "esphome.h"

#define ONE_WIRE_BUS 23
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

float voltage, phValue, temperature = 25;
  
DFRobot_ESP_PH_WITH_ADC ph;

Adafruit_ADS1115 ads;

float readTemperature()
{
	sensors.requestTemperatures();
	return sensors.getTempCByIndex(0);
}

class MyCustomSensor : public PollingComponent {
 public:
  // constructor
  
  Sensor *temp_sensor = new Sensor();
  Sensor *voltage_sensor = new Sensor();
  Sensor *ph_sensor = new Sensor();

  MyCustomSensor() : PollingComponent(15000) {}


  void setup() override {
    Serial.begin(115200);
	EEPROM.begin(32);//needed EEPROM.begin to store calibration k in eeprom
	ph.begin();
	sensors.begin();
	ads.setGain(GAIN_ONE);
	ads.begin();
  }
  void update() override {
    	static unsigned long timepoint = millis();
	if (millis() - timepoint > 1000U) //time interval: 1s
	{
		timepoint = millis();
		/**
		 * index 0 for adc's pin A0
 		 * index 1 for adc's pin A1
		 * index 2 for adc's pin A2
		 * index 3 for adc's pin A3
		*/
		voltage = ads.readADC_SingleEnded(0) / 10; // read the voltage
		voltage_sensor->publish_state(voltage);

		temperature = readTemperature(); // read your temperature sensor to execute temperature compensation
		temp_sensor->publish_state(temperature);

		phValue = ph.readPH(voltage, temperature); // convert voltage to pH with temperature compensation
		ph_sensor->publish_state(phValue);
	}
	ph.calibration(voltage, temperature); // calibration process by Serail CM
  }
};
Then I call that into my ESPhome compile by using these lines in my esphome yaml

Code: Select all

esphome:
  name: tentwater

  libraries:
    - EEPROM
    - ivankravets/OneWire
    - greenponik/DFRobot_ESP_PH_WITH_ADC_BY_GREENPONIK@^1.2.3
    - paulstoffregen/OneWire@^2.3.6
    - milesburton/DallasTemperature@^3.9.1
    - Wire
    - SPI
    - armmbed/mbed-drivers@^1.5.0
    - adafruit/Adafruit BusIO@^1.11.1
    - adafruit/Adafruit ADS1X15@^2.4.0


  includes:
    - Adafruit_I2CDevice.h
    - phmeter.h

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "64e37359881f93b8a33514982f6ac388"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails

captive_portal:

dallas:
  - pin: 23  
    update_interval: 10s
    
i2c:
  sda: GPIO22
  scl: GPIO21
  scan: true
  
ads1115:
  - address: 0x48
  
# Individual sensors
sensor:
  - platform: dallas
    address: 0x5b3c01f096300c28
    filters:
    - lambda: return x * (9.0/5.0) + 32.0;
    unit_of_measurement: "°F"
    name: "Water Temperature"
    id: water_temperature
  - platform: uptime
    name: Tentwater Uptime
    id: tentwater_uptime
  - platform: wifi_signal
    name: "Tentwater Wifi"
    update_interval: 60s

  - platform: ads1115
    multiplexer: 'A1_GND'
    gain: 4.096
    name: "pH Meter"
    accuracy_decimals: 2
    unit_of_measurement: "pH"
    update_interval: 10s
    filters:
    - calibrate_linear:
          - 1.011625 -> 10.0
          - 1.53625 -> 7.0
          - 1.733500 -> 5.8
          - 2.016 -> 4.0

  - platform: custom
    lambda: |-
      auto my_sensor = new MyCustomSensor();
      App.register_component(my_sensor);
      return {my_sensor->temp_sensor, my_sensor->ph_sensor, my_sensor->voltage_sensor};
  
    sensors:
    -  name: "temp Sensor"
       unit_of_measurement: "temp"
       accuracy_decimals: 2
    -  name: "ph Sensor"
       unit_of_measurement: "ph"
       accuracy_decimals: 2
    -  name: "voltage Sensor"
       unit_of_measurement: "voltage"
       accuracy_decimals: 2
       
Shimbob
LED Wizard
LED Wizard
Reactions:
Posts: 642
Joined: Mon Nov 27, 2017 11:29 pm

rogueacres wrote:
Sun Feb 27, 2022 4:32 pm
can you explain to me where that gets the pin/pins to read the data in from? Once I can figure out that I think i will have it built in ESPhome and shared back. Here is my current code which is "working" but not reading in correct voltages. Also what is the //* Index section about? should i be pointing those to my ADS1115 pins somehow?
I use an ADS1115 chip to read the values of my capacitive soil moisture sensors, I noticed you have:

Code: Select all

ads.setGain(GAIN_ONE); 
which means the ADS1115 will read a value +/- 4.096V. Then you have:

Code: Select all

voltage = ads.readADC_SingleEnded(0) / 10;
which takes the voltage and divides by 10, so now you will only get values of +/- 0.4096V.
I don't think you want this division by 10 because your yaml specifies:

Code: Select all

    - calibrate_linear:
          - 1.011625 -> 10.0
          - 1.53625 -> 7.0
          - 1.733500 -> 5.8
          - 2.016 -> 4.0
This suggests you're expecting values of at least 2.016, which you'll never get due to that division by 10.
Baylos
LED-Curious
LED-Curious
Reactions:
Posts: 22
Joined: Sat Nov 07, 2020 11:49 am

Hi,

I calibrate my probe every three months. The deviation that I see is just minimal. So for that, I do it on my PC.

I think the DFRobot ROM needs the serial console for calibration. I was thinking of using Serial <>MQTT but not having the passion for making it happen.

BR
rogueacres
LED-Curious
LED-Curious
Reactions:
Posts: 4
Joined: Mon Feb 07, 2022 1:28 am

Shimbob wrote:
Sun Feb 27, 2022 5:22 pm

I use an ADS1115 chip to read the values of my capacitive soil moisture sensors, I noticed you have:

Code: Select all

ads.setGain(GAIN_ONE); 
which means the ADS1115 will read a value +/- 4.096V. Then you have:

Code: Select all

voltage = ads.readADC_SingleEnded(0) / 10;
which takes the voltage and divides by 10, so now you will only get values of +/- 0.4096V.
I don't think you want this division by 10 because your yaml specifies:

Code: Select all

    - calibrate_linear:
          - 1.011625 -> 10.0
          - 1.53625 -> 7.0
          - 1.733500 -> 5.8
          - 2.016 -> 4.0
This suggests you're expecting values of at least 2.016, which you'll never get due to that division by 10.

that calibrate linear function in the ESP Yaml is for the device as i am using it today (which does not have the calibration feature) I am reading in values fine as it is from that sensor right now.

I am trying to set this up where I can hit one button and then do a two point calibration. I am almost there, and i even think i'm reading in voltage correctly now (not 100% sure)

Here is a snippet from my logs. Something to note: the "pH Meter" is the meter as i am using it today so please ignore those. The "ph sensor" and "voltage snesor" are the readings that I am pulling in using the custom sensor feature with baylos' start.

now, I am trying to figure out how to send the calibration messages over UART and successfully get the esp32 to calibrate the voltage readings and adjust to be correct ranges.

Code: Select all

[08:54:42][D][api.connection:826]: Home Assistant 2022.2.9 (::FFFF:C0A8:170): Connected successfully
[08:54:43][D][ads1115:164]: 'pH Meter': Got Voltage=1.513250V
[08:54:43][D][sensor:125]: 'pH Meter': Sending state 7.06352 pH with 2 decimals of accuracy
[08:54:45][D][sensor:125]: 'voltage Sensor': Sending state 1211.00000 voltage with 2 decimals of accuracy
[08:54:45][D][sensor:125]: 'temp Sensor': Sending state 18.37500 temp with 2 decimals of accuracy
[08:54:45][D][sensor:125]: 'ph Sensor': Sending state 6.40310 ph with 2 decimals of accuracy
[08:54:50][D][dallas.sensor:137]: 'Water Temperature': Got Temperature=18.3°C
[08:54:50][D][sensor:125]: 'Water Temperature': Sending state 64.96250 °F with 1 decimals of accuracy
[08:54:53][D][ads1115:164]: 'pH Meter': Got Voltage=1.514375V
[08:54:53][D][sensor:125]: 'pH Meter': Sending state 7.05682 pH with 2 decimals of accuracy
[08:55:00][D][sensor:125]: 'voltage Sensor': Sending state 1211.00000 voltage with 2 decimals of accuracy
[08:55:00][D][sensor:125]: 'temp Sensor': Sending state 18.31250 temp with 2 decimals of accuracy
[08:55:00][D][sensor:125]: 'ph Sensor': Sending state 6.40310 ph with 2 decimals of accuracy
[08:55:00][D][dallas.sensor:137]: 'Water Temperature': Got Temperature=18.4°C
[08:55:00][D][sensor:125]: 'Water Temperature': Sending state 65.07500 °F with 1 decimals of accuracy
[08:55:03][D][ads1115:164]: 'pH Meter': Got Voltage=1.517625V
[08:55:03][D][sensor:125]: 'pH Meter': Sending state 7.03748 pH with 2 decimals of accuracy
Post Reply