You are on page 1of 8

1.

Software/Tools setup

Software/Tools required: Arduino IDE [download from: https://www.arduino.cc/en/software]

2. Configuration steps

To ease the development of this work, Arduino IDE which is pretty simple and powerful with serial
monitor feature will be used.

As Arduino IDE is not compatible for programming of STM32 Nucleo Boards by default, these
configuration steps are necessary to perform in Arduino IDE to make it compatible for programming
of STM32 Nucleo Boards:

1. Open Arduino IDE


2. Go to File -> Preferences
3. In Additional Boards Manager URLs column, type:
https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_i
ndex.json
4. Click OK
5. Go to Tools -> Board -> Boards Manager
6. In search column, search for “STM32”, click on “STM32 MCU based boards by
STMicroelectronics” to install the board package. All the series of STM32 board by
STMicroelectronics will be installed in Arduino IDE.
7. Go to Tools -> Board, choose for your STM32 board series. In this work, Nucleo-64 will be
used
8. Go to Tools -> Board part number, choose for your STM32 board part number. In this work,
Nucleo F446RE will be used
9. Go to Tools -> Port and select the port on which your STM32 board is connected to

3. Steps for firmware development

The firmware development can be classified to a 4 sections, which are:

1. Define sensor library

Some of the sensors available in the market required additional library provided by the sensor
manufacturer to configure the sensor so that it can operate properly. Hence, it is mandatory to
define the sensors’ library at the beginning of code.

Sensor that required additional library: DHT11


Additional library required: DHT.h [download from: Arduino IDE -> Sketch -> Include
Library -> Manage Libraries -> search for “DHT sensor library by Adafruit” and click to
download]

2. Define pin connection of sensor & variable

The pin number in which the sensors are connected to are required to be defined in this
section so that the program know which port should the signal receive from/send to.

Also, the variables to be used in the program should be defined in this section too.

3. Initialize the board

This section initializes the board with pin configurations and serial port enablement when the
board is power up. It will only run for once in the whole power up cycle.
4. Main functional code

This section is the main functional code of the program where it will keep on looping as long
as the board is still power up. The main functional code includes receive data from sensors,
and send output to receiver such as LED and buzzer.

The algorithm for this work is that the board will read in data from temperature sensor,
humidity sensor and gas sensor every 5 seconds. While for motion detection and door state
detection, the board will always read in data from PIR sensor and contact switch to give
reaction immediately when signals are detected.

Coding for temperature sensor:

Coding for humidity sensor:

Coding for gas sensor:


Coding for PIR sensor and contact switch:
Complete coding: [link]

4. Steps for hardware development

Sensors used in this work and their pins connection to Nucleo F446RE board:

1. LM35 Temperature Sensor

Pins connection to Nucleo F446RE board:


LM35 Nucleo F446RE board
+ VCC
– GND
OUT A0

2. DHT11 Humidity Sensor

Pins connection to Nucleo F446RE board:


DHT11 Nucleo F446RE board
+ VCC
– GND
OUT 2

3. MQ2 Gas Sensor (to measure smoke concentration and hence detect fire incident)

Pins connection to Nucleo F446RE board:


MQ2 Nucleo F446RE board
VCC VCC
GND GND
DO noConn
AD A1

4. PIR (Passive Infra Red) Sensor (for motion detection to automatically control ON and OFF of
lighting)
Pins connection to Nucleo F446RE board:
PIR sensor Nucleo F446RE board
+ VCC
– GND
OUT 8

5. Contact Switch (for door open/close detection)

Pins connection to Nucleo F446RE board:


Contact switch Nucleo F446RE board
wire 1 13
wire 2 GND

Complete setup of the hardware:

You might also like