On off switch using bluetooth

Bluetooth receiver as an on/off switch

Is it possibly to use a Bluetooth receiver as an on/off switch in a circuit board? Ideally, I would set the Bluetooth receiver into a low energy/sleep mode and use it simply as an on/off switch on a device. There is a small battery connected to the circuit board and an LED light at the other end, just to test if this will work. Ideally it works like so: Android/iPhone sends signal to Bluetooth receiver Bluetooth receiver accepts the signal, then the LED light turns on/off I know many people use bluetooth devices to maintain a constant connection with their phone and/or constantly feed information, however this isn’t my intention. I simply want to use it as an on/off switch that my phone can communicate with at all times.

1 Answer 1

You are looking for Bluetooth 4.0 I think. Lower BT versions are not made for energy efficient systems. Notice you probably want to stay connected to the BT device because:

  • Polling/inquiring is were BT normally wastes more power.
  • You may want to have «real time» response (you don’t want to wait until the BT devices are synchronized). Going from standby to connected status may take from more than half a second (known address) to several seconds (unknown address) which is definitively a non real time response.

There are also low power modes for the BT (park, hold and sniff), which you can use to quickly change to the active (connected) status for data transmission.

Sorry for the mixed up ideas in the response, it is better if you read a little bit about BT versions and architecture if you are interested. Otherwise my advise is, again, go for BT version 4.

Источник

Programmers Sample Guide

Bluetooth is a wireless technology standard for exchanging data over short distances, low-bandwidth peer-to-peer communications, between mobile devices creating personal area networks (PANs) with high levels of security. The Bluetooth device in Android is controlled via the BluetoothAdapter class. For the adatper to work you application manifest needs to include the BLUETOOTH and the BLUETOOTH_ADMIN permission.

If you are going to use Bluetooth Scanner in your mobile application to scan barcodes then it will stop you from using the soft keyboard unless a keyboard wedge is provided by the scanner company. So the only way to use the keyboard is to switch off the bluetooth as the mobile device thinks that the scanner is as a bluetooth keyboard. The ablity to quickly switch off bluetooth and switch it back on is needed if you want to both scan barcodes as well as use the keyboard in your app.

Читайте также:  Samsung r425 драйвера блютуз

Android Bluetooth Switch on/off programmatically

Android Manifest

Application Layout — activity_main.xml

Application Activity — MainActivity.java

package com.as400samplecode; import android.os.Bundle; import android.app.Activity; import android.bluetooth.BluetoothAdapter; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class MainActivity extends Activity implements OnClickListener < private BluetoothAdapter mBluetoothAdapter; private Button changeStatus; private TextView status; @Override public void onCreate(Bundle savedInstanceState) < super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //reference to the button changeStatus = (Button) findViewById(R.id.changeStatus); changeStatus.setOnClickListener(this); //reference to the text view status = (TextView) findViewById(R.id.status); //reference to the bluetooth adapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); //check if adatpter is available, please note if you running //this application in emulator currently there is no support for bluetooth if(mBluetoothAdapter == null)< status.setText("BlueTooth adapter not found"); changeStatus.setText("BlueTooth Disabled"); changeStatus.setEnabled(false); >//check the status and set the button text accordingly else < if (mBluetoothAdapter.isEnabled()) < status.setText("BlueTooth is currently switched ON"); changeStatus.setText("Switch OFF Bluetooth"); >else < status.setText("BlueTooth is currently switched OFF"); changeStatus.setText("Switch ON Bluetooth"); >> > @Override public boolean onCreateOptionsMenu(Menu menu) < getMenuInflater().inflate(R.menu.activity_main, menu); return true; >@Override public void onClick(View v) < switch (v.getId()) < case R.id.changeStatus: //disable the bluetooth adapter if (mBluetoothAdapter.isEnabled()) < mBluetoothAdapter.disable(); status.setText("BlueTooth is currently switched OFF"); changeStatus.setText("Switch ON Bluetooth"); >//enable the bluetooth adapter else < mBluetoothAdapter.enable(); status.setText("BlueTooth is currently switched ON"); changeStatus.setText("Switch OFF Bluetooth"); >break; // More buttons go here (if any) . > > >

Источник

Switch device on/off using bluetooth and application

There is something I want to make, and I’m not sure where to begin. I tried searching around but the problem is I don’t know where to start. So basically, there is a hardware side and a software side. The hardware side is just a Bluetooth v4.0 device which turns on and off. that’s it. Now I want to develop an Android application which can connect to this device via Bluetooth and switch the device on and off from the phone. Is there a special Bluetooth chip specific for this task? Do I have to write the program for a microcontroller so I can perform this task? If anyone could help just point me in the right direction just to get me started and I can research the rest then I would be really grateful. Thanks. Hassan

There is a bit missing from your plan. The ‘bluetooh chip’ needs a controller that tells it how to behave. This would normally mean some sort of microcontroller. Some bluetooth modules have a controller included and you can sometimes change the program on it to tailor it to some bespoke task like yours.

