What's new

Help Water dispenser Using bluetooth device Arduino project

Joined
Nov 28, 2023
Posts
14
Reaction
1
Points
7
Hi there's anyone that can help me to our research Project, water dispenser using bluetooth module using Arduino Uno? Then some diagram and code nadin po.
 
Of course! I can help you with your research project on a water dispenser using a Bluetooth module with Arduino Uno. Let's start with the hardware connections and then move on to the code.

Here's a general diagram of how you can connect the components:

Code:
Arduino Uno        Bluetooth Module       Relay Module        Water Pump
   GND ------------ GND
   5V -------------- VCC
   TX -------------- RX
   RX -------------- TX

Here's a step-by-step guide on how to proceed:

1. Connect the GND pin of Arduino Uno to the GND pin of the Bluetooth module.
2. Connect the 5V pin of Arduino Uno to the VCC pin of the Bluetooth module.
3. Connect the TX pin of Arduino Uno to the RX pin of the Bluetooth module.
4. Connect the RX pin of Arduino Uno to the TX pin of the Bluetooth module.
5. Connect the relay module to the Arduino Uno. The relay module will control the water pump.
6. Connect the VCC and GND pins of the relay module to the 5V and GND pins of Arduino Uno.
7. Connect the signal pin of the relay module to any digital pin of Arduino Uno. For example, you can connect it to pin 8.
8. Connect the water pump to the relay module. Make sure the power supply of the water pump is compatible with the relay module.

Now, let's move onto the code. Here's a basic outline of the code:

C++:
#include <SoftwareSerial.h>

int relayPin = 8;  // Connect the relay module to pin 8
SoftwareSerial bluetooth(10, 11);  // RX, TX

void setup() {
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW);
  
  Serial.begin(9600);
  bluetooth.begin(9600);
}

void loop() {
  if (bluetooth.available()) {
    char command = bluetooth.read();
    
    if (command == '1') {
      digitalWrite(relayPin, HIGH);  // Turn on the water pump
      Serial.println("Water pump turned on");
      bluetooth.println("Water pump turned on");
    } else if (command == '0') {
      digitalWrite(relayPin, LOW);  // Turn off the water pump
      Serial.println("Water pump turned off");
      bluetooth.println("Water pump turned off");
    }
  }
}

Make sure you have the SoftwareSerial library installed before uploading the code to Arduino Uno.

This code listens for commands from the Bluetooth module. If the command received is '1', it will turn on the water pump by setting the relay pin to HIGH. If the command received is '0', it will turn off the water pump by setting the relay pin to LOW.

Remember to pair your Bluetooth module with your smartphone or any other Bluetooth-enabled device. Once paired, you can send '1' to turn on the water pump and '0' to turn it off.

I hope this helps you in your research project! Let me know if you have any further questions.
 
Of course! I can help you with your research project on a water dispenser using a Bluetooth module with Arduino Uno. Let's start with the hardware connections and then move on to the code.

Here's a general diagram of how you can connect the components:

Code:
Arduino Uno        Bluetooth Module       Relay Module        Water Pump
   GND ------------ GND
   5V -------------- VCC
   TX -------------- RX
   RX -------------- TX

Here's a step-by-step guide on how to proceed:

1. Connect the GND pin of Arduino Uno to the GND pin of the Bluetooth module.
2. Connect the 5V pin of Arduino Uno to the VCC pin of the Bluetooth module.
3. Connect the TX pin of Arduino Uno to the RX pin of the Bluetooth module.
4. Connect the RX pin of Arduino Uno to the TX pin of the Bluetooth module.
5. Connect the relay module to the Arduino Uno. The relay module will control the water pump.
6. Connect the VCC and GND pins of the relay module to the 5V and GND pins of Arduino Uno.
7. Connect the signal pin of the relay module to any digital pin of Arduino Uno. For example, you can connect it to pin 8.
8. Connect the water pump to the relay module. Make sure the power supply of the water pump is compatible with the relay module.

Now, let's move onto the code. Here's a basic outline of the code:

C++:
#include <SoftwareSerial.h>

int relayPin = 8;  // Connect the relay module to pin 8
SoftwareSerial bluetooth(10, 11);  // RX, TX

void setup() {
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW);
 
  Serial.begin(9600);
  bluetooth.begin(9600);
}

void loop() {
  if (bluetooth.available()) {
    char command = bluetooth.read();
   
    if (command == '1') {
      digitalWrite(relayPin, HIGH);  // Turn on the water pump
      Serial.println("Water pump turned on");
      bluetooth.println("Water pump turned on");
    } else if (command == '0') {
      digitalWrite(relayPin, LOW);  // Turn off the water pump
      Serial.println("Water pump turned off");
      bluetooth.println("Water pump turned off");
    }
  }
}

Make sure you have the SoftwareSerial library installed before uploading the code to Arduino Uno.

This code listens for commands from the Bluetooth module. If the command received is '1', it will turn on the water pump by setting the relay pin to HIGH. If the command received is '0', it will turn off the water pump by setting the relay pin to LOW.

Remember to pair your Bluetooth module with your smartphone or any other Bluetooth-enabled device. Once paired, you can send '1' to turn on the water pump and '0' to turn it off.

I hope this helps you in your research project! Let me know if you have any further questions.
Can you customize it some features like choosing how much water it will ran, like 50ml, 100ml, 150ml, 200ml, 250ml. And how can I create a bluetooth app/device to run that
 
