Dear guys I am new to programming please help me to write a code for esp32 with a Nextion display for reading the value from ph sensor

/*

  • file DFRobot_ESP_PH_BY_GREENPONIK.ino
  • @ GitHub - GreenPonik/DFRobot_ESP_PH_BY_GREENPONIK: Read PH on ESP32 by using Gravity: Analog pH Sensor / Meter Kit V2, SKU:SEN0161-V2
  • This is the sample code for Gravity: Analog pH Sensor / Meter Kit V2, SKU:SEN0161-V2
  • In order to guarantee precision, a temperature sensor such as DS18B20 is needed, to execute automatic temperature compensation.
  • You can send commands in the serial monitor to execute the calibration.
  • Serial Commands:
  • enterph -> enter the calibration mode
  • calph -> calibrate with the standard buffer solution, two buffer solutions(4.0 and 7.0) will be automaticlly recognized
  • exitph -> save the calibrated parameters and exit from calibration mode
  • Based on the @ GitHub - DFRobot/DFRobot_PH: Arduino library for Gravity: Analog pH Sensor / Meter Kit V2, SKU: SEN0161-V2
  • Copyright DFRobot, 2018
  • Copyright GNU Lesser General Public License
  • ##################################################
  • ##################################################
  • ########## Fork on github by GreenPonik ##########
  • ############# ONLY ESP COMPATIBLE ################
  • ##################################################
  • ##################################################
  • version V1.1
  • date 2019-06
    */

#include "DFRobot_ESP_PH.h"
#include "EEPROM.h"

DFRobot_ESP_PH ph;
#define ESPADC 4096.0 //the esp Analog Digital Convertion value
#define ESPVOLTAGE 3300 //the esp voltage supply value
#define PH_PIN 35 //the esp gpio data pin number
float voltage, phValue, temperature = 25;

void setup()
{
Serial.begin(115200);
EEPROM.begin(32);//needed to permit storage of calibration value in eeprom
ph.begin();
}

void loop()
{
static unsigned long timepoint = millis();
if (millis() - timepoint > 1000U) //time interval: 1s
{
timepoint = millis();
//voltage = rawPinValue / esp32ADC * esp32Vin
voltage = analogRead(PH_PIN) / ESPADC * ESPVOLTAGE; // 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);
}
ph.calibration(voltage, temperature); // calibration process by Serail CMD

}

float readTemperature()
{
//add your code here to get the temperature from your temperature sensor
}

so Guys attached is the ph sensor reading code try to help me to combine how can i use it with Nextion and teach how you did this thank you

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

2 Likes

Have you read the docs?

How is your sketch working as you posted? Have you verified the ESP, ph sensor and temperature sensor are working? The following portion of your sketch looks like you commented-out a call to an empty function... so the temperature will probably not move from 25 with or without that call.

(and if you would, please, format your sketch in post #1 by editing the post and clicking the < CODE > button and cut/paste your code where you see '''copy or paste code here''')

1 Like

Bro my concern is to i need to monitor the value of ph sensor in nextion display for that i am looking a code the thing is that i am new to this field and regarding the temprature dosent matter for me now just i wnated to show the real value in the nextion display

You might drop your request for coding here:

Have you made the real value show on the serial monitor?

which one bro

for the ph sensor i have code
but for the nextion i dont have the code

The one you wrote about.

Are you using an Arduino Nano ESP32 or some other ESP32 based board?

Ya BRO That programs works but i need to use with nextion

Esp32

The Nano ESP32 section is specific for the Arduino Nano ESP32; hence topic moved.

what bro?

No, it does not return temperature, and you need that to send to "ph" object.

Have you set up your GUI with the Nextion editor?

yes bro i ave setup
image

You probably did not read what you copy/pasted here... why do you not want to do any of the work?

what you mean bro I didnt understand

bro the thing is that now i am not using the sensor at the moment just only wante to show the value in the nextion
so how i can show that is my concern