Arduino Sensor Connection and Data Export to a smart phone

So far, I got the system to control the temperature and monitors the pH of a water tank. The temperature/heating system works on one circuit with a built-in display. The pH system works on a sensor attached to a circuit which is connected to an Arduino ​Uno that is connected to an OLED display to show its output. I want to add a dissolved oxygen measuring meter as well but I would like to combine all these sensors' output to an Arduino in order to analyze it all from one source instead of having too many circuits everywhere.

​Is there a circuit with all these sensors attached, which connects to an Arduino from which I can output the data through bluetooth or cellular data to a smart phone?

Welcome lehansa! Probably not, but it would not be that hard for you do design it. It appears you have each sensor working with its own Arduino. If that is correct do you have the source code? If so you have about half of your problem solved. Check the schematics of the existing ones and if they each use different pins great, if not you will have to assign a different pin(s) to each sensor unless they are I2C, then they stay on the same two pins. You can output via bluetooth, I do not know about celular. Have fun with your project and let us know how you progress. When you ask additional questions post links to the technical side of the hardware devices.

I will leave others to talk about connecting the sensors to Arduino, but my (paid) pfodApp can handle the connection via bluetooth or SMS or WiFi or BLE to an Android mobile.
There is a free pfodDesigner Android app that will generate the Arduino code for you to make the connection and numerous example sketches.
This one does 3G/2G SMS

Welcome to the forum.

There are a few things we do not know. So, here are a few general points.

BLE is great when you need low power. e.g., when your sensor runs from a battery. The drawback is you need an app to interact with your BLE device. There are generic apps (BLE Scanner, nRF Connect, ...) that allow you to read and write raw data. But for a good user experience you need to write your own. Maybe the app from drmpf is something in between.

When you have power available you can use WiFi. It allows you to run a local WebServer that provides an interface that anyone can use. With some HTML and CSS knowledge you can make that very pretty.
You can have a secure WPA2 access point or connect to your home WiFi. There are additional options if you want to extend this system e.g., local or cloud data storage and analysis.

There are a couple of Nano sized Arduinos that have WiFi and/or BLE build in. Only you know how many I/Os you need. You can even switch between BLE and WiFi with some Arduinos.

Hello! Thanks for your reply,

The temperature sensor senses and displays the output on a built-in display but I need one temperature sensor that will connect to the arduino to be displayed on a phone, so I plan on using another sensor shown here:https://create.arduino.cc/projecthub/imjeffparedes/add-wifi-to-arduino-uno-663b9e

The pH sensor is connected to an Arduino which is connected to an OLED display as shown in this website: DIY Ph Meter using PH Sensor & Arduino with OLED Display

Also, gilshultz, (I had to cut the message in half because of the link and media limit)

I am planning to connect the dissolved oxygen sensor as shown here: D.O. Meter using Analog Dissolved Oxygen Sensor & Arduino.

I checked some of the pins used for the oxygen and pH systems and found that both the OLED display and use a GND pin (also, I switched to a wifi module ( I plan on connecting it this way: https://create.arduino.cc/projecthub/imjeffparedes/add-wifi-to-arduino-uno-663b9e) which uses a GND pin) but there are only 2 GND pins so I don’t know what to do). Also, the wifi module and another sensor both use the 3.3v pin and there might be more pins.
Should I get a breadboard or is there a different way to connect all of this?

(The schematics are included in the websites).

@Klaus_K

Thank you for the feedback: just to clarify, compared to BLE, wifi draws a lot more power, right? In other words, if I am using a battery which one would work better?

There is no better. It is a compromise between bandwidth and power. Maybe using BLE and WiFi would be the best solution for what you would like to achieve.

Can you describe the use case a bit more?

  • Is the device active all the time or once a day, hour ... ?
  • Is the radio active all the time or once a day, hour ...?
  • How much data do you need to transfer?
  • ...

The only thing you can say with certainty about the choice is that Bluetooth is more convenient. This goes double if you are already using a Uno, which is not such a great choice for working with WiFi. The rest is down to you, and any technical differences may be irrelevant anyway. I would use Bluetooth every time simply because I'm not aware of a WiFi terminal programme that is a direct equivalent to the Bluetooth terminal I use, and there has never been any motivation to look. This decision has nothing to do with Arduino.....

@Klaus_K ,

I expect all these aspects to be active for about an hour or two a day, and I expect I might need to transfer 1-2 MB, but I am not completely sure yet because this is the first time I am trying to transfer raw data.

Take a deep breath, you can connect all the grounds together. The UNO's I use have several ground pins, two together and one on the other side by Aref. You can connect all the grounds together, they are the same. If you have a small proto board you can use that to connect them. The ISP plug also has a ground.

The amount of data is low enough to use BLE. On the other side if you only need to enable WiFi once a day to send the data you can also use WiFi with a battery.

You can chose the protocol that you can use to create the best user experience. That depends on your skills. Do you want to use a BLE app or a web page?

That is a key point. Coding a BLE app is a pain where as you still display your webpage on your mobile.

If you decide to use WiFi instead of Bluetooth(either classic or BLE) the path of adding an esp8266 module to a UNO is not an optimal route.

You would do better to use an fully featured usb interfaced esp8266 development board like the Wemos or NodeMCU.

For more IO and bluetooth integrated as well as WiFi, you should look at the ESP32 development board.

@cattledog

I already have a bluetooth module: https://www.amazon.com/HiLetgo-Wireless-Bluetooth-Transceiver-Support/dp/B01CKW4FSI/ref=sr_1_18?dchild=1&keywords=bLE+to+arduino+module&qid=1630668728&s=electronics&sr=1-18

So, would that work too?

That device is a HC-06 "classic" Bluetooth. It is one of the most popular ways of getting data out of Arduino and, since you've got it, you might as well use it. This assumes you are using Android. It is incompatible with iPhone. If you are currently sending data to the serial monitor, you may simply connect Bluetooth to the serial pins and you are off to the races - no additional code required.

You might find the following background notes useful.

Thank's for the guides.

I've got the circuit-connecting part done. For the app, after I check the serial if the monitor's data comes through, how to I connect that data to the app, and what programming language is used when building an app on Kai Morich's app or Cetin's app to connect to the HC-06 circuit?

This makes no sense. You use the IDE to programme the Arduino to send data to the serial port, in a manner similar to that for the display, which you imply you have already done.
Serial.Print(data);
Morich and Cetin's apps are simply terminals to receive that data via Bluetooth. You are making this all a lot more difficult than it really is...! There is a data-logging example in the notes.

@Nick_Pyner
OK. I saw it. Right now, I have a program that displays the sensor data on a separate OLED display and the serial monitor. I also found a program that sends and prints random numbers on the Bluetooth Terminal App through the HC-06, so I know that connection is fixed. I've tried to combine these two programs so that instead of printing random numbers, the sensor data is being printed on the app and but error messages show up and the sensor data isn't sent over.

How do I achieve sending over the sensor data by combining these programs? I am sending the two programs below now.

This is the program that collects and displays pH, temperature, and dissolved oxygen values.:

//Ph, DO, Temperature to OLED from Arduino - Lehansa M

#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define DO_PIN A1
//ADDED DEFINE SENSOR PIN A0 FOR PH STARTS HERE-LEHANSA
#define SensorPin A0 // the pH meter Analog output is connected with the Arduino’s Analog
unsigned long int avgValue; //Store the average value of the sensor feedback
float b;
int buf[10],temp;

//ADDED DEFINE SENSOR PIN A0 FOR PH ENDS HERE-LEHANSA

#define VREF 5000 //VREF (mv)
#define ADC_RES 1024 //ADC Resolution

//Single-point calibration Mode=0
//Two-point calibration Mode=1
#define TWO_POINT_CALIBRATION 0

#define READ_TEMP (25) //Current water temperature ℃, Or temperature sensor function

//Single point calibration needs to be filled CAL1_V and CAL1_T
#define CAL1_V (131) //mv
#define CAL1_T (25) //℃
//Two-point calibration needs to be filled CAL2_V and CAL2_T
//CAL1 High temperature point, CAL2 Low temperature point
#define CAL2_V (1300) //mv
#define CAL2_T (15) //℃

const uint16_t DO_Table[41] = {
14460, 14220, 13820, 13440, 13090, 12740, 12420, 12110, 11810, 11530,
11260, 11010, 10770, 10530, 10300, 10080, 9860, 9660, 9460, 9270,
9080, 8900, 8730, 8570, 8410, 8250, 8110, 7960, 7820, 7690,
7560, 7430, 7300, 7180, 7070, 6950, 6840, 6730, 6630, 6530, 6410
};

uint8_t temperature;
uint16_t ADC_Raw;
uint16_t ADC_Voltage;
uint16_t DO;

int16_t readDO(uint32_t voltage_mv, uint8_t temperature_c)
{
#if TWO_POINT_CALIBRATION == 00
uint16_t V_saturation = (uint32_t)CAL1_V + (uint32_t)35 * temperature_c - (uint32_t)CAL1_T * 35;
return (voltage_mv * DO_Table[temperature_c] / V_saturation);
#else
uint16_t V_saturation = (int16_t)((int8_t)temperature_c - CAL2_T) * ((uint16_t)CAL1_V - CAL2_V) / ((uint8_t)CAL1_T - CAL2_T) + CAL2_V;
return (voltage_mv * DO_Table[temperature_c] / V_saturation);
#endif
}

void setup()
{
Serial.begin(115200);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
display.clearDisplay();
delay(10);

pinMode(13,OUTPUT);  

Serial.begin(9600);
//Serial.println("Ready"); //Test the serial monitor

}

void loop()
{
temperature = (uint8_t)READ_TEMP;
ADC_Raw = analogRead(DO_PIN);
ADC_Voltage = uint32_t(VREF) * ADC_Raw / ADC_RES;

for(int i=0;i<10;i++) //Get 10 sample value from the sensor for smooth the value
{
buf[i]=analogRead(SensorPin);
delay(10);
}
for(int i=0;i<9;i++) //sort the analog from small to large
{
for(int j=i+1;j<10;j++)
{
if(buf[i]>buf[j])
{
temp=buf[i];
buf[i]=buf[j];
buf[j]=temp;
}
}
}
avgValue=0;
for(int i=2;i<8;i++) //take the average value of 6 center sample
avgValue+=buf[i];
float phValue=(float)avgValue5.0/1024/6; //convert the analog into millivolt
phValue=3.5
phValue; //convert the millivolt into pH value
Serial.print("PH:\t" + String(phValue) + "\t" );
Serial.print("temperature:\t" + String(temperature) + "\t");
//Serial.print("ADC RAW:\t" + String(ADC_Raw) + "\t");
//Serial.print("ADC Voltage:\t" + String(ADC_Voltage) + "\t");
Serial.println("DO:\t" + String(readDO(ADC_Voltage, temperature)) + "\t");

display.clearDisplay();
display.setCursor(10, 0); //oled display
display.setTextSize(1);
display.setTextColor(WHITE);
display.print("Dissolved Oxygen");

display.setCursor(30, 20); //oled display
display.setTextSize(2);
display.setTextColor(WHITE);
display.print((readDO(ADC_Voltage, temperature))/1000);
display.setTextSize(1);
display.print(" mg/L");
display.display();
delay(1000);

//TEMPERATURE STARTS HERE-LEHANSA
display.clearDisplay();
display.setCursor(10, 0); //oled display
display.setTextSize(1);
display.setTextColor(WHITE);
display.print("Temperature");

display.setCursor(30, 20); //oled display
display.setTextSize(2);
display.setTextColor(WHITE);
display.print(temperature);
display.setTextSize(1);
display.print("degrees C");
display.display();
delay(2000);

//TEMPERATURE ENDS HERE-LEHANSA

//PH DISPLAY STARTS HERE-LEHANSA
display.clearDisplay();
display.setCursor(10, 0); //oled display
display.setTextSize(1);
display.setTextColor(WHITE);
display.print("PH Value");

display.setCursor(30, 20); //oled display
display.setTextSize(2);
display.setTextColor(WHITE);
display.print(phValue);
display.setTextSize(1);
display.display();
delay(3000);
//PH DISPLAY ENDS HERE-LEHANSA
}