Code Monkey home page Code Monkey logo

esp32-tutorial's Introduction

esp32-tutorial's People

Contributors

lucadentella avatar rosld avatar tonyp7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp32-tutorial's Issues

spiffs does not compile

home/thomas/projekte/esp32-tutorial/16_spiffs/components/spiffs/./spiffs_vfs.c: In function 'vfs_spiffs_register':
/home/thomas/projekte/esp32-tutorial/16_spiffs/components/spiffs/./spiffs_vfs.c:836:9: error: unknown field 'fd_offset' specified in initializer
         .fd_offset = 0,
         ^
In file included from /home/thomas/projekte/esp32-tutorial/16_spiffs/components/spiffs/./spiffs_vfs.c:24:0:
/home/thomas/projekte/esp32/esp-idf/components/vfs/include/esp_vfs.h:39:37: warning: initialized field overwritten [-Woverride-init]

Certificate for HTTPS

How do I get the SSL certificate? I am hosting my webpage on Azure and use Cloudflare as a proxy. Can I just generate an certificate with openssl?

21_mqtt: mqtt automatic reconnection issue

Hello, nice example!

I just have an issue that the mqtt automatic reconnection is not working. I think it is the while loop that prevents the disconnect callback so the mqtt client is never making a reconnection

I did set the .auto_reconnect = true and it works if I just comment out the while loop

So instead I believe that the sensor readings using the while loop and mqtt publishing maybe should be moved to a separate task - My initial tests seems to work but the last bit I cannot find out, the mqtt publishing from inside the task

So my code below looks something like this (simplified and using a temperatur sensor) and it builds correctly but it crashes when the mqtt publishing happens

  1. program starts correctly, mqtt client connects, xtask is created, sensor temperature is read correctly
  2. mqtt publishing -> crash
  3. I guess something goes wrong with pointer/address in data
  4. if I run the code without mqtt publishing, everything works fine, if I restart mqtt broker, the program reconnects perfectly
  5. happy for any suggestion how to make mqtt publishing correct instead, maybe putting it into a separate function?

Best regards, Walter

bool mqtt_conn = false;


void read_temp(void *data)
{
    while(mqtt_conn)
    {
        float rt = ds18b20_get_temp();
        char temp_string[10];
        sprintf(temp_string, "%.1f", rt);
        printf("%s\n",temp_string);
        mqtt_publish(data, "/room/temperature", temp_string, strlen(temp_string), 0, 0);
        vTaskDelay(5000 / portTICK_RATE_MS);

    }
    vTaskDelete( NULL );
}


// MQTT connected callback
void mqtt_connected_callback(mqtt_client *client, mqtt_event_data_t *event_data)
{
    printf(" connected!\n");
    mqtt_conn = true;
    xTaskCreate(&read_temp, "read_temp_task", 10000, &client, 5, NULL);
}


// MQTT disconnected callback
void mqtt_disconnected_callback(mqtt_client *client, mqtt_event_data_t *event_data)
{
    printf("MQTT disconnected!\n");
    mqtt_conn = false;
}

23_ap_http example: Make errors at IDF Stable version 3.2

Hello.

I'm using Your example 23_ap_http (HTTP server + SoftAP mode) and tries to run it on ESP-WROOM-32, but when i compiles it using IDF Stable 3.2 there were some errors and warnings:

