Skip to content

Aditya-11/STM32-Bluetooth-Based-Home-Automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STM32-Bluetooth-Based-Home-Automation

  • Used ARM-Keil IDE

License

  • HC-05 module

STM32f303RE microcontroller was used in the project.

Used STM32 microcontroller and various sensor to collect data and control the led lights , dc motor and send the data to a user mobile and controlled the outputs through bluetooth

Bluetooth module used HC-05

  1. Bluetooth is IEEE 802.15.1 standardized protocol, through which one can build wireless Personal Area Network (PAN). It uses frequency-hopping spread spectrum (FHSS) radio technology to send data over air.

  2. Communication between bluetooth and microcontroller is done using UART (Universal Asynchronous Receiver and Transmitter) protocol

  3. The UART packet size is about 8 bits , 1 start and 1 stop bit and 0 parity bits.

  4. Check out the baudrate , rated baudrate at command mode is 38400 and at data mode is 9600, whenever the enable pin is ON then its in command mode. You can go through various AT commands to configure your bluetooth module from HC-05 documentation.

Sensors Used

  • Used ADC 1 (timmer 1) and 2 (timmer 8) to sample the analog values comming from various sensors.
  1. LM-35 -> temperature sensor
  2. LDR -> Light brightness in a room
  3. PIR -> To detect presence of someone inside a room , used gpio_10 from getting high/low input

Outputs

  • 1st to control the light intensity , 2nd -> To drive a dc motor (fan)
  1. Based on sensing data outputs were produced in the form of PWM signal using timmer 16 and 17 from main.c file.

  2. Based on temperature , if it's high, then speed of fan (dc motor) was increased and decreased if it's low by adjusting the pwm signal.Dont directly interface the DC motor to the microcontroller , this may lead to damage of microcontroller if it draws more current, use dc driver circuits.

  3. Based on the intensity of light the brightness of LED lights was adjusted by adjusting the PWM values.

  4. The values of temperature , light intensity % , presence of a person was send to a persons mobile through bluetooth module. And from the bluetooth app person had the option to control speed of fan. This was done by sending by sensing data through blutooth from mobile to blutooth module therough bluetooth protocol and from there through UART to the microcontroller. Based on the data the dutycycle of the PWM waveform was varied to control the speed of the motor.

Control AC devices

  • controlling AC devices isn't as easy as controlling dc devices , the knowledge of power electronics would be very much useful for this kind of task. Due to time contraint we couldn't implement this part completely, the power circuits were failing but the guys who are really interested in making a real home automation system can have a look at the content below. Below is controlling AC lamp for AC drive we have to use a snubber circuit.

  • POWER CIRCUIT

The power circuit consists of two parts

  1. The Triac driver circuit
  2. The zero crossing detection circuit
  • The driver circuit

As we are trying to do ac power control we would be requiring a triac.A triac is a device in which two thyristors are connected in anti parallel.It has 3 terminals MT1,MT2and Gate.Triac allows power flow in both the directions.It acts as a switch and is only turned on when the gate pulse is triggered. here we are also using a MOC3021 which is an optocoupler.The main purpose of the MOC is to optically isolate the microcontroller side from the power circuit side and to amplify the pwm signal and give it to the gate terminal of the traic.It consists of an IR LED which emits light when it receives a voltage more than 1.1V and a Diac which acts as an LASCR(Light activated Silicon Controlled Rectifier).The Diac starts conducting whenever light is emitted by the diode. Whenever the dia conducts the gate pulse is being given to the triac and it starts firing.

  • Zero crossing detection circuit

In this circuit we will be using a 220V-6V step down transformer,LM741 op amp which acts as a comparator,a signal diode. This circuit is used to detect instances where the ac supply is crossing zero.What it does is it creates a rising edge a nd a falling edge alternatively whenever it detects a zero on the ac supply.We will read these rising and falling edges through the microcontroller and generate an interrupt exactly when the edges are detecting.The pwm output which is generated by the output of ldr should be given to the MOC exactly when an interrupt is being generated so that the gate pulse and the ac supply are in synchronization.This circuit helps us in preventing giving two gate pulses in a single period of 180 degrees.

About

Used STM32 microcontroller and various sensor to collect data and control the led lights , dc motor and send the data to a user mobile and controlled the outputs through bluetooth

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages