unfolder 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- unfolder/__init__.py +6 -0
- unfolder/__main__.py +35 -0
- unfolder/data/LDR_DHT22_COMBINED.txt +82 -0
- unfolder/data/Q01_DHT_Sensor.txt +77 -0
- unfolder/data/Q02_LDR_Sensor.txt +70 -0
- unfolder/data/Q03_PIR_Sensor.txt +64 -0
- unfolder/data/Q04_DHT_MQTT.txt +181 -0
- unfolder/data/Q05_REST_API_Supabase.txt +283 -0
- unfolder/data/Q06_MQTT_Supabase.txt +376 -0
- unfolder/data/Q07_ThingsBoard_MQTT.txt +116 -0
- unfolder/data/Q08_CoAP_Server_Client.txt +277 -0
- unfolder/data/Q09_MQTT_HiveMQ_Mosquitto.txt +179 -0
- unfolder/data/Q10_CoAP_OpenMeteo_Supabase.txt +504 -0
- unfolder/data/Q11_ISS_Tracking.txt +108 -0
- unfolder/data/Q12_Earthquake_Analysis.txt +275 -0
- unfolder/data/Q13_Weather_Analysis.txt +126 -0
- unfolder/data/Q14_Air_Quality_Analysis.txt +138 -0
- unfolder/data/Q15_Decision_Tree_Occupancy.txt +133 -0
- unfolder/data/Q16_Linear_Regression_Temperature.txt +158 -0
- unfolder/data/Q17_Random_Forest_Air_Quality.txt +173 -0
- unfolder/data/temp.txt +3266 -0
- unfolder/downloader.py +41 -0
- unfolder-0.1.0.dist-info/METADATA +79 -0
- unfolder-0.1.0.dist-info/RECORD +28 -0
- unfolder-0.1.0.dist-info/WHEEL +5 -0
- unfolder-0.1.0.dist-info/entry_points.txt +2 -0
- unfolder-0.1.0.dist-info/licenses/LICENSE +17 -0
- unfolder-0.1.0.dist-info/top_level.txt +1 -0
unfolder/__init__.py
ADDED
unfolder/__main__.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
|
|
5
|
+
from . import __version__, download
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main() -> None:
|
|
9
|
+
parser = argparse.ArgumentParser(
|
|
10
|
+
prog="unfolder",
|
|
11
|
+
description="Extract the Unfolder collection of text files.",
|
|
12
|
+
)
|
|
13
|
+
parser.add_argument("--version", action="version", version=f"unfolder {__version__}")
|
|
14
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
15
|
+
|
|
16
|
+
download_parser = subparsers.add_parser("download", help="Extract all bundled text files")
|
|
17
|
+
download_parser.add_argument(
|
|
18
|
+
"--destination",
|
|
19
|
+
"-d",
|
|
20
|
+
default=None,
|
|
21
|
+
help="Target folder (default: ./unfolder)",
|
|
22
|
+
)
|
|
23
|
+
download_parser.add_argument(
|
|
24
|
+
"--overwrite",
|
|
25
|
+
action="store_true",
|
|
26
|
+
help="Overwrite files that already exist",
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
args = parser.parse_args()
|
|
30
|
+
if args.command == "download":
|
|
31
|
+
download(args.destination, overwrite=args.overwrite)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if __name__ == "__main__":
|
|
35
|
+
main()
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
DHT sensor library
|
|
2
|
+
Adafruit Unified Sensor
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
sketch.ino:
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
#include <DHT.h>
|
|
9
|
+
|
|
10
|
+
#define DHTPIN 4
|
|
11
|
+
#define DHTTYPE DHT22
|
|
12
|
+
#define LDRPIN 34
|
|
13
|
+
|
|
14
|
+
DHT dht(DHTPIN, DHTTYPE);
|
|
15
|
+
|
|
16
|
+
void setup() {
|
|
17
|
+
Serial.begin(115200);
|
|
18
|
+
dht.begin();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
void loop() {
|
|
22
|
+
float temperature = dht.readTemperature();
|
|
23
|
+
float humidity = dht.readHumidity();
|
|
24
|
+
|
|
25
|
+
int light = analogRead(LDRPIN);
|
|
26
|
+
|
|
27
|
+
Serial.println("--------------------");
|
|
28
|
+
|
|
29
|
+
Serial.print("Temperature: ");
|
|
30
|
+
Serial.print(temperature);
|
|
31
|
+
Serial.println(" C");
|
|
32
|
+
|
|
33
|
+
Serial.print("Humidity: ");
|
|
34
|
+
Serial.print(humidity);
|
|
35
|
+
Serial.println(" %");
|
|
36
|
+
|
|
37
|
+
Serial.print("Light Reading: ");
|
|
38
|
+
Serial.println(light);
|
|
39
|
+
|
|
40
|
+
if (light > 500) {
|
|
41
|
+
Serial.println("Room: DARK");
|
|
42
|
+
Serial.println("Status: COMFY");
|
|
43
|
+
} else {
|
|
44
|
+
Serial.println("Room: BRIGHT");
|
|
45
|
+
Serial.println("Status: NOT COMFORTABLE");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
delay(2000);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
diagram.json:
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
{
|
|
56
|
+
"version": 1,
|
|
57
|
+
"author": "",
|
|
58
|
+
"editor": "wokwi",
|
|
59
|
+
"parts": [
|
|
60
|
+
{ "type": "board-esp32-devkit-c-v4", "id": "esp", "top": 0, "left": 0, "attrs": {} },
|
|
61
|
+
{ "type": "wokwi-dht22", "id": "dht1", "top": 0.3, "left": -111, "attrs": {} },
|
|
62
|
+
{
|
|
63
|
+
"type": "wokwi-photoresistor-sensor",
|
|
64
|
+
"id": "ldr1",
|
|
65
|
+
"top": -73.6,
|
|
66
|
+
"left": 77.6,
|
|
67
|
+
"attrs": {}
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"connections": [
|
|
71
|
+
[ "esp:TX", "$serialMonitor:RX", "", [] ],
|
|
72
|
+
[ "esp:RX", "$serialMonitor:TX", "", [] ],
|
|
73
|
+
[ "dht1:VCC", "esp:3V3", "red", [] ],
|
|
74
|
+
[ "dht1:GND", "esp:GND.1", "black", [] ],
|
|
75
|
+
[ "dht1:SDA", "esp:4", "green", [] ],
|
|
76
|
+
[ "ldr1:VCC", "esp:3V3", "red", [] ],
|
|
77
|
+
[ "ldr1:GND", "esp:GND.1", "black", [] ],
|
|
78
|
+
[ "ldr1:AO", "esp:34", "blue", [] ]
|
|
79
|
+
],
|
|
80
|
+
"dependencies": {
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
DHT sensor library
|
|
2
|
+
Adafruit Unified Sensor
|
|
3
|
+
|
|
4
|
+
1.Develop an ESP32 program to read temperature and humidity values using a DHT22 sensor and display the readings using serial communication.
|
|
5
|
+
|
|
6
|
+
sketch.ino:
|
|
7
|
+
|
|
8
|
+
#include "DHT.h"
|
|
9
|
+
|
|
10
|
+
#define DHTPIN 4
|
|
11
|
+
#define DHTTYPE DHT22
|
|
12
|
+
|
|
13
|
+
DHT dht(DHTPIN, DHTTYPE);
|
|
14
|
+
|
|
15
|
+
void setup() {
|
|
16
|
+
Serial.begin(115200);
|
|
17
|
+
|
|
18
|
+
dht.begin();
|
|
19
|
+
|
|
20
|
+
Serial.println("DHT22 Sensor Started");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void loop() {
|
|
24
|
+
float humidity = dht.readHumidity();
|
|
25
|
+
float temperature = dht.readTemperature();
|
|
26
|
+
|
|
27
|
+
if (isnan(humidity) || isnan(temperature)) {
|
|
28
|
+
Serial.println("Failed to read from DHT22 sensor!");
|
|
29
|
+
delay(2000);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Serial.print("Temperature: ");
|
|
34
|
+
Serial.print(temperature);
|
|
35
|
+
Serial.println(" °C");
|
|
36
|
+
|
|
37
|
+
Serial.print("Humidity: ");
|
|
38
|
+
Serial.print(humidity);
|
|
39
|
+
Serial.println(" %");
|
|
40
|
+
|
|
41
|
+
Serial.println("--------------------");
|
|
42
|
+
|
|
43
|
+
delay(2000);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
diagram.json:
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
{
|
|
50
|
+
"version": 1,
|
|
51
|
+
"author": "",
|
|
52
|
+
"editor": "wokwi",
|
|
53
|
+
"parts": [
|
|
54
|
+
{
|
|
55
|
+
"type": "board-esp32-devkit-c-v4",
|
|
56
|
+
"id": "esp",
|
|
57
|
+
"top": 0,
|
|
58
|
+
"left": 0,
|
|
59
|
+
"attrs": {}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"type": "wokwi-dht22",
|
|
63
|
+
"id": "dht",
|
|
64
|
+
"top": -20,
|
|
65
|
+
"left": 200,
|
|
66
|
+
"attrs": {}
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"connections": [
|
|
70
|
+
["esp:TX", "$serialMonitor:RX", "", []],
|
|
71
|
+
["esp:RX", "$serialMonitor:TX", "", []],
|
|
72
|
+
["dht:VCC", "esp:3V3", "red", []],
|
|
73
|
+
["dht:GND", "esp:GND.1", "black", []],
|
|
74
|
+
["dht:SDA", "esp:4", "green", []]
|
|
75
|
+
],
|
|
76
|
+
"dependencies": {}
|
|
77
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
DHT sensor library
|
|
2
|
+
Adafruit Unified Sensor
|
|
3
|
+
|
|
4
|
+
2.Develop an ESP32 program to read light intensity using an LDR module and display the readings using serial communication.
|
|
5
|
+
|
|
6
|
+
sketch.ino:
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#define LDR_PIN 34
|
|
10
|
+
|
|
11
|
+
void setup() {
|
|
12
|
+
Serial.begin(115200);
|
|
13
|
+
|
|
14
|
+
Serial.println("LDR Sensor Started");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void loop() {
|
|
18
|
+
int lightValue = analogRead(LDR_PIN);
|
|
19
|
+
|
|
20
|
+
Serial.print("Light Intensity: ");
|
|
21
|
+
Serial.println(lightValue);
|
|
22
|
+
|
|
23
|
+
if (lightValue < 1500) {
|
|
24
|
+
Serial.println("Low Light");
|
|
25
|
+
}
|
|
26
|
+
else if (lightValue < 3000) {
|
|
27
|
+
Serial.println("Medium Light");
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
Serial.println("High Light");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Serial.println("--------------------");
|
|
34
|
+
|
|
35
|
+
delay(1000);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
diagram.json:
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
{
|
|
43
|
+
"version": 1,
|
|
44
|
+
"author": "",
|
|
45
|
+
"editor": "wokwi",
|
|
46
|
+
"parts": [
|
|
47
|
+
{
|
|
48
|
+
"type": "board-esp32-devkit-c-v4",
|
|
49
|
+
"id": "esp",
|
|
50
|
+
"top": 0,
|
|
51
|
+
"left": 0,
|
|
52
|
+
"attrs": {}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"type": "wokwi-photoresistor-sensor",
|
|
56
|
+
"id": "ldr",
|
|
57
|
+
"top": -20,
|
|
58
|
+
"left": 200,
|
|
59
|
+
"attrs": {}
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"connections": [
|
|
63
|
+
["esp:TX", "$serialMonitor:RX", "", []],
|
|
64
|
+
["esp:RX", "$serialMonitor:TX", "", []],
|
|
65
|
+
["ldr:VCC", "esp:3V3", "red", []],
|
|
66
|
+
["ldr:GND", "esp:GND.1", "black", []],
|
|
67
|
+
["ldr:AO", "esp:34", "green", []]
|
|
68
|
+
],
|
|
69
|
+
"dependencies": {}
|
|
70
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
DHT sensor library
|
|
2
|
+
Adafruit Unified Sensor
|
|
3
|
+
|
|
4
|
+
3.Develop an ESP32 program to detect motion using a PIR sensor and display the detection status using serial communication.
|
|
5
|
+
|
|
6
|
+
sketch.ino:
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#define PIR_PIN 4
|
|
10
|
+
|
|
11
|
+
void setup() {
|
|
12
|
+
Serial.begin(115200);
|
|
13
|
+
|
|
14
|
+
pinMode(PIR_PIN, INPUT);
|
|
15
|
+
|
|
16
|
+
Serial.println("PIR Motion Detection Started");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void loop() {
|
|
20
|
+
int motion = digitalRead(PIR_PIN);
|
|
21
|
+
|
|
22
|
+
if (motion == HIGH) {
|
|
23
|
+
Serial.println("Motion Detected!");
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
Serial.println("No Motion");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
delay(1000);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
diagram.json:
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
{
|
|
37
|
+
"version": 1,
|
|
38
|
+
"author": "",
|
|
39
|
+
"editor": "wokwi",
|
|
40
|
+
"parts": [
|
|
41
|
+
{
|
|
42
|
+
"type": "board-esp32-devkit-c-v4",
|
|
43
|
+
"id": "esp",
|
|
44
|
+
"top": 0,
|
|
45
|
+
"left": 0,
|
|
46
|
+
"attrs": {}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"type": "wokwi-pir-motion-sensor",
|
|
50
|
+
"id": "pir",
|
|
51
|
+
"top": -20,
|
|
52
|
+
"left": 200,
|
|
53
|
+
"attrs": {}
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"connections": [
|
|
57
|
+
["esp:TX", "$serialMonitor:RX", "", []],
|
|
58
|
+
["esp:RX", "$serialMonitor:TX", "", []],
|
|
59
|
+
["pir:VCC", "esp:3V3", "red", []],
|
|
60
|
+
["pir:GND", "esp:GND.1", "black", []],
|
|
61
|
+
["pir:OUT", "esp:4", "green", []]
|
|
62
|
+
],
|
|
63
|
+
"dependencies": {}
|
|
64
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
DHT sensor library
|
|
2
|
+
Adafruit Unified Sensor
|
|
3
|
+
|
|
4
|
+
4.Develop an ESP32 program to read temperature and humidity data and publish it to an MQTT broker, and develop a Python subscriber program to receive and display the published data.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
pip install paho-mqtt
|
|
8
|
+
|
|
9
|
+
sketch.ino:
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
#include <WiFi.h>
|
|
13
|
+
#include <PubSubClient.h>
|
|
14
|
+
#include "DHT.h"
|
|
15
|
+
|
|
16
|
+
// DHT22 configuration
|
|
17
|
+
#define DHTPIN 4
|
|
18
|
+
#define DHTTYPE DHT22
|
|
19
|
+
|
|
20
|
+
DHT dht(DHTPIN, DHTTYPE);
|
|
21
|
+
|
|
22
|
+
// WiFi configuration
|
|
23
|
+
const char* ssid = "Wokwi-GUEST";
|
|
24
|
+
const char* password = "";
|
|
25
|
+
|
|
26
|
+
// MQTT broker configuration
|
|
27
|
+
const char* mqtt_server = "test.mosquitto.org";
|
|
28
|
+
const int mqtt_port = 1883;
|
|
29
|
+
const char* topic = "iot/dht22";
|
|
30
|
+
|
|
31
|
+
WiFiClient espClient;
|
|
32
|
+
PubSubClient client(espClient);
|
|
33
|
+
|
|
34
|
+
void connectWiFi() {
|
|
35
|
+
Serial.print("Connecting to WiFi");
|
|
36
|
+
|
|
37
|
+
WiFi.begin(ssid, password, 6);
|
|
38
|
+
|
|
39
|
+
while (WiFi.status() != WL_CONNECTED) {
|
|
40
|
+
delay(500);
|
|
41
|
+
Serial.print(".");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Serial.println("\nWiFi Connected!");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void reconnectMQTT() {
|
|
48
|
+
while (!client.connected()) {
|
|
49
|
+
Serial.print("Connecting to MQTT...");
|
|
50
|
+
|
|
51
|
+
if (client.connect("ESP32_DHT22_Publisher")) {
|
|
52
|
+
Serial.println("Connected!");
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
Serial.print("Failed, state: ");
|
|
56
|
+
Serial.println(client.state());
|
|
57
|
+
delay(2000);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void setup() {
|
|
63
|
+
Serial.begin(115200);
|
|
64
|
+
|
|
65
|
+
dht.begin();
|
|
66
|
+
|
|
67
|
+
connectWiFi();
|
|
68
|
+
|
|
69
|
+
client.setServer(mqtt_server, mqtt_port);
|
|
70
|
+
|
|
71
|
+
Serial.println("DHT22 MQTT Publisher Started");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
void loop() {
|
|
75
|
+
if (!client.connected()) {
|
|
76
|
+
reconnectMQTT();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
client.loop();
|
|
80
|
+
|
|
81
|
+
float temperature = dht.readTemperature();
|
|
82
|
+
float humidity = dht.readHumidity();
|
|
83
|
+
|
|
84
|
+
if (isnan(temperature) || isnan(humidity)) {
|
|
85
|
+
Serial.println("DHT22 Read Failed!");
|
|
86
|
+
delay(2000);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
String payload = "{";
|
|
91
|
+
payload += "\"temperature\":" + String(temperature, 2) + ",";
|
|
92
|
+
payload += "\"humidity\":" + String(humidity, 2);
|
|
93
|
+
payload += "}";
|
|
94
|
+
|
|
95
|
+
if (client.publish(topic, payload.c_str())) {
|
|
96
|
+
Serial.print("Published: ");
|
|
97
|
+
Serial.println(payload);
|
|
98
|
+
|
|
99
|
+
} else {
|
|
100
|
+
Serial.println("MQTT publish failed!");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
delay(5000);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
diagram.json:
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
{
|
|
111
|
+
"version": 1,
|
|
112
|
+
"author": "",
|
|
113
|
+
"editor": "wokwi",
|
|
114
|
+
"parts": [
|
|
115
|
+
{
|
|
116
|
+
"type": "board-esp32-devkit-c-v4",
|
|
117
|
+
"id": "esp",
|
|
118
|
+
"top": 0,
|
|
119
|
+
"left": 0,
|
|
120
|
+
"attrs": {}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"type": "wokwi-dht22",
|
|
124
|
+
"id": "dht",
|
|
125
|
+
"top": -20,
|
|
126
|
+
"left": 200,
|
|
127
|
+
"attrs": {}
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"connections": [
|
|
131
|
+
["esp:TX", "$serialMonitor:RX", "", []],
|
|
132
|
+
["esp:RX", "$serialMonitor:TX", "", []],
|
|
133
|
+
["dht:VCC", "esp:3V3", "red", []],
|
|
134
|
+
["dht:GND", "esp:GND.1", "black", []],
|
|
135
|
+
["dht:SDA", "esp:4", "green", []]
|
|
136
|
+
],
|
|
137
|
+
"dependencies": {}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
subscriber.py:
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
import paho.mqtt.client as mqtt
|
|
144
|
+
|
|
145
|
+
# MQTT broker configuration
|
|
146
|
+
BROKER = "test.mosquitto.org"
|
|
147
|
+
PORT = 1883
|
|
148
|
+
TOPIC = "iot/dht22"
|
|
149
|
+
|
|
150
|
+
# Callback when connected
|
|
151
|
+
def on_connect(client, userdata, flags, reason_code, properties):
|
|
152
|
+
if reason_code.is_failure:
|
|
153
|
+
print("Connection failed:", reason_code)
|
|
154
|
+
return
|
|
155
|
+
|
|
156
|
+
print("Connected to MQTT Broker!")
|
|
157
|
+
client.subscribe(TOPIC)
|
|
158
|
+
print("Subscribed to:", TOPIC)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
# Callback when a message arrives
|
|
162
|
+
def on_message(client, userdata, msg):
|
|
163
|
+
print("\nReceived MQTT Message:")
|
|
164
|
+
print(msg.payload.decode())
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
# Create MQTT client using Paho MQTT 2.x callback API
|
|
168
|
+
client = mqtt.Client(
|
|
169
|
+
callback_api_version=mqtt.CallbackAPIVersion.VERSION2
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
client.on_connect = on_connect
|
|
173
|
+
client.on_message = on_message
|
|
174
|
+
|
|
175
|
+
# Connect to broker
|
|
176
|
+
client.connect(BROKER, PORT, 60)
|
|
177
|
+
|
|
178
|
+
print("Waiting for sensor data...")
|
|
179
|
+
|
|
180
|
+
# Keep receiving messages
|
|
181
|
+
client.loop_forever()
|