This guide will help you create an IoT-Based Anti-theft Flooring System using Raspberry Pi. The system will detect unauthorized access through floor sensors and alert you in real-time by sending notifications to the cloud.

Components Required

  • Raspberry Pi (Model 3 or later)
  • Pressure sensors or force-sensitive resistors (FSRs)
  • Relay module (for triggering alarms or notifications)
  • Connecting wires and breadboard
  • Power supply (for Raspberry Pi)
  • Cloud service account (e.g., ThingSpeak, Blynk, or AWS IoT)
  • Buzzer or alarm (optional, for local alerts)

Setting Up the Hardware

Follow these steps to set up the hardware:

  1. Connect the Pressure Sensors

    Place the pressure sensors or FSRs under the flooring in the areas you want to monitor. Connect these sensors to the Raspberry Pi using the GPIO pins. The sensors will output an analog signal that can be read by the Raspberry Pi.

  2. Integrate the Relay Module

    Connect the relay module to the Raspberry Pi. The relay can be used to trigger an alarm or notification if unauthorized access is detected.

  3. Power the System

    Ensure the Raspberry Pi and other components are properly powered using the appropriate power supplies.

Programming the Raspberry Pi

Write the code to read data from the pressure sensors and send alerts to the cloud. Below is a basic outline of the code using Python:


                import RPi.GPIO as GPIO
                import time
                import requests

                # Configuration
                PRESSURE_SENSOR_PIN = 18
                RELAY_PIN = 23
                CLOUD_URL = "https://api.thingspeak.com/update?api_key=YOUR_API_KEY"

                # Setup
                GPIO.setmode(GPIO.BCM)
                GPIO.setup(PRESSURE_SENSOR_PIN, GPIO.IN)
                GPIO.setup(RELAY_PIN, GPIO.OUT)

                def send_alert():
                    response = requests.get(CLOUD_URL + "&field1=1")
                    print(f"Alert sent to cloud: {response.status_code}")

                try:
                    while True:
                        if GPIO.input(PRESSURE_SENSOR_PIN):
                            print("Pressure detected!")
                            GPIO.output(RELAY_PIN, GPIO.HIGH)
                            send_alert()
                            time.sleep(10)  # Wait before next check
                        else:
                            GPIO.output(RELAY_PIN, GPIO.LOW)
                        time.sleep(0.1)  # Adjust as necessary for your application

                except KeyboardInterrupt:
                    GPIO.cleanup()
            

This code monitors the pressure sensor. If pressure is detected (indicating potential unauthorized access), it triggers the relay and sends an alert to the cloud service.

Setting Up Cloud Integration

To visualize and receive notifications, integrate the system with a cloud service. Configure your cloud service to receive data from the Raspberry Pi and set up notifications or alerts based on the data received.

Testing and Calibration

Test the system by simulating pressure on the sensors and verifying that the alerts are correctly sent to the cloud and that the relay triggers as expected. Adjust the sensor sensitivity and code parameters as needed for reliable performance.

Conclusion

The IoT-Based Anti-theft Flooring System provides a robust solution for detecting unauthorized access through flooring. By integrating pressure sensors with Raspberry Pi and cloud services, this system ensures real-time monitoring and alerts, enhancing security.