An Embedded Machine learning-based project was used to detect fire using the inbuilt colour sensor.

Description
It’s an embedded machine learning-based project used to predict a fire in Arduino nano ble 33 sense with the help of the inbuilt color sensor attached to the board and if the fire has been detected a buzzer is switched on. It is far better than a typical flame and smoke sensor as one uses a heating effect and another uses a good amount of smoke to predict fire but this uses the RGB value to detect fire which is more accurate than the previous 2. I have used the inbuilt colour sensor in the newly launched Arduino nano ble 33 sense which s a mbed os board.
First, i collected the RGB value data of my room without lighting any candle and then by lighting a candle and made 2 datasets for training my Neural network model and then the model was implemented in the microcontroller to predict a fire with high accuracy.
Arduino nano ble 33 sense
The Nano 33 BLE Sense (without headers) is Arduino’s 3.3V AI-enabled board in the smallest available form factor: 45x18mm!
The Arduino Nano 33 BLE Sense is a completely new board on a well-known form factor. It comes with a series of embedded sensors:
- 9 axis inertial sensor: what makes this board ideal for wearable devices
- humidity, and temperature sensor: to get highly accurate measurements of the environmental conditions
- barometric sensor: you could make a simple weather station
- microphone: to capture and analyse sound in real-time
- gesture, proximity, light colour and light intensity sensor: estimate the room’s luminosity, but also whether someone is moving close to the board
Colour sensor

In this project, we have to create 3 programs one for data capture, one for training our model and one for implementing our model to predict fire.
1) Data Capture
- First, we need to include the APDS9960 library that will allow us to control the sensor. To do so, we need to add the following portion of code before the setup().
- We will keep the setup() section as it is, on it we have the ADPS.begin() within an if statement. This initializes the colour sensor and will print a message in the Serial Monitor in case the sensor has not been successfully initialized. This string can be any message of your choice. then print the header ie “RED, GREEN, BLUE” for our dataset headers.


- After writing the program just upload it to the board and open the serial monitor.
- for collecting data with no fire just move the board in your room and the serial monitor should look like the below image





- Make sure to make 2 separate datasets for our training the model containing data of nofire and fire RGB values
2) Training our model
- For training our model our first task is to upload the datasets into our google collaboratory



Now we have to set up the environment in collab with installing required libraries and Tensorflow






Define the model




3) Implementing our trained model in ble sense
- The first task is to create a new ARDUINO project and copy the model.h file into the folder


First, we need to include the APDS9960 library that will allow us to control the sensor and the TensorFlow lite library along with the tflite global parameters and all the variables for the model. To do so, we need to add the following portion of code before the setup().




