import time
import random
class Bluetooth:
def __init__(self, name="ESP32_BT"):
self.name = name
def start(self):
print(f"[BT] Bluetooth device '{self.name}' is now ON and discoverable.")
def connect(self, device="Smartphone"):
print(f"[BT] {device} connected to {self.name}.")
def send(self, msg):
print(f"[BT] Sent to phone: {msg}")
bluetooth = Bluetooth()
bluetooth.start()
# Simulated smartphone connection
time.sleep(1)
bluetooth.connect()
# Loop to send fake sensor data
while True:
sensor_value = random.randint(20, 40)
bluetooth.send(f"Sensor Value: {sensor_value}")
time.sleep(1)