I keep advancing with the theme of the garden: D
I have these meters of ph and ec and I need to know what to put in the code to get me on your platform!
The model of ph is A1004v2 and that of ec is A1003v1
const int analogInPin = A2; // Analog input pin that the sensor is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 14);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
// print the results to the serial monitor:
Serial.print("sensor = " );
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(analogRead(2)* 14.0 / 1024, 1);
// wait 10 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(500);
}
Hi @maxcat, without thinger, what is the correct code that reads and print to serial the expected sensor value? Then we can include that inside any resource. Just think that you need to set this value to the out variable.
Random example:
// example resource
thing["example"] >> [](pson & out){
int sensorValue = analogRead(analogInPin);
// do whatever you want with the value!
sensorValue = sensorValue* 14.0 / 1024;
// set the value to the resource
out = sensorValue;
};
thing[“ph”] >> [](pson & out){
int sensorValue = analogRead(analogInPin);
// do whatever you want with the value!
sensorValue = sensorValue* 14.0 / 1024;
// set the value to the resource
out = sensorValue;
};
sensors.begin();
}
void loop() {
thing.handle();
}
I’d like to that PH has two decimal places to get it controlled. How could I do? Thank you
Thanks for your support Alvaro