Professional Documents
Culture Documents
Software/Tools setup
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:
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.
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.
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.
Sensors used in this work and their pins connection to Nucleo F446RE board:
3. MQ2 Gas Sensor (to measure smoke concentration and hence detect fire incident)
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