Hello there, Can anyone tell me where and how to plug this in, and what code to use?
(Sorry if the photo takes time to load.)Thanks in advance.
Hello there, Can anyone tell me where and how to plug this in, and what code to use?
I'm going to take a wild guess that the output pins marked O/P bottom centre, are an analog value across their + and - pins.
That would indicate - to Arduino ground and + to an analog input Ax pin, and just read it with analogRead(), but before you do that check the output voltage with a voltmeter that it's not over 5V ever.
Looks like the board has its power supplied bottom right, but does it say 9V?
edit... looks like this one? Says there, it's analog with output is 0.5-3V.
I'll try the idea.Thanks
SumukhPrasad:
I'll try the idea.Thanks
But finding the datasheet would be a better option.
I have the data sheet, but it doesn't say anything about what goes to what.
Nope. That doesn't work. I get a constant zero.
Well it seems from the link I posted in #1, which admittedly is perhaps not your actual model, but looks very very similar, that just wiring the output to an analog input should work. It says:
Perhaps post your code and a link to the datasheet you have.
What voltage do you read with your multimeter on those outputs?
(Presumably you have the probe connected to the bnc?)
First, which ports? A0-A15 or AREF? Second, I don't have a multimeter, but the data sheet says says that the max. output is 5 volts.
Here is the code.:
int phval = 0;
#include <Arduino.h>
#include <TM1637Display.h>
// Module connection pins (Digital Pins)
#define CLK0 41
#define DIO0 43
#define CLK1 23
#define DIO1 25
#define TEST_DELAY 2000
const uint8_t SEG_pH[] = {
SEG_A | SEG_F | SEG_E | SEG_G | SEG_B,
SEG_F | SEG_E | SEG_G | SEG_B | SEG_C,
SEG_G | SEG_D,
};
TM1637Display display0(CLK0, DIO0);
TM1637Display display1(CLK1, DIO1);
void setup()
{
Serial.begin(9600);
pinMode(27, OUTPUT);
pinMode(29, OUTPUT);
digitalWrite(27, HIGH);
digitalWrite(29, LOW);
pinMode(45, OUTPUT);
pinMode(47, OUTPUT);
digitalWrite(45, HIGH);
digitalWrite(47, LOW);
pinMode(A1, INPUT);
int k;
uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };
display0.setBrightness(0x0f);
display1.setBrightness(0x0f);
// All segments on
display0.setSegments(data);
display1.setSegments(data);
delay(TEST_DELAY);
}
void loop()
{
phval = digitalRead(A1);
int k;
uint8_t data[] = { 0xFF, 0xFF, 0xFF, 0xFF };
uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };
display0.setBrightness(0x0f);
/*Set PH VALUE HERE!!!!!!!!Get the first, second, third,
fourth digit of the ph value and calibrate to show the
value on the screen. */
data[0] = display0.encodeDigit(1);
data[1] = display0.encodeDigit(2);
data[2] = display0.encodeDigit(3);
data[3] = display0.encodeDigit(4);
display0.setSegments(data);
display1.setSegments(SEG_pH);
Serial.println(phval);
}
Make this an analogRead()
phval = digitalRead(A1);
I don't have a multimeter
Bzzzzt.... wrong answer
Thanks. Now I get a continuous stream of completely unrelated numbers when connected.
SumukhPrasad:
Thanks. Now I get a continuous stream of completely unrelated numbers when connected.
You mean from here?
Serial.println(phval);
Those numbers are from 0 to 1023 for 0 to 5V, so x5/1023 to get voltage.
Then the datasheet of the sensor will tell you the relationship between volts and pH.
By the way the voltage needs to be a float, and make the 5 and 1023 floats as well to make sure the maths happens correctly, as shown here:
float voltage= sensorValue * (5.0 / 1023.0);
Now I get a constant reading of 8 ph.
int phval = 0;
#include <Arduino.h>
#include <TM1637Display.h>
// Module connection pins (Digital Pins)
#define CLK0 41
#define DIO0 43
#define CLK1 23
#define DIO1 25
// The amount of time (in milliseconds) between tests
#define TEST_DELAY 2000
const uint8_t SEG_pH[] = {
SEG_A | SEG_F | SEG_E | SEG_G | SEG_B,
SEG_F | SEG_E | SEG_G | SEG_B | SEG_C,
SEG_G | SEG_D,
};
char myChar[10];
TM1637Display display0(CLK0, DIO0);
TM1637Display display1(CLK1, DIO1);
void setup()
{
Serial.begin(9600);
pinMode(27, OUTPUT);
pinMode(29, OUTPUT);
digitalWrite(27, HIGH);
digitalWrite(29, LOW);
pinMode(45, OUTPUT);
pinMode(47, OUTPUT);
digitalWrite(45, HIGH);
digitalWrite(47, LOW);
pinMode(A1, INPUT);
int k;
uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };
display0.setBrightness(0x0f);
display1.setBrightness(0x0f);
// All segments on
display0.setSegments(data);
display1.setSegments(data);
delay(TEST_DELAY);
}
void loop()
{
phval = (((analogRead(A1)*5)/1023)/0.375);
int k;
uint8_t data[] = { 0xFF, 0xFF, 0xFF, 0xFF };
uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };
display0.setBrightness(0x0f);
/*Set PH VALUE HERE!!!!!!!!Get the first, second, third,
fourth digit of the ph value and calibrate to show the
value on the screen. */
Serial.println(itoa(phval, myChar, 10));
data[0] = display0.encodeDigit((myChar[3]));
data[1] = display0.encodeDigit((myChar[2]));
data[2] = display0.encodeDigit((myChar[1]));
data[3] = display0.encodeDigit((myChar[0]));
display0.setSegments(data);
display1.setSegments(SEG_pH);
Serial.println(phval);
Serial.println(itoa(phval, myChar, 10));
Serial.println(myChar[0]);
Serial.println(myChar[1]);
Serial.println(myChar[2]);
Serial.println(myChar[3]);
Serial.println(myChar[4]);
}
Now I get a constant reading of 8 ph.
Maybe the pH is 8?
You need to make phval a float, as I said, and put .0 on the 5.0 and 1023.0
But as far as I can see from a search, there is no Arduino float equivalent of itoa so not sure how you're going to get the digits out like you are for the integer.
In your other thread you just gave a value with no decimals:
SumukhPrasad:
if x is considered to be 375635
No. I tried different solutions. All seem to be 8. I know that soap has a different ph level than water.
SumukhPrasad:
No. I tried different solutions. All seem to be 8. I know that soap has a different ph level than water.
Try vinegar vs baking soda....
Maybe there's some calibration routine that needs to run.
Did you make the pH reading a float to get some decimals?
But get a voltmeter. Then you can measure the output directly at the sensor's connections, and know if any "unacceptable" readings are dodgy right from there, or if it's the Arduino coding.
You don't want to be the wheel-tapper who condemns a whole train just because the hammer's cracked.
Ive tried an Arduino "Voltmeter" project, which is supposed to tell me what voltage is present, if under 5 volts.
I did make them "float". I've tried:
-Salt solutions
-Soap
-Water
-Copper sulphate solution
-Sodium Hydroxide
-Baking soda.
All of them seem to be pH 9.