Initial commit

This commit is contained in:
Rafal Zajac
2017-11-12 22:49:10 +01:00
commit 74d0876c59
39 changed files with 2503 additions and 0 deletions

View File

@ -0,0 +1,37 @@
# Copyright 2017 Rafal Zajac <rzajac@gmail.com>.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
find_package(esp_sdo REQUIRED)
find_package(esp_ow REQUIRED)
find_package(esp_eb REQUIRED)
find_package(esp_util REQUIRED)
add_executable(ds18b20_search main.c ${ESP_USER_CONFIG})
target_include_directories(ds18b20_search PUBLIC
${ESP_USER_CONFIG_DIR}
${esp_sdo_INCLUDE_DIRS}
${esp_ow_INCLUDE_DIRS}
${esp_eb_INCLUDE_DIRS}
${esp_util_INCLUDE_DIRS})
target_link_libraries(ds18b20_search
${esp_sdo_LIBRARIES}
${esp_ow_LIBRARIES}
${esp_eb_LIBRARIES}
${esp_util_LIBRARIES}
esp_ds18b20)
esp_gen_exec_targets(ds18b20_search)

View File

@ -0,0 +1,12 @@
## Find DS18b20 devices.
Demonstrates how to search OneWire bus for DS18b20.
## Flashing
```
$ cd build
$ cmake ..
$ make ds18b20_search_flash
$ miniterm.py /dev/ttyUSB0 74880
```

View File

@ -0,0 +1,55 @@
/*
* Copyright 2017 Rafal Zajac <rzajac@gmail.com>.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#include <user_interface.h>
#include <osapi.h>
#include <esp_ds18b20.h>
#include <esp_gpio.h>
#include <esp_sdo.h>
// List of found devices on the OneWire bus.
static esp_ow_device *root = NULL;
static void ICACHE_FLASH_ATTR
sys_init_done()
{
esp_ow_err err;
if (esp_ds18b20_init(GPIO2) == false) {
os_printf("Error initializing DS18B20.\n");
return;
}
err = esp_ds18b20_search(GPIO2, false, &root);
if (err != ESP_OW_OK) {
os_printf("Search error: %d\n", err);
return;
}
// Log found devices to serial.
esp_ow_dump_found(root);
}
void ICACHE_FLASH_ATTR
user_init()
{
// No need for wifi for this examples.
wifi_station_disconnect();
wifi_set_opmode_current(NULL_MODE);
stdout_init(BIT_RATE_74880);
system_init_done_cb(sys_init_done);
}