the sketch uploads, but i keep getting "PH: NO_DATA" in the serial monitor.
the ezo board flashes red which indicates "command not understood" according to the manufacturers datasheet. The pH EZO board is connected via I2C. Im using mkr 1010 and atlas scientific ph probe and EZO circuit.
a similar sketch without the generated IOT and wifi code works offline and gives me a reading so i know the hardware is working.
/*
Sketch generated by the Arduino IoT Cloud Thing "pH_Test"
https://create.arduino.cc/cloud/things/6717560a-59d1-488f-8f50-7565b0301cea
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float phIOT;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include <Ezo_i2c.h> // Link: https://github.com/Atlas-Scientific/Ezo_I2c_lib)
#include <Wire.h> //include arduinos i2c library
Ezo_board PH = Ezo_board(99, "PH"); //create a PH circuit object, who's address is 99 and name is "PH"
bool reading_request_phase = true; //selects our phase
uint32_t next_poll_time = 0; //holds the next time we receive a response, in milliseconds
const unsigned int response_delay = 1000; //how long we wait to receive a response, in milliseconds
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
Serial.println("begin");
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
Wire.begin(); //start the I2C
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
// Your code here
if (reading_request_phase) //if were in the phase where we ask for a reading
{
//send a read command. we use this command instead of PH.send_cmd("R");
//to let the library know to parse the reading
PH.send_read_cmd();
next_poll_time = millis() + response_delay; //set when the response will arrive
reading_request_phase = false; //switch to the receiving phase
}
else //if were in the receiving phase
{
if (millis() >= next_poll_time) //and its time to get the response
{
receive_reading(PH); //get the reading from the PH circuit
reading_request_phase = true; //switch back to asking for readings
}
}
}
void receive_reading(Ezo_board &Sensor) // function to decode the reading after the read command was issued
{
Serial.print(Sensor.get_name()); // print the name of the circuit getting the reading
Serial.print(": ");
Sensor.receive_read_cmd(); //get the response data and put it into the [Sensor].reading variable if successful
switch (Sensor.get_error()) //switch case based on what the response code is.
{
case Ezo_board::SUCCESS:
Serial.println(Sensor.get_last_received_reading()); //the command was successful, print the reading
phIOT = Sensor.get_last_received_reading();
break;
case Ezo_board::FAIL:
Serial.print("Failed "); //means the command has failed.
break;
case Ezo_board::NOT_READY:
Serial.print("Pending "); //the command has not yet been finished calculating.
break;
case Ezo_board::NO_DATA:
Serial.print("No Data "); //the sensor has no data to send.
break;
}
Serial.print("ph float: ");
Serial.println(phIOT);
}
Verbose output.txt (1.4 MB)