3 Answers 3

There is a bit missing from your plan. The ‘bluetooh chip’ needs a controller that tells it how to behave.
This would normally mean some sort of microcontroller, but there are Soc (system on chip) that include all of the radio, bluetooth stack and controller on one device.
There are bluetooth modules that include both the bluetooth and the controller and you can sometimes change the firmware on it to tailor it to some bespoke task like yours.

Читайте также:  Какие бывают колонки блютуз

Secondly there is the problem of when you ‘turn it off’ how do you turn it back on?
I assume the device would have a battery?
When you add a battery to a design you have to consider low power design and battery charge management.
Of course you also need the additional electronics to handle the battery.

Start by trying to find a development kit or evaluation board that has all the parts you need. I’ve not spent time studying it’s documentation, but something like this Texas Instruments CC2541

A Bluetooth low energy (Bluetooth Smart) based device sounds like what you are after.

The company I work for, CSR, produce a Bluetooth LE chip that has an SDK for on-chip applications and uses very low power. There are many application profiles for Low Energy but I can’t think of one specifically for just switching stuff on or off, although such an application would be very simple.

On the controlling side, you would definitely need a device capable of dual-mode operation e.g. to operate normal Bluetooth (BR/EDR) and Low Energy (LE). Any chip that is certified 4.0 will do this (newer iPhones, etc.)

I hear Broadcom make chips too.

The cheapest way to do this is to alter a mass produced bluetooth product that already has a bluetooth chip, microcontroller and an output. Whilst giving less flexibility than an arduino board or raspberry pi; for a simple on/off bluetooth controlled switch this should suffice and can be made for as little as £3.50.

Open it up and remove speaker. Pair phone with device (usually requires physical button push preventing randomer from pairing but may depend on bluetooth headset model)and play a tone which will generate a current in wires that used to go to speaker upon which you can attach a relay switch that can be had for pennies (check power rating if connecting to large device like garage door opener motor). Wire in on other side of relay circuit you want to control.

I should add there may be a cleverer way to get an output signal than by playing tone and hijacking speaker wires — by taking an ammeter and setting it on its lowest setting and connecting and disconnecting phone to device, try and locate if any current is starts flowing in circuit. If so may be a better place to wire to. Otherwise using something like app generator can quickly make an on button that transmits tone over bluetooth continuosly for a smoother experience.

P.S: if the question relates more to controlling another bluetooth device such as one phone controlling another, then this solution won’t be all that useful as I’m guessing you won’t want to start opening up your phone! as well as the issues highlighted by Jason.

Читайте также:  Ноутбук sony vaio есть bluetooth

Источник

Bluetooth Home Automation Light Bulb Switch Using An HC-05, A Relay, and Arduino

I used an HC-05 Bluetooth module, a relay switch, a light bulb switch, and an Arduino Uno to create a wireless home automation light switch. The goal was to establish a wireless protocol for switching a light bulb on and off using a simple app on a smartphone. The relay switch controls the power to the light bulb, the HC-05 handles the Bluetooth, and the Uno reads the Bluetooth module to control the relay. The tools implemented can be extrapolated to other projects such as automated blinds, temperature controlled fans, motion sensors, security cameras, smoke detectors, etc.

IMG_2728.JPG

IMG_2738.jpg

socket_whole.jpg

relay_zoom.jpg

IMG_2739.jpg

Wiring

wiring_diagram.png

Android App

I used a simple Andoid app that connects to the HC-05 and transmits strings. Using the app, on the Arduino side we can decode the signal to create a protocol that turns the light switch on or off. It can be as simple as 1s and 0s, or as complex as you want. I used a 1 for on, and a 0 for off, and this method is used in the Arduino code below. To change the protocol, just change the code section in the ‘if’ statement, and make sure to send the desired protocol through the Android app.

android_app_arduino.png

Arduino Code

#include int relay = 2; // Set pin for relay control SoftwareSerial bleserial(8,9); // setup the relay output and the bluetooth serial, and the serial monitor (if you want to print the outputs) void setup() < // set relay pin as output. pinMode(relay, OUTPUT); // start bluetooth and serial monitor bleserial.begin(9600); Serial.begin(9600); > void loop() < if(bleserial.available())< char char1 = bleserial.read(); Serial.println(char1); // Set protocol that you want to turn on the light bulb, I chose 1 and 0 as on and off, respectively if(char1=='1')< Serial.println("ON"); digitalWrite(relay,LOW); > else if (char1=='0') < digitalWrite(relay,HIGH); >> >

This project is straightforward, so I did not feel the need to make many comments throughout. The important thing to remember about using a relay module is that it involves switching AC current, also called mains power. This is a dangerous process. So please use caution when disassembling the light bulb socket. This project is a great introduction to using relays and switching, while also utilizing wireless technology and Arduino. The Bluetooth protocol process is useful for wireless sensing and control, and I hope the educational nature of this project opens up avenues in home automation, remote sensing, wireless control, and electronics in general.

Источник

Оцените статью
Adblock
detector