Code Monkey home page Code Monkey logo

sensor-esp32's Introduction

OpenAirProject AirQuality / Dust Meter

Features

This meter measures dust (pm1, pm2.5, pm10 particles) and, optionally, other environmental conditions like temperature, pressure and humidity. Measurements occurs in configured intervals and the result is an average of multiple recorded samples. It handles 'warming period' necessary by the sensor to force proper air flow.

Current air quality is indicated with different color of RGB led (blue color means that first measurement has not completed yet).

Data is sent via local wifi to one of configured services (currently - ThingSpeak, AWS IoT is coming soon). After booting up for the first time, sensor becomes an access point and enables user to configure wifi access via browser.

Hardware

Required parts:

ESP32 DevKit Board (other boards should also work after minor modifications). Plantower PMS5003 (or PMS3003 or PMS7003) Any push button

Optional parts:

BMP280 sensor for temperature/airpressure readings RGB Led (common kathode) + 3 resistors (330ohms+)

Wiring

Here. I draw it myself.

Schema

Assembling is rather trivial.

PMSx003 sensor requires 5V power, although it communicates with standard 3V3, so no TTL converter is required. Connect RGB led via resistors to ESP32 and to GND. Connect BMP280 directly to ESP32. Connect button to one of pins to pull up when pressed.

ESP32 chip features GPIO matrix which means (theoretically) that programmatically we can change a function of any I/O pin. That being said, on ESP32 DevKit board some pins are already designated to perform specific function and may not work properly (or cause side effects) when assigned to other interfaces.

Firmware is pre-configured to use following GPIO which were tested with ESP32 DevKit board.

These assignments can be changed via 'make menuconfig'.

PMSx003 TX  => 34
PMSx003 SET => 10

BMx280 SDA	=> 25
BMx280 SCL	=> 26

LED R		=> 12
LED G		=> 27
LED B		=> 14

BUTTON		=> 35

Power consumption

Sensor requires 5V+ and consumes ~150mA up to ~170mA. During booting power consumption can be slightly higher (~250mA), but it is still low enough to be powered directly from any decent USB phone charger or from PC.

Despite low voltage, if you are going to use sensor outdoor or in any unfriendly environment (e.g. high humidity), please take it under consideration during build, isolate all connections properly and use appropriate case/enclosure (more on that soon).

Uploading firmware

To run your sensor you first need to flash ESP32 chip with OAP firmware.

To do so, you don't need to clone this project nor compile it - you can use pre-compiled firmware and a dedicated tool to handle the upload.

The procedure below was tested on Mac and Linux (Windows users, by now you should know the drill).

  1. Get proper USB cable to connect the sensor to your PC. All USB cables look similar, but some of them (which are usually thinner than others), cannot transfer data and are used only for powering/charging devices and are not suitable for our task.

  2. While Linux may detect sensor (or rather - usb driver chip installed on the esp32 board), other systems will most likely require installing a custom USB driver that matches the chip. Its type depends on the ESP32 board, but in majority of cases it should be a Silabs chip for which a driver can be found at http://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx).

  3. Once driver is installed and sensor is connected with usb cable to PC, do

     ls -la /dev/tty*
    

    to find out what name of the serial port was assigned to our sensor (the easiest way is to list this folder with sensor disconnected and connected and compare results). Note it down. On my Mac it was "/dev/tty.SLAB_USBtoUART", on Linux - "/dev/ttyUSB0" or /dev/ttyUSB1" but it may be different depending on the system configuration.

  4. Now download the firmware (three *.bin files) for the latest stable release that you can find here https://github.com/openairproject/sensor-esp32/releases.

  5. Now it is time to install "esptool", which is a firmware uploader from the manufacturer of ESP32 chip (Espressif company). Detailed instructions can be found here: https://github.com/espressif/esptool/blob/master/README.md, but if you already have Python and pip installed, just do

     pip install esptool
    

    By default it should be installed to "/usr/local/bin/".

  6. It is time to perform the flashing:

     esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -u --flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader.bin 0x30000 sensor-esp32.bin 0x8000 partitions.bin
    

    Use --port from the step 3, and three bin files downloaded in step 4.

    In most cases, esptool will be able to switch your sensor into 'flashing' mode automatically and reset it afterwords to make it ready to go - it takes a few seconds. Some boards however require manual operation to activate this mode (esptool connection will timeout). To do so, disconnect the sensor from USB, press and hold small button labeled "EN" on esp32 board (next to micro usb port), connect the sensor, run the command above and then release the button.

