solvaholic / micropython

@solvaholic's MicroPython scripts
MIT License
0 stars 0 forks source link

Learn how to use bluetooth #2

Closed solvaholic closed 8 months ago

solvaholic commented 9 months ago
### Tasks
- [x] Scan; Log device list ~with timestamp; Show new devices on OLED~
- [x] Pair Wifi kit 32 with Raspberry Pi; Send messages back and forth
- [ ] Pair with Timeular cube; Log event messages (does this fit in Terms?)
solvaholic commented 8 months ago

Scan; Log device list ~with timestamp; Show new devices on OLED~

Today I learned time requires a network, and/or hardware these esp32 wifi kit don't seem to have. Scan finds more devices than I want to display on OLED. While I'm curious about how to hold a list of devices and notice when they come and go, that won't move what I'm working on forward. So skip those and just understand the BLE_scan example: https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/939189487221db9dbce38edeeb24878173eda30c/esp32/libraries/BLE/examples/BLE_scan/BLE_scan.ino

solvaholic commented 8 months ago

Pair Wifi kit 32 with Raspberry Pi; Send messages back and forth

I'm thinking: The esp32 checks sensors and emits data in BLE advertisements, RPi receives and logs those. This covers one approach: https://tutorials-raspberrypi.com/esp32-bluetooth-connection-to-esp8266-and-raspberry-pi/

edit: I'm thinking :point_that: because I'd read about it in Python Playground, 2nd Edition chapter 14: https://nostarch.com/python-playground-2nd-edition

and forth

What if I want the esp32 to operate some 12V accessories - and be remote-controllable? esp32 emits accessory states alongside sensor data; RPi sends accessory states to esp32 somehow; esp32 makes those states true. Is there a safe way to do that?

solvaholic commented 8 months ago

Pair Wifi kit 32 with Raspberry Pi; Send messages back and forth

b2d5fec adds ble_server.ino, which hosts a BLE server that advertises an attribute with a read/write characteristic. Using the nRF Connect app, I think I need to Connect before reading or writing the characteristic. I think it should be possible to include sensor data in the advertisement, so it can be read passively and collected on the Pi.

For now, tho, just learn how to read and write this data from the Raspberry Pi. Here's one way to set that up: https://www.argenox.com/library/bluetooth-low-energy/using-raspberry-pi-ble/

solvaholic commented 8 months ago

For now, tho, just learn how to read and write this data from the Raspberry Pi.

497014b adds notes about how I did this, in rpi_setup.md.