ecobin · sensore BLE · 2026
Monitoraggio del riempimento via BLE
Sensore per cestini smart: un sensore a ultrasuoni misura il livello dei rifiuti e un SoC TI CC26xx lo trasmette via Bluetooth Low Energy a un'app Android. Progettazione della PCB in Cadence OrCAD e firmware C a bassissimo consumo, ripartito tra core ARM e Sensor Controller.
C · Kotlin · github.com/bobbisasha/prj13_board_firmware
static void scTaskAlertCallback(void) {
static uint8_t packet[4];
static uint8_t packetIndex = 0;
scifClearAlertIntSource();
uint32_t count = scifUartGetRxFifoCount();
while (count > 0) {
uint8_t b = (uint8_t)scifUartRxGetChar();
count--;
if (packetIndex == 0) {
if (b == 0xFF) {
packet[0] = b;
packetIndex++;
}
} else {
packet[packetIndex++] = b;
if (packetIndex == 4) {
if (((packet[0] + packet[1] + packet[2]) & 0xFF) == packet[3]) {
scSensorPayload[0] = packet[1];
scSensorPayload[1] = packet[2];
scSensorPayload[2] = 0;
scSensorPayload[3] = 0;
scSensorPayload[4] = 0;
Event_post(syncEvent, SBP_SC_ALERT_EVT);
}
packetIndex = 0;
}
}
}
scifAckAlertEvents();
scifOsalEnableTaskAlertInt();
}
Ciclo di misura · schema non in scala
- Core ARM in sleep durante l'avvio del sensore, lettura del FIFO già pieno
- Disconnessione BLE: timer arrestato e sensore spento
Cestino 1
Connesso · live
- Distanza
- 14 cm
- Profondità
- 50 cm
Calcolo nell'app
fullness% = (depth − distance) / depth × 100
Caratteristica BLE CHAR5 · notifiche o polling · modalità demo per emulatore