First run

After booting the sensor for the first time, sensor will switch into Access Point mode and create a wifi network

ssid: OpenAirProject-XXXXXX
pass: cleanair

After connecting to this network, open following url

http://192.168.1.1

and configure sensor settings using web control panel (most notably - your home wifi ssid/pass). After rebooting sensor will connect to your wifi .Web control panel will still be available, but at IP that was specified or assigned to sensor by your router.

If there's a need to force sensor into Access Point mode again (e.g. when it can't connect to specified wifi), reboot the device with a control button pressed down.

Schema

Building firmware

This part is for advanced users, in most cases you should be fine with installing pre-build firmware.

OAP firmware is written in native espressif-sdk v2.1 http://esp-idf.readthedocs.io/en/v2.1/get-started/index.html

After installing and setting up SDK, connect your ESP32 board to your PC. See notes regarding USB cable and driver in a chapter above.

To configure and build sources

make -j5

You can always bring up configuration menu via

make menuconfig	

During the first run, a menuconfig should appear where you need to configure some parameters of your setup, most notably - UART port.

In components submenu there's a few configuration settings related to OAP hardware setup (e.g. gpio pin assignments), and "OAP Main" menu where you can change various functional parameters.

** ATTENTION. main task stack should be increased to 10K if you're gonna use AWSIoT (via menuconfig) **

All settings are saved in sdkconfig file.

to flash the module and read from the serial output

make flash monitor

That's it.

Happy DIY time!


Prototype

sensor-esp32's People

Contributors

codepainters avatar kglowacki 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

Watchers

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

sensor-esp32's Issues

automated tests against memory leaks

this is a bit tricky to do, but possible with a separated nightly job running on jenkins.
in that case we'd have a separate 'test component' that would be the only one used to build unit-test-app. such component would implement several actions running in a long-lasting loop (maybe even emulate our main loop), and report average heap consumption. After X iterations we expect that no more memory is being consumed.

crash in tcp stack

after 24h, heap free