$ make flash -j2
Toolchain path: /opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a5
Compiler version: 5.2.0
Python requirements from C:/msys32/home/Laptop_1/esp/esp-idf/requirements.txt ar e satisfied.
CC build/main/main.o
C:/msys32/home/Laptop_1/esp/esp-idf/dd/23_ap_http/main/main.c: In function 'even t_handler':
C:/msys32/home/Laptop_1/esp/esp-idf/dd/23_ap_http/main/main.c:70:3: error: unkno wn type name 'mdns_server_t'
mdns_server_t* mDNS = NULL;
^
In file included from C:/msys32/home/Laptop_1/esp/esp-idf/components/esp32/inclu de/esp_timer.h:44:0,
from C:/msys32/home/Laptop_1/esp/esp-idf/components/freertos/in clude/freertos/portmacro.h:82,
from C:/msys32/home/Laptop_1/esp/esp-idf/components/freertos/in clude/freertos/portable.h:94,
from C:/msys32/home/Laptop_1/esp/esp-idf/components/freertos/in clude/freertos/FreeRTOS.h:105,
from C:/msys32/home/Laptop_1/esp/esp-idf/dd/23_ap_http/main/mai n.c:3:
C:/msys32/home/Laptop_1/esp/esp-idf/dd/23_ap_http/main/main.c:72:19: error: impl icit declaration of function 'mdns_set_hostname' [-Werror=implicit-function-decl aration]
ESP_ERROR_CHECK(mdns_set_hostname(mDNS, "esp32web"));
^
C:/msys32/home/Laptop_1/esp/esp-idf/components/esp32/include/esp_err.h:117:31: n ote: in definition of macro 'ESP_ERROR_CHECK'
esp_err_t __err_rc = (x);
^
C:/msys32/home/Laptop_1/esp/esp-idf/dd/23_ap_http/main/main.c:73:19: error: impl icit declaration of function 'mdns_set_instance' [-Werror=implicit-function-decl aration]
ESP_ERROR_CHECK(mdns_set_instance(mDNS, "ESP32 webserver"));
^
C:/msys32/home/Laptop_1/esp/esp-idf/components/esp32/include/esp_err.h:117:31: n ote: in definition of macro 'ESP_ERROR_CHECK'
esp_err_t __err_rc = (x);
^
C:/msys32/home/Laptop_1/esp/esp-idf/dd/23_ap_http/main/main.c: In function 'http _server_netconn_serve':
C:/msys32/home/Laptop_1/esp/esp-idf/dd/23_ap_http/main/main.c:156:11: warning: u nused variable 'method' [-Wunused-variable]
char* method = strtok(request_line, " ");
^
C:/msys32/home/Laptop_1/esp/esp-idf/dd/23_ap_http/main/main.c:143:9: warning: un used variable 'body' [-Wunused-variable]
char* body = strstr(buf, "\r\n\r\n");
^
cc1.exe: some warnings being treated as errors
make[1]: *** [/home/Laptop_1/esp/esp-idf/make/component_wrapper.mk:286: main.o] Error 1
make: *** [C:/msys32/home/Laptop_1/esp/esp-idf/make/project.mk:530: component-ma in-build] Error 2

Regards,
Jacek

Processing an I2C write from master to slave

Hello.

First of all thank you for the informative guides you made on the I2C topic. I'm following this in particular right now: http://www.lucadentella.it/en/2017/10/09/esp32-23-i2c-basic/ and I got a solid understanding of the protocol and I successfully initialized the a slave module but I need to set an ESP32 as a slave device and another microcontroller (PSOC 5) will be the master. I was wondering if you have any or know of any examples on simply processing the information sent from the master in the loop() function of the arduino IDE (which im using to program the esp32), ie, accessing the data string sent by the master and answering with the ACK.

Thank you.

undefined reference to `_binary_certs_pem_start'

Unable to get .elf file in build directory, saying undefined reference to '_binary_certs_pem_start'
Error:
~/esp/WorkSpace/build/main/libmain.a(FileName_main.o):(.literal.check_update_task+0x2c): undefined reference to `_binary_certs_pem_start'

Having trouble creating ssl certificate

Running the line of code

winpty openssl ca -config openssl.cnf -extensions server_cert -days 365 -notext -md sha256 -in csr/espserver.csr -out certs/espserver.cer

and i keep getting the error

Using configuration from openssl.cnf
Error opening CA private key /home/Hakeem/myCA/private/ca.key
9360:error:02001003:system library:fopen:No such process:bss_file.c:406:fopen('/home/Hakeem/myCA/private/ca.key','rb')
9360:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:408:
unable to load CA private key

how can I resolve this?

