Become a leader in the IoT community!
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Hello guys ahv gotten to a new stage on my project simple temperature monitoring system using `MicroPython` on a `Zephyr` `RTOS`-supported microcontroller, such as the `ESP32`, and transmit the data over `Bluetooth` Low Energy (BLE) to a mobile app. Am currently transmit the temperature and humidity data over Bluetooth Low Energy (BLE) from the `ESP32` to a mobile app but `BLE` fails to advertise or the mobile app does not detect the `ESP32`.
Here’s my code
import bluetooth
from machine import Pin
import dht
sensor = dht.DHT11(Pin(4))
ble = bluetooth.BLE()
ble.active(True)
def advertise():
adv_data = b'x02x01x06' + b'x03x03xaaxfe'
ble.gap_advertise(100, adv_data)
def send_data(temp, hum):
data = "Temp: {}Β°C, Hum: {}%".format(temp, hum)
ble.gatts_notify(0, 0, data.encode('utf-8'))
advertise()
while True:
sensor.measure()
temp = sensor.temperature()
hum = sensor.humidity()
send_data(temp, hum)
CONTRIBUTE TO THIS THREAD