
04.Mar.2023
In this application, we will examine how to measure volt information and send it to Android phone via bluetooth module.
The resistors R1 and R2 seen in the circuit diagram divide the voltage to be measured. A lower voltage is generated on R2. The zener diode connected in parallel to the R2 resistor provides overvoltage protection. For example, if 100 volts is applied to the measuring input, the voltage across R2 will exceed 20 volts. In this case, without the zener diode, this voltage would damage the microcontroller system. The 20 volt voltage is kept at 5 volts with the help of a 5.1 volt zener and a protection resistor.
You can watch our Youtube video about the application.
Below are the Flutter-Dart codes in the project:
import 'dart:async';
import 'dart:convert';
//import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bluetooth_serial/flutter_bluetooth_serial.dart';
void main()=> runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
// ignore: library_private_types_in_public_api
_MyAppState createState()=> _MyAppState();
}
class _MyAppState extends State {
List _devices=[];
late BluetoothConnection connection;
String adr="00:21:07:00:50:69"; // my bluetooth device MAC Adres
String recData="0 Volt";
late Timer _timer;
String _timeString="";
@override
void initState() {
// _startTimer(); automatic
super.initState();
_loadDevices();
}
Future _loadDevices() async {
List devices=await FlutterBluetoothSerial.instance
.getBondedDevices();
setState(() {
_devices=devices;
});
}
//----------------------------
Future sendData(String data) async {
data=data.trim();
try {
List list=data.codeUnits;
Uint8List bytes=Uint8List.fromList(list);
connection.output.add(bytes);
await connection.output.allSent;
if (kDebugMode) {
// print('Data sent successfully');
}
} catch (e) {
//print(e.toString());
}
}
// data RECEIVED --------------
Future receiveData() async {
connection.input!.listen((Uint8List data) {
//Data entry point
setState(() {
recData=ascii.decode(data);
//var n1=int.parse('-42');
});
});
}
//--------------------------------------
// TIMER START-----------
void _startTimer() {
_timer=Timer.periodic(Duration(milliseconds: 500), (timer) {
receiveData();
});
}
// TIMER STOP--------------------------------------
Future _stopTimer() async {
setState(() {
});
_timer.cancel();
}
//---------------------------------------------
@override
void dispose() {
_timer.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text("----VOLTMETER with BlueTooth-----"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text("MAC Adress: 00:21:07:00:50:69"),
ElevatedButton(child: Text("Connect"), onPressed: () {
connect(adr);
},),
const SizedBox(height: 30.0,),
const Text("VOLTMeter: ",style: TextStyle(fontSize: 55.0),),
Text(recData,style: TextStyle(fontSize: 60.0),),
const SizedBox(height: 10.0,),
// Text(_timeString),
const SizedBox(height: 10.0,),
ElevatedButton(child: Text("Stop timer"), onPressed: () {
_stopTimer();
},),
const SizedBox(height: 10.0,),
ElevatedButton(child: Text("Start timer"), onPressed: () {
_startTimer();
},),
],
),
),
)
);
}
Future connect(String address) async {
try {
connection=await BluetoothConnection.toAddress(address);
// sendData('111');
//durum="Connected to the device";
} catch (exception) {
// durum="Cannot connect, exception occured";
}
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
}
// --------------**************data gonder
//Future send(Uint8List data) async {
//connection.output.add(data);
// await connection.output.allSent;
// }
}
//------------*********** data gonder end
Below are the microcontroller codes used in the project:
#include
SoftwareSerial mySerial(10, 11); // RX, TX
char Buf[50]; // to bluetooth device<------
String volt_string="0 Volt";
void setup() {
// hc-05 bluetooth module volt meter-----------------------------
// Open serial communications and wait for port to open:
Serial.begin(9600);
mySerial.begin(9600);
}
void loop() {
float volt_in=analogRead(A0);// Vin INPUT
float deg=(volt_in/1023)*60; // for max. 55 volt
volt_string=String(deg);
volt_string=volt_string+" Volt";
volt_string.toCharArray(Buf, 50);
mySerial.write(Buf);
delay(200);
}

How to make a night light with Bluetooth control and three colors?
A practical and inexpensive night light design with Bluetooth control
03.03.2023

We make temperature and humidity detection system with Android device
Android apps
05.03.2023

A BlueTooth-controlled Android App to Measure Heart Rate
An application related to biomedical devices: Measuring heartbeats
08.03.2023

Controlling 8 LEDs with Android phone
Android apps with Bluetooth Module
13.03.2023

DC Motor Speed Control by Android phone
Android Mobil Apps
14.03.2023

Controlling multiple devices with Android phone
Android Apps with Bluetooth
15.03.2023

Projects with Wifi Module
Wifi module settings
20.03.2023

Application to Control Led Matrix Panel with Android Phone - Part 1
Led Panel-Bluetooth Apps
29.03.2023

Designing an IoT System
Designing an IoT system for personal and business
22.05.2023

Reading the Weather Using the GSM Module Connected to the Microcontroller
How to make weather reading application with GSM module
24.05.2023

Smart Homes Can Be Smarter Than Us.
I'm Programming My House.
18.12.2022

IoT impact in the Healthcare Industry
What is the level of applications of IoT objects in the health sector?
22.12.2022

Application of IoT(Internet of Things) Technologies to Animals
Animals on the Internet
23.12.2022

Smart Cars in the IoT Universe
The evolution of Smart Cars
24.12.2022

Use of HM-10, HC-06 and HC-05 Bluetooth Modules in IoT Projects
Use of HM-10, HC-06 and HC-05 Bluetooth Modules
23.01.2023

Led Control Application with HC-05 Bluetooth Module
Led Control with Android Phone-Flutter
25.02.2023

Electronic Organ Construction with HC-05 Bluetooth Module
Electronic organ design with the program written with Flutter-Dart codes
25.02.2023

220 Volt Lamp On-Off Application with Bluetooth
A bluetooth application made with Flutter-Dart codes
25.02.2023

Measuring resistance by phone to Android
Measuring resistance by phone to Android( with Flutter-Dart)
02.03.2023