Tutorial 30: Memory leak after parsing JSON file

Hi Luca,

You have a memory leak here:
cJSON *json = cJSON_Parse(rcv_buffer);

You need to call the following line to free it:
cJSON_Delete(json);

Reference document for the cJSON library is here:
https://github.com/DaveGamble/cJSON


Given some JSON in a zero terminated string, you can parse it with cJSON_Parse.

cJSON *json = cJSON_Parse(string);

It will parse the JSON and allocate a tree of cJSON items that represents it. Once it returns, you are fully responsible for deallocating it after use with cJSON_Delete.

Guru Meditation Error...

I've run this example, and while it does connect to my wifi, It also keeps resetting. Here's the log, backtrace is at the bottom.

^[[0;32mI (29) boot: ESP-IDF v2.0-rc1-364-gcecdfdb 2nd stage bootloader^[[0m
^[[0;32mI (29) boot: compile time 10:03:11^[[0m
^[[0;32mI (63) boot: Enabling RNG early entropy source...^[[0m
^[[0;32mI (63) boot: SPI Speed : 40MHz^[[0m
^[[0;32mI (64) boot: SPI Mode : DIO^[[0m
^[[0;32mI (74) boot: SPI Flash Size : 4MB^[[0m
^[[0;32mI (86) boot: Partition Table:^[[0m
^[[0;32mI (98) boot: ## Label Usage Type ST Offset Length^[[0m
^[[0;32mI (120) boot: 0 nvs WiFi data 01 02 00009000 00006000^[[0m
^[[0;32mI (143) boot: 1 phy_init RF data 01 01 0000f000 00001000^[[0m
^[[0;32mI (166) boot: 2 factory factory app 00 00 00010000 00100000^[[0m
^[[0;32mI (190) boot: End of partition table^[[0m
^[[0;32mI (203) boot: Disabling RNG early entropy source...^[[0m
^[[0;32mI (220) boot: Loading app partition at offset 00010000^[[0m
^[[0;32mI (940) boot: segment 0: paddr=0x00010018 vaddr=0x00000000 size=0x0ffe8 ( 65512) ^[[0m
^[[0;32mI (941) boot: segment 1: paddr=0x00020008 vaddr=0x3f400010 size=0x08424 ( 33828) map^[[0m
^[[0;32mI (957) boot: segment 2: paddr=0x00028434 vaddr=0x3ffb0000 size=0x02494 ( 9364) load^[[0m
^[[0;32mI (987) boot: segment 3: paddr=0x0002a8d0 vaddr=0x40080000 size=0x00400 ( 1024) load^[[0m
^[[0;32mI (1010) boot: segment 4: paddr=0x0002acd8 vaddr=0x40080400 size=0x1a7f8 (108536) load^[[0m
^[[0;32mI (1088) boot: segment 5: paddr=0x000454d8 vaddr=0x400c0000 size=0x00000 ( 0) load^[[0m
^[[0;32mI (1089) boot: segment 6: paddr=0x000454e0 vaddr=0x00000000 size=0x0ab28 ( 43816) ^[[0m
^[[0;32mI (1105) boot: segment 7: paddr=0x00050010 vaddr=0x400d0018 size=0x3abf4 (240628) map^[[0m
^[[0;32mI (1131) cpu_start: Pro cpu up.^[[0m
^[[0;32mI (1143) cpu_start: Starting app cpu, entry point is 0x40080bb4^[[0m
^[[0;32mI (0) cpu_start: App cpu up.^[[0m
^[[0;32mI (1176) heap_alloc_caps: Initializing. RAM available for dynamic allocation:^[[0m
^[[0;32mI (1198) heap_alloc_caps: At 3FFAE2A0 len 00001D60 (7 KiB): DRAM^[[0m
^[[0;32mI (1219) heap_alloc_caps: At 3FFB7528 len 00028AD8 (162 KiB): DRAM^[[0m
^[[0;32mI (1240) heap_alloc_caps: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM^[[0m
^[[0;32mI (1261) heap_alloc_caps: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM^[[0m
^[[0;32mI (1283) heap_alloc_caps: At 4009ABF8 len 00005408 (21 KiB): IRAM^[[0m
^[[0;32mI (1304) cpu_start: Pro cpu start user code^[[0m
^[[0;32mI (1365) cpu_start: Starting scheduler on PRO CPU.^[[0m
^[[0;32mI (212) cpu_start: Starting scheduler on APP CPU.^[[0m
^[[0;32mI (252) phy: phy_version: 350, Mar 22 2017, 15:02:06, 1, 0^[[0m
Connecting to MYSSID
Guru Meditation Error of type LoadProhibited occurred on core 1. Exception was unhandled.
Register dump:
PC : 0x40083872 PS : 0x00060930 A0 : 0x80081a10 A1 : 0x3ffc3f00
A2 : 0xa5a5a5a5 A3 : 0xffffffff A4 : 0x00060920 A5 : 0x3ffc4730
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x80083048 A9 : 0x3ffc3ef0
A10 : 0x00000003 A11 : 0x00060923 A12 : 0x00060920 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000000 EXCCAUSE: 0x0000001c
EXCVADDR: 0xa5a5a5a9 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff

Backtrace: 0x40083872:0x3ffc3f00 0x40081a10:0x3ffc3f20 0x40081af0:0x3ffc3f50 0x400fb281:0x3ffc3f70 0x400fe466:0x3ffc4280 0x400fb324:0x3ffc43a0 0x400f4f20:0x3ffc46b0 0x40107d8d:0x3ffc4700

Problem connecting iphones - esp-idf 3.1.2

Hello,

With 3.1.2 esp-idf version, I'm struggling to connect iPhones to Wifi AP while it is working fine with Androids' phones.

Did you already face this issue ? Any tricks ?

Implicit declaration of function 'esp_https_ota'

I have a problem using the function from your example.

 esp_http_client_config_t ota_client_config = {
          .url = file->valuestring,
          .cert_pem = (char *)server_cert_pem_start
  };
esp_err_t ret = esp_https_ota(&ota_client_config);

It returns error: implicit declaration of function 'esp_https_ota' [-Werror=implicit-function-declaration]

setvbuf(stdout, NULL, _IONBF, 0) crashes http client example

First of all, your tutorials are awesome and have helped me a ton. Thank you!

If the setvbuf line is left in the http_client I get the following:

Connecting to xxxx... I (2122) event: sta ip: 192.168.1.53, mask: 255.255.255.0, gw: 192.168.1.1
connected!

IP Address: 192.168.1.53
CORRUPT HEAP: multi_heap.c:370 detected at 0x3ffc3d64
abort() was called at PC 0x40086c4f on core 0
0x40086c4f: multi_heap_assert at /Users/brannan/esp/esp-idf/components/heap/./multi_heap_platform.h:55
(inlined by) multi_heap_malloc_impl at /Users/brannan/esp/esp-idf/components/heap/./multi_heap.c:370

Comment out the call and all works well. The actual crash comes traces back to the subnet mask printf statement.

UUID

How to print the UUID of the iBeacon in the 23_ble_scan example? Reply asap

30_https_ota - Potential man-in-the-middle attack vulnerability

I think I found a potential security risk.
The code does check for authentication (using the certificate) while calling the "esp_https_ota" function:

	esp_http_client_config_t ota_client_config = {
		.url = file->valuestring,
		.cert_pem = server_cert_pem_start,
	};

But the code does not check for authentication while downloading the JSON file, which is just as critical:

		esp_http_client_config_t config = {
        .url = UPDATE_JSON_URL,
        .event_handler = _http_event_handler,
		};

That is enough for a man-in-the-middle-attack, right?

Proposed fix:

		esp_http_client_config_t config = {
        .url = UPDATE_JSON_URL,
        .cert_pem = server_cert_pem_start,
        .event_handler = _http_event_handler,
		};

PS.: Sorry if this is not the proper channel. I'm new to github.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.