Good day, nod
I am trying to add TDS and PH based sensors to hassio, i tried the analogue sensor but not much accurate and i am using the ESP32 node mcu 32s and ph analog sensor.
Re: Hydropronic Farming: Water TDS, PH level hassio
Posted: Sun Dec 20, 2020 6:29 pm
by Baylos
Hey Barcardi,
I would assume the resolution of the ADC from the ESP32 is not high enough. You can give a separate ADC a try. I use ads1115 and it works with DFrobot SEN0169 and ESP32. Also, I have a temperature sensor on it too, it is important for calculating the correct ph.
Greetings
B
Re: Hydropronic Farming: Water TDS, PH level hassio
I would assume the resolution of the ADC from the ESP32 is not high enough. You can give a separate ADC a try. I use ads1115 and it works with DFrobot SEN0169 and ESP32. Also, I have a temperature sensor on it too, it is important for calculating the correct ph.
Greetings
B
Could you please share the wiring and code used in esphome
Re: Hydropronic Farming: Water TDS, PH level hassio
Thank you for the links and I never knew tasmota supported this feature, could you please help me with the wiring on a esp82 or esp32.
1) Also how do i calibrate the probe ?
2) Do i need to purchase just the Atlas Scientific EZO-pH Embedded pH Circuit or along with the carrier board.
Apologies, noob here
Re: Hydropronic Farming: Water TDS, PH level hassio
Posted: Sun Jan 03, 2021 6:03 pm
by stud
hello its not hard to plug the sensor , i'm also a learning noob , i'm using the i2c protocol .so you have to make sure the sensor is on i2c mode ,not uart .
the original tasmota.bin does not have EZO sensors enabled by default due to binary size limitations , you have to recompile tasmota and uncomment the EZO sensors in myuserconfig.h .
this was my fisrt time compiling a bin file ,thanks to DigiBlur's video tutorial, worked on the first try for me using Gitpod.io :
no need for schematic , its very simple to plug i2c devices , just plug SDA and SCL of sensor to the SDA and SCL of microcontroller .(make sure the sensor is on I2C mode)
i'm on a Wemos Mini D1 and the sensor is powered by 5 volts from Wemos ,also works on 3.3v .
to calibrate you can chk this post ,i can now calibrate from Tasmota or Home Assustant thx to @LEDG
you can follow this post : viewtopic.php?f=35&t=6068
i did buy the carrier isolated board ,i have the older version 1 . when i buy the EZOEC i guess i will get the v2 .
good luck
PS.: i attached my compiled tasmota bin , i only enabled EZO-PH on it to test and works amazing . i just ordered a EZO-EC , i will have to recompile again to enable EZO-EC .
Re: Hydropronic Farming: Water TDS, PH level hassio
hello its not hard to plug the sensor , i'm also a learning noob , i'm using the i2c protocol .so you have to make sure the sensor is on i2c mode ,not uart .
the original tasmota.bin does not have EZO sensors enabled by default due to binary size limitations , you have to recompile tasmota and uncomment the EZO sensors in myuserconfig.h .
this was my fisrt time compiling a bin file ,thanks to DigiBlur's video tutorial, worked on the first try for me using Gitpod.io :
no need for schematic , its very simple to plug i2c devices , just plug SDA and SCL of sensor to the SDA and SCL of microcontroller .(make sure the sensor is on I2C mode)
i'm on a Wemos Mini D1 and the sensor is powered by 5 volts from Wemos ,also works on 3.3v .
to calibrate you can chk this post ,i can now calibrate from Tasmota or Home Assustant thx to @LEDG
you can follow this post : viewtopic.php?f=35&t=6068
i did buy the carrier isolated board ,i have the older version 1 . when i buy the EZOEC i guess i will get the v2 .
good luck
PS.: i attached my compiled tasmota bin , i only enabled EZO-PH on it to test and works amazing . i just ordered a EZO-EC , i will have to recompile again to enable EZO-EC .
Wow i am trying this, any tips/ mandatory options on the tasmota configuration side ?
Re: Hydropronic Farming: Water TDS, PH level hassio
I had ordered DFR0504, which is an isolator interface. Once my EC probe will arrive I can upgrade the ESP32 with an isolator interface for ph and EC.
I do ph calibration once a month.
BR
Thank you Baylos , this is cost effective and was going through your profile and comments. Did you manage to get this integrated to hassio ?
Re: Hydropronic Farming: Water TDS, PH level hassio
Posted: Mon Jan 04, 2021 5:21 pm
by Baylos
Hi,
my current code is below. They're still a working area in it! Especially the code in the field void onConnectionEstablished.
I faced later that Arduino saves the code every time I compile it, that why there some changes from last time to it. What I like to do later on is to move calibration (this is by serial at the moment) to MQTT. EspMQTTClient was used because I had in the past connecting issue with PubSubClient.
The probe SEN0169 is connected with ADS1115 at PIN A1.
The Temperature Sensor is connected to PIN15 of the ESP32.
You can find the core code and library at GitHub under Greenponik. They are the writer of the core code and library.
#include "EspMQTTClient.h"
#include <Arduino.h>
#include "DFRobot_ESP_PH_WITH_ADC.h"
#include "OneWire.h"
#include "DallasTemperature.h"
#include "Adafruit_ADS1015.h"
#include "EEPROM.h"
DFRobot_ESP_PH_WITH_ADC ph;
Adafruit_ADS1115 ads;
#define ONE_WIRE_BUS 15
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
EspMQTTClient client(
"MY-Network",
"The Network Password",
"xxx.xxx.x.xxx", // MQTT Broker server ip
"MQTTClientName", // Can be omitted if not needed
"MQTTpassword", // Can be omitted if not needed
"Client Name", // Client name that uniquely identify your device
1883 // The MQTT port, default to 1883. this line can be omitted
);
void setup()
{
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();
// Optionnal functionnalities of EspMQTTClient :
client.enableDebuggingMessages(); // Enable debugging messages sent to serial output
client.enableHTTPWebUpdater(); // Enable the web updater. User and password default to values of MQTTUsername and MQTTPassword. These can be overrited with enableHTTPWebUpdater("user", "password").
client.enableLastWillMessage("TestClient/lastwill", "I am going offline"); // You can activate the retain flag by setting the third parameter to true
}
// This function is called once everything is connected (Wifi and MQTT)
// WARNING: YOU MUST IMPLEMENT IT IF YOU USE EspMQTTClient
void onConnectionEstablished()
{
// Subscribe to "mytopic/test" and display received message to Serial
client.subscribe("mytopic/test", [](const String & payload) {
Serial.println(payload);
});
// Subscribe to "mytopic/wildcardtest/#" and display received message to Serial
client.subscribe("mytopic/wildcardtest/#", [](const String & topic, const String & payload) {
Serial.println("(From wildcard) topic: " + topic + ", payload: " + payload);
});
// Publish a message to "mytopic/test"
client.publish("mytopic/test", "This is a message"); // You can activate the retain flag by setting the third parameter to true
// Execute delayed instructions
client.executeDelayed(5 * 1000, []() {
client.publish("mytopic/wildcardtest/test123", "This is a message sent 5 seconds later");
});
}
float voltage, phValue, temperature = 25;
float readTemperature()
{
//add your code here to get the temperature from your temperature sensor
sensors.requestTemperatures();
return sensors.getTempCByIndex(0);
}
void loop()
{
static unsigned long timepoint = millis();
if (millis() - timepoint > 5000U) //time interval: 5s
{
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(1) / 10; // read the voltage
Serial.print("voltage:");
Serial.println(voltage, 4);
temperature = readTemperature(); // read your temperature sensor to execute temperature compensation
Serial.print("temperature:");
Serial.print(temperature, 1);
Serial.println("^C");
phValue = ph.readPH(voltage, temperature); // convert voltage to pH with temperature compensation
Serial.print("pH:");
Serial.println(phValue, 4);
char phwert[8];
dtostrf(phValue, 1, 2, phwert);
char volt[8];
dtostrf(voltage, 1, 2, volt);
char temp[8];
dtostrf(temperature, 1, 2, temp);
client.publish("mytopic/volt", volt); // You can activate the retain flag by setting the third parameter to true
client.publish("mytopic/ph", phwert); // You can activate the retain flag by setting the third parameter to true
client.publish("mytopic/temp", temp); // You can activate the retain flag by setting the third parameter to true
}
ph.calibration(voltage, temperature); // calibration process by Serail CMD
client.loop();
}