Making an IoT-based intrusion detector

Now that Raspberry Pi is set up and we are ready to make it IoT enabled let's see how we are going to connect the system to the internet and make things work. Firstly, we need to connect Raspberry Pi to the devices, which we want to control using the IoT technology. So go ahead and use the following diagram to make the connection:

Once you have set up all the components, let's go ahead and upload the following code:

import timeimport paho.mqtt.client as mqttimport RPi.gpio as gpiopir = 23gpio.setmode(gpio.BCM)gpio.setup(pir, gpio.IN)client = mqtt.Client()broker="broker.hivemq.com"port = 1883pub_topic ...

Get Getting Started with Python for the Internet of Things now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.