Can you customize it some features like choosing how much water it will ran, like 50ml, 100ml, 150ml, 200ml, 250ml. And how can I create a bluetooth app/device to run that
Sure! To customize the water dispenser to choose the amount of water, you can modify the code to include different options for water volume. Here's an updated code with additional functionality:

C++:
#include <SoftwareSerial.h>

int relayPin = 8;  // Connect the relay module to pin 8
SoftwareSerial bluetooth(10, 11);  // RX, TX

void setup() {
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW);
 
  Serial.begin(9600);
  bluetooth.begin(9600);
}

void loop() {
  if (bluetooth.available()) {
    char command = bluetooth.read();
   
    if (command == '1') {
      digitalWrite(relayPin, HIGH);  // Turn on the water pump
      Serial.println("Water pump turned on");
      bluetooth.println("Water pump turned on");
    } else if (command == '0') {
      digitalWrite(relayPin, LOW);  // Turn off the water pump
      Serial.println("Water pump turned off");
      bluetooth.println("Water pump turned off");
    } else if (command == '2') {
      digitalWrite(relayPin, HIGH);  // Turn on the water pump
      delay(50);  // Adjust this delay to control the water flow rate
      digitalWrite(relayPin, LOW);  // Turn off the water pump
      Serial.println("50ml dispensed");
      bluetooth.println("50ml dispensed");
    } else if (command == '3') {
      digitalWrite(relayPin, HIGH);  // Turn on the water pump
      delay(100);  // Adjust this delay to control the water flow rate
      digitalWrite(relayPin, LOW);  // Turn off the water pump
      Serial.println("100ml dispensed");
      bluetooth.println("100ml dispensed");
    } else if (command == '4') {
      digitalWrite(relayPin, HIGH);  // Turn on the water pump
      delay(150);  // Adjust this delay to control the water flow rate
      digitalWrite(relayPin, LOW);  // Turn off the water pump
      Serial.println("150ml dispensed");
      bluetooth.println("150ml dispensed");
    } else if (command == '5') {
      digitalWrite(relayPin, HIGH);  // Turn on the water pump
      delay(200);  // Adjust this delay to control the water flow rate
      digitalWrite(relayPin, LOW);  // Turn off the water pump
      Serial.println("200ml dispensed");
      bluetooth.println("200ml dispensed");
    } else if (command == '6') {
      digitalWrite(relayPin, HIGH);  // Turn on the water pump
      delay(250);  // Adjust this delay to control the water flow rate
      digitalWrite(relayPin, LOW);  // Turn off the water pump
      Serial.println("250ml dispensed");
      bluetooth.println("250ml dispensed");
    }
  }
}

In the updated code, we have added options for different water volumes such as 50ml, 100ml, 150ml, 200ml, and 250ml. When you send the corresponding command from the Bluetooth module, the water pump will turn on for the specified duration (controlled by the delay() function) and dispense the desired amount of water.

Now, let's move to the Bluetooth app/device. You can create a custom Bluetooth app using various platforms and programming languages like Android Studio (Java), Flutter (Dart), or React Native (JavaScript). The app will establish a connection with the Bluetooth module and send the commands for different water volumes.

Here's a brief example using Flutter and Dart to create a simple Bluetooth app:

Code:
import 'package:flutter/material.dart';
import 'package:flutter_bluetooth_serial/flutter_bluetooth_serial.dart';

class BluetoothPage extends StatefulWidget {
  @override
  _BluetoothPageState createState() => _BluetoothPageState();
}

class _BluetoothPageState extends State<BluetoothPage> {
  BluetoothConnection connection;
  bool isConnected = false;

  void _connectToDevice() async {
    List<BluetoothDevice> devices = await FlutterBluetoothSerial.instance.getBondedDevices();
    BluetoothDevice device = devices.firstWhere((device) => device.name == 'YOUR_DEVICE_NAME');
    
    await BluetoothConnection.toAddress(device.address).then((_connection) {
      setState(() {
        connection = _connection;
        isConnected = true;
      });
      print('Connected to device');
    }).catchError((error) {
      print('Error connecting to device: $error');
    });
  }
  
  void _sendCommand(String command) {
    connection.output.add(ascii.encode(command + '\n'));
    connection.output.allSent.then((_) {
      print('Command sent: $command');
    });
  }

  @override
  void initState() {
    super.initState();
    _connectToDevice();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Bluetooth App')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            RaisedButton(
              child: Text('50ml'),
              onPressed: () {
                _sendCommand('2');
              },
            ),
            RaisedButton(
              child: Text('100ml'),
              onPressed: () {
                _sendCommand('3');
              },
            ),
            RaisedButton(
              child: Text('150ml'),
              onPressed: () {
                _sendCommand('4');
              },
            ),
            RaisedButton(
              child: Text('200ml'),
              onPressed: () {
                _sendCommand('5');
              },
            ),
            RaisedButton(
              child: Text('250ml'),
              onPressed: () {
                _sendCommand('6');
              },
            ),
          ],
        ),
      ),
    );
  }
}

In this example, we use the Flutter Bluetooth Serial package to connect to a specific Bluetooth device (replace 'YOUR_DEVICE_NAME' with the name of your Bluetooth module) and send commands for different water volumes when the corresponding button is pressed.

Remember to set up Flutter and the necessary dependencies to run the app. You can find more details in the Flutter documentation.

I hope this helps you in implementing your water dispenser project with Bluetooth control! Let me know if you have any further questions.
 

Similar threads

Back
Top