ESC[0;32mI (68236646) meter_intv: warming[0] pm1.0=2 pm2.5=8 pm10=8ESC[0m
ESC[0;33mW (68236950) http: couldn't acquire lock for SSL requestESC[0m
ESC[0;33mW (68236950) http: error connectESC[0m
D (68236950) http: Cleaning SSL connection.ESC[0m
ESC[0;33mW (68236953) ota: error response code=0ESC[0m
D (68236957) ota: fetch_last_ota_info failed [0x1001]ESC[0m
D (68236962) ota: sleep for 60 secESC[0m
D (68237486) mem: stack min (1152) - task 'pmsX003'ESC[0m
ESC[0;32mI (68237486) meter_intv: warming[0] pm1.0=5 pm2.5=5 pm10=16ESC[0m
D (68238326) mem: stack min (1152) - task 'pmsX003'ESC[0m
ESC[0;32mI (68238327) meter_intv: warming[0] pm1.0=3 pm2.5=5 pm10=5ESC[0m
D (68238399) mem: stack min (1104) - task 'bmx280'ESC[0m
D (68238402) bmx280: sensor (0) => Temperature : 29.09 C, Pressure: 1000.18 hPa, Humidity 31.27ESC[0m
ESC[0;32mI (68238403) app: env (0): temp : 29.09 C, pressure: 1000.18 hPa, humidity: 31.27 %ESC[0m
D (68239166) mem: stack min (1152) - task 'pmsX003'ESC[0m
ESC[0;32mI (68239167) meter_intv: warming[0] pm1.0=0 pm2.5=0 pm10=0ESC[0m
Guru Meditation Error of type LoadProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x40086f65 PS : 0x00060933 A0 : 0x80085999 A1 : 0x3ffbd810
ESC[0;33m0x40086f65: uxListRemove at /opt/esp/esp-idf/components/freertos/./list.c:218
ESC[0m
A2 : 0x3ffaebc0 A3 : 0x00060923 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x3ffaebc0
A10 : 0x3ffaebc0 A11 : 0x00060923 A12 : 0x00060920 A13 : 0x3ffbd884
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000019 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000004 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff

Backtrace: 0x40086f65:0x3ffbd810 0x40085996:0x3ffbd830 0x40083f55:0x3ffbd850 0x40124c32:0x3ffbd890 0x40114e92:0x3ffbd8b0 0x401140da:0x3ffbd8d0
ESC[0;33m0x40086f65: uxListRemove at /opt/esp/esp-idf/components/freertos/./list.c:218
ESC[0m
ESC[0;33m0x40085996: xTaskRemoveFromEventList at /opt/esp/esp-idf/components/freertos/./tasks.c:3442
ESC[0m
ESC[0;33m0x40083f55: xQueueGenericSend at /opt/esp/esp-idf/components/freertos/./queue.c:2034
ESC[0m
ESC[0;33m0x40124c32: sys_sem_signal at /opt/esp/esp-idf/components/lwip/port/freertos/sys_arch.c:554
ESC[0m
ESC[0;33m0x40114e92: lwip_netconn_do_delconn at /opt/esp/esp-idf/components/lwip/api/api_msg.c:1813 (discriminator 6)
ESC[0m
ESC[0;33m0x401140da: tcpip_thread at /opt/esp/esp-idf/components/lwip/api/tcpip.c:474
ESC[0m

CPU halted.

add logs

log UTC date from time to time and time since last http success so we could detect networking issues more easily

stack overflow in task eventTask

happens after a few hours in wifi on/off test

ESC[0;32mI (12916530) wifi: SYSTEM_EVENT_STA_CONNECTEDESC[0m
ESC[0;32mI (12916552) wifi: SYSTEM_EVENT_STA_GOT_IPESC[0m
ESC[0;32mI (12916552) wifi:

*** SENSOR IP (network 'cosmos-test') http://10.42.0.163
ESC[0m
ERROR A stack overflow in task eventTask has been detected.
abort() was called at PC 0x400874f4 on core 0

Backtrace: 0x400873dc:0x3ffbe540 0x400874db:0x3ffbe560 0x400874f4:0x3ffbe580 0x40084ce9:0x3ffbe5a0 0x400863b0:0x3ffbe5c0 0x4008636a:0x00000000

Rebooting...

proper versioning

each build should be marked with semantic version number;
we should print it to logs and send as a header to data endpoints.

document firmware upload

maybe in a form of a python script or something?
we can pull binaries from OTA folder and use IDF tools to upload them to the device.
such script could also feature a wizard to set up initial config parameters incl cert/ppk.

reboot after crash

official release firmware should auto-reboot after crash; but we should detect this in long-lasting stability tests.

secondary OTA server

CA certificate of current OTA server may change and this will case OTA to fail.
We need secondary, backup OTA server defined that could be used in such case (from different provider). We can use github for that.

use wiremock for testing publishers

thingspeak rejects connections from abusive devices, the same case may happen with any other publisher. ideally we'd have a wiremock (spring contract? local mqtt?) endpoints set up on jenkins to simulate real apis.

wifi disconnects

...after ~70sec of no activity

I (39527861) wifi: state: run -> auth (7c0)
I (39527861) wifi: n:11 0, o:11 0, ap:255 255, sta:11 0, prof:1
I (39527862) wifi: pm stop, total sleep time: 0/848270267

32mI (39527865) wifi: SYSTEM_EVENT_STA_DISCONNECTED

this might have been fixed in sdk already ('sending null frame'...) but in 2.1 causes problems - w/o a buffer for results, data is being lost. also, ssl often fails just after reconnecting.
we can send a simple request every 30 sec or so, maybe even only to the gateway.

refactor static config

components should not import sdkconfig.h;
structure code in main better to see where particular components are activated;

problems with storing config

D (55140) nvs: nvs_open_from_partition OAP 1
D (55140) storage: set_bigblob 'config'= 3483 bytes
D (55145) nvs: nvs_get config.# 4
D (55149) storage: old entry size=3484 (2 parts)
D (55154) storage: store part 'config.0': 0-1984
D (55158) nvs: nvs_set_blob config.0 1984
ESP_ERROR_CHECK failed: esp_err_t 0x1105 at 0x4011509e
0x4011509e: storage_set_bigblob at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/oap_common/./oap_storage.c:224 (discriminator 1)

Backtrace: 0x4008781c:0x3ffd4100 0x40087b99:0x3ffd4120 0x4011509e:0x3ffd4140 0x40115164:0x3ffd4190 0x401151f1:0x3ffd41b0 0x4011f8b4:0x3ffd41d0 0x4011f981:0x3ffd41f0 0x401228ee:0x3ffd4220 0x40123bb9:0x3ffd4250 0x40123d62:0x3ffd4270 0x40123d7e:0x3ffd42a0 0x401228ee:0x3ffd4440 0x40122ce9:0x3ffd4470 0x40122cfe:0x3ffd44a0 0x40122d72:0x3ffd44c0 0x40123026:0x3ffd44e0 0x4012327d:0x3ffd4520 0x40121e22:0x3ffd4580 0x4011f757:0x3ffd45a0
0x4008781c: invoke_abort at /opt/esp/esp-idf/components/esp32/./panic.c:553

0x40087b99: _esp_error_check_failed at /opt/esp/esp-idf/components/esp32/./panic.c:565

0x4011509e: storage_set_bigblob at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/oap_common/./oap_storage.c:224 (discriminator 1)

0x40115164: storage_store_config at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/oap_common/./oap_storage.c:262

0x401151f1: storage_update_config at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/oap_common/./oap_storage.c:306

0x4011f8b4: handler_set_config at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/bootwifi/./bootwifi.c:123

0x4011f981: mongoose_event_handler at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/bootwifi/./bootwifi.c:164

MQTT support

Hello very nice project, could you please integrate MQTT client ?

cannot save changed config

in sdk2.1 there's a limit for a single nvs entry (1984 bytes), we usually exceed this when aws keys are filled.

crash in esp_request

D (16716) HTTP_REQ: Secure
assertion "next > (intptr_t)block" failed: file "/opt/esp/esp-idf/components/heap/./multi_heap.c", line 116, function: get_next_block
abort() was called at PC 0x40102623 on core 0
0x40102623: __assert_func at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdlib/../../../.././newlib/libc/stdlib/assert.c:63 (discriminator 8)

Backtrace: 0x400875d8:0x3ffccb10 0x400876a3:0x3ffccb30 0x40102623:0x3ffccb50 0x400870cf:0x3ffccb80 0x40082456:0x3ffccba0 0x4008276d:0x3ffccbc0 0x4000bec7:0x3ffccbe0 0x4012a367:0x3ffccc00 0x4012a03d:0x3ffccc20 0x4012a1a6:0x3ffccc50 0x4012a1d9:0x3ffccc70 0x401158f3:0x3ffccc90 0x40115ae6:0x3ffcccd0 0x40115bf3:0x3ffccd00 0x40115db8:0x3ffccd40
0x400875d8: invoke_abort at /opt/esp/esp-idf/components/esp32/./panic.c:553

0x400876a3: abort at /opt/esp/esp-idf/components/esp32/./panic.c:553

0x40102623: __assert_func at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdlib/../../../.././newlib/libc/stdlib/assert.c:63 (discriminator 8)

0x400870cf: get_next_block at /opt/esp/esp-idf/components/heap/./multi_heap.c:615 (discriminator 1)
(inlined by) multi_heap_free_impl at /opt/esp/esp-idf/components/heap/./multi_heap.c:414 (discriminator 1)

0x40082456: heap_caps_free at /opt/esp/esp-idf/components/heap/./heap_caps.c:143

0x4008276d: _free_r at /opt/esp/esp-idf/components/newlib/./syscalls.c:42

0x4012a367: free_parsed_uri at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/esp-request/./uri_parser.c:250

0x4012a03d: req_setopt_from_uri at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/esp-request/./esp_request.c:402

0x4012a1a6: req_new_with_buf at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/esp-request/./esp_request.c:440

0x4012a1d9: req_new at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/esp-request/./esp_request.c:450

0x401158f3: fetch_last_ota_info at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/ota/./ota.c:146

0x40115ae6: is_ota_update_available at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/ota/./ota.c:254

0x40115bf3: check_ota at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/ota/./ota.c:301 (discriminator 1)

0x40115db8: check_ota_task at /opt/tomcat/.jenkins/workspace/oap-sensor-esp32/components/ota/./ota.c:360

wifi crashes while reconnecting

D (58542) event: SYSTEM_EVENT_STA_DISCONNECTED, ssid:cosmos, ssid_len:6, bssid:24:7f:20:5f:70:41, reason:7
D (58552) tcpip_adapter: check: local, if=0 fn=0x40116578
0x40116578: tcpip_adapter_down_api at /Users/kris/Dev/iot/ESP32/esp-idf/components/tcpip_adapter/./tcpip_adapter_lwip.c:942

D (58558) tcpip_adapter: if0 start ip lost tmr: enter
D (58563) tcpip_adapter: if0 start ip lost tmr: interval=120
D (58569) tcpip_adapter: call api in lwip: ret=0x0, give sem
D (58574) tcpip_adapter: check: remote, if=0 fn=0x40116578
0x40116578: tcpip_adapter_down_api at /Users/kris/Dev/iot/ESP32/esp-idf/components/tcpip_adapter/./tcpip_adapter_lwip.c:942

D (58580) wifi: Station disconnected - reconnecting
Guru Meditation Error of type LoadProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x4011d73e PS : 0x00060a30 A0 : 0x8011d8a2 A1 : 0x3ffbdb80
0x4011d73e: restore_wifi_setup at /Users/kris/Dev/iot/ESP32/workspace/pmsensor/components/bootwifi/./bootwifi.c:432

A2 : 0x00000001 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x3ffbba3c
A6 : 0x00000001 A7 : 0x00000005 A8 : 0x8011d712 A9 : 0x3ffbdb60
A10 : 0x00000000 A11 : 0x00060a20 A12 : 0x3ffbdbd0 A13 : 0x0000000c
A14 : 0x00000000 A15 : 0x00000005 SAR : 0x00000007 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000001 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffe

Backtrace: 0x4011d73e:0x3ffbdb80 0x4011d89f:0x3ffbdc10 0x40127f4d:0x3ffbdc50 0x40127f91:0x3ffbdc70
0x4011d73e: restore_wifi_setup at /Users/kris/Dev/iot/ESP32/workspace/pmsensor/components/bootwifi/./bootwifi.c:432

0x4011d89f: esp32_wifi_eventHandler at /Users/kris/Dev/iot/ESP32/workspace/pmsensor/components/bootwifi/./bootwifi.c:303 (discriminator 1)

0x40127f4d: esp_event_post_to_user at /Users/kris/Dev/iot/ESP32/esp-idf/components/esp32/./event_loop.c:94

0x40127f91: esp_event_loop_task at /Users/kris/Dev/iot/ESP32/esp-idf/components/esp32/./event_loop.c:94

bme280 self-heating issue

it usually shows 3-5C above ambient temp; part of it is a self-heating mentioned by the data sheet, since it has no external sensor, and the other part - heat radiated by esp32.

self-heating can be probably reduced by doing less frequent reads (forced mode + read every 5 min or so).

new PCB must be designed in a way to move sensor away from the chip.

buffer results in case of publishing errors

for each publisher we can maintain a short queue and try to resend outstanding results during the next round, if publisher failed previously.
w/o this feature we're losing data with flaky wifi networks

provide 'factory reset'

it has to be triggered by a physical button - the whole idea is to recover after soft failed.

Rebooting caused by missing hardwares?

Hi openairproject,

During the search for bmp280 driver I landed here. ๐Ÿ˜ƒ
But what I'm working on is somehow very similar to this project.
Besides the issue about socket. I've experienced permanent rebooting issue as the console log here:

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4456
load:0x40078000,len:0
ho 12 tail 0 room 4
load:0x40078000,len:12988
entry 0x40078d14
I (192) cpu_start: Pro cpu up.
I (192) cpu_start: Single core mode
I (192) heap_init: Initializing. RAM available for dynamic allocation:
D (196) heap_init: New heap initialised at 0x3ffae6e0
I (201) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
D (207) heap_init: New heap initialised at 0x3ffb8dd8
I (212) heap_init: At 3FFB8DD8 len 00027228 (156 KiB): DRAM
I (218) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (225) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
D (231) heap_init: New heap initialised at 0x40091ab0
I (236) heap_init: At 40091AB0 len 0000E550 (57 KiB): IRAM
I (243) cpu_start: Pro cpu start user code
D (255) clk: RTC_SLOW_CLK calibration value: 3420723
D (40) intr_alloc: Connected src 46 to int 2 (cpu 0)
D (41) intr_alloc: Connected src 57 to int 3 (cpu 0)
D (41) intr_alloc: Connected src 24 to int 9 (cpu 0)
I (47) cpu_start: Starting scheduler on PRO CPU.
D (51) heap_init: New heap initialised at 0x3ffe0440
D (55) heap_init: New heap initialised at 0x3ffe4350
D (60) intr_alloc: Connected src 16 to int 12 (cpu 0)
I (1066) app: starting app... firmware 1.2.0
D (1103) storage: get config
D (1104) storage: reading 475 bytes
D (1104) storage: read config.0: 0-475
I (1105) storage: config
{
	"wifi":	{
		"ssid":	"",
		"password":	"",
		"ip":	"",
		"gw":	"",
		"netmask":	""
	},
	"thingspeak":	{
		"enabled":	0,
		"apikey":	""
	},
	"awsiot":	{
		"enabled":	0,
		"endpoint":	"a32on3oilq3poc.iot.eu-west-1.amazonaws.com",
		"port":	8443
	},
	"ota":	{
		"interval":	3600
	},
	"sensor":	{
		"config":	{
			"indoor":	0,
			"led":	1,
			"fan":	1,
			"heater":	1,
			"measTime":	60,
			"warmUpTime":	30,
			"measInterval":	300,
			"test":	0,
			"measStrategy":	0
		}
	}
}
D (1150) intr_alloc: Connected src 22 to int 13 (cpu 0)
D (1155) wifi: wifi_boot start
D (1159) btn: click gpio[39] [1 in sequence]
I (1164) wifi: wifi firmware version: 275023b
I (1167) wifi: config NVS flash: enabled
I (1170) wifi: config nano formating: disabled
I (1175) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (1184) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (1199) wifi: Init dynamic tx buffer num: 32
I (1199) wifi: Init data frame dynamic rx buffer num: 64
I (1203) wifi: Init management frame dynamic rx buffer num: 64
I (1209) wifi: wifi driver task: 3ffc2344, prio:23, stack:4096
I (1214) wifi: Init static rx buffer num: 10
I (1218) wifi: Init dynamic rx buffer num: 0
I (1222) wifi: wifi power manager task: 0x3ffc6f94 prio: 21 stack: 2560
D (1229) wifi: - Starting being an access point ...
D (1894) btn: click gpio[39] [2 in sequence]
D (1895) btn: click gpio[39] [3 in sequence]
D (1895) btn: click gpio[39] [4 in sequence]
D (1897) btn: click gpio[39] [5 in sequence]
D (1901) btn: click gpio[39] [6 in sequence]
D (1905) btn: click gpio[39] [7 in sequence]
D (1910) btn: click gpio[39] [8 in sequence]
D (1914) btn: click gpio[39] [9 in sequence]
D (1918) btn: click gpio[39] [10 in sequence]
W (1923) app: about to perform factory reset!
/home/gfast2/esp/esp-idf/components/freertos/./queue.c:718 (xQueueGenericSend)- assert failed!
abort() was called at PC 0x40084eb7 on core 0
0x40084eb7: xQueueGenericSend at /home/gfast2/esp/esp-idf/components/freertos/./queue.c:2037


Backtrace: 0x40088904:0x3ffbe6e0 0x40088a03:0x3ffbe700 0x40084eb7:0x3ffbe720 0x4010d3d7:0x3ffbe760 0x4010d407:0x3ffbe780 0x40120d73:0x3ffbe7a0
0x40088904: invoke_abort at /home/gfast2/esp/esp-idf/components/esp32/./panic.c:572

0x40088a03: abort at /home/gfast2/esp/esp-idf/components/esp32/./panic.c:572

0x40084eb7: xQueueGenericSend at /home/gfast2/esp/esp-idf/components/freertos/./queue.c:2037

0x4010d3d7: ledc_update at /home/gfast2/workspace/OAP_openAirProject/main/./main.c:75

0x4010d407: btn_handler at /home/gfast2/workspace/OAP_openAirProject/main/./main.c:355 (discriminator 1)

0x40120d73: gpio_watchdog_task at /home/gfast2/workspace/OAP_openAirProject/components/oap-hw-ext/./ctrl_btn.c:82

ESP-IDF: 1837a034dd642e2843d62d8e6e8f784071d01ebe
Board: NodeMCU esp-32s
Sensor & Co. : Right now only a BOSH bmp280 (0x76 with default I2C pin on ESP32)
Changes I made:

  1. rename "socket" -> "sock" in sensor-esp32/components/oap-http/esp_request.c
  2. change target device from "opt/...can_not_remember_anymore.../ttyOAP" -> "/dev/ttyUSB0"

adjust partitions

since we need 4MB flash anyway (at least 1MB for code x 3 partitions)
we can utilise all this space, esp make NVS bigger - it will solve problems with storing config and will leave some room for persistent buffer.
this has to done prior to 1.0 release because partitions cannot be changed via OTA.

test OTA

perform long-lasting test (put a device into an update loop)

OTA updates

  1. the trigger for OTA will be separated from the updater so we can use AWS-IoT to notify the device about new version or just use static url.
  2. verify signature
  3. OTA can be disabled via config
  4. we need proper versioning now

check SSL requests in AP mode

it seems to hang network stack (observed with OTA status check).
the same issue may happen while trying to publish results with thingsspeak or AWS IoT in AP mode.

error: called object 'socket' is not a function or function pointer

Getting Error:
CC build/oap-http/esp_request.o
sensor-esp32/components/oap-http/./esp_request.c: In function 'nossl_connect':
sensor-esp32/components/oap-http/./esp_request.c:128:14: error: called object 'socket' is not a function or function pointer
socket = socket(PF_INET, SOCK_STREAM, 0);

It seems due to change in ESP IDF.

According to the solution above changes will need to done in esp_request.c file.

duo pm measurement strategy

the idea is to have a strategy that uses secondary PM sensor as a reference sensor, used from time to time along with primary sensor.

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.