Go Down

Topic: Arduino pH Sensor with HC-06 Bluetooth (Read 700 times) previous topic - next topic

mayamac-seid

I am trying to program a HC-06 Bluetooth module to send data from a pH sensor connected to an Arduino Uno to the serial monitor on my laptop. The code for the pH sensor alone works perfectly and I was able to connect my HC-06 module to my computer and I have the COM port for it set up in the Arduino IDE. This is my first time using a bluetooth module in an Arduino project. 

What do I add to my code in order for the data to be sent to the serial monitor via the Bluetooth module?

Code: [Select]

#include <DFRobot_PH.h>

#include <EEPROM.h>


#define PH_PIN A1

float voltage,phValue,temperature = 25;

DFRobot_PH ph;


void setup()

{

    Serial.begin(115200);  

    ph.begin();

}


void loop()

{

    static unsigned long timepoint = millis();

    if(millis()-timepoint>1000U){                  //time interval: 1s

        timepoint = millis();

        //temperature = readTemperature();         // read your temperature sensor to execute temperature compensation

        voltage = analogRead(PH_PIN)/1024.0*5000;  // read the voltage

        phValue = ph.readPH(voltage, temperature);  // convert voltage to pH with temperature compensation

        //Serial.print("temperature:");

        //Serial.print(temperature,1);

        Serial.print("pH:");

        Serial.println((phValue*-0.816226171)+ 10.34788768,2); //using linear regression to compensate for calibration

    }

    ph.calibration(voltage,temperature);           // calibration process by Serial CMD

}




TheUNOGuy

It's better if you check the internet  ( your friend ) before posting..! ;)
How to get the best out of the forum - https://forum.arduino.cc/index.php?topic=712197.msg4790182#new

ballscrewbob


@mayamac-seid

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.


It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google (who would have thunk it ! ) or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Nick_Pyner

I didn't think you can do that, but I may be wrong.

https://create.arduino.cc/projecthub/millerman4487/view-serial-monitor-over-bluetooth-fbb0e5

If I am right, you can still do what you want by using a proper terminal programme on PC - like RealTerm.

Either way, I bet you need to change from 115200 to 9600, as I bet you haven't configured Bluetooth. That will be the only change to the programme needed. Disconnect Bluetooth before uploading.

Go Up