I need to use a Dallas 1wire iButton, which has only a read only id. I found a library for 1wire from David Antliff. I used this simple code:
Code: Select all
static void ibutton_task(void *param) {
OneWireBus_SearchState search_state = {0};
if (!owb)
LOGD(TAG, "owb is null");
vTaskDelay(5000);
owb_rmt_driver_info rmt_driver_info;
owb=owb_rmt_initialize(&rmt_driver_info, GPIO_I_BUTTON, RMT_CHANNEL_1, RMT_CHANNEL_0);
owb_use_crc(owb, true);
while(1) {
bool found = false;
owb_search_first(owb, &search_state, &found);
if (found) {
LOGD(TAG, "found");
char rom_code[17];
owb_string_from_rom_code(search_state.rom_code, rom_code, sizeof(rom_code));
LOGD(TAG, "code:%s", rom_code);
}
vTaskDelay(pdMS_TO_TICKS(IBUTTON_TASK_DELAY_MS));
}
}
It works but it frequently generates an error:
E (917646) owb_rmt: rx_items == 0
E (932086) rmt: RMT RX BUFFER FULL
E (932086) rmt: RMT RX BUFFER FULL
Is there an example for getting device id only from an ibutton?
thx
Zamek