Open rikki78 opened 7 months ago
I am using the esp-idf visual studio code extension. I'll add the rest of the files. I finished the wifi config and remote config with CURL/REST now so I'm moving on to tests and doco.
I just checked out the project fresh, opened the directory, ran menuconfig to set the partitions to use the custom partitions and built it. I am using a xiao C3.
I'm new to esp-idf so it took some time to get it working. I'm using a esp32 dev board and it crashed on boot, so I had to modify the code so it doesn't use gpio 9 anymore. Now it starts but for some reason the esp touch always fails. This is the debug output:
I (1614058) WiFiManager: Found channel I (1644058) wifi:ic_disable_sniffer I (1644058) smartconfig: smartconfig restart I (1644108) smartconfig: SC version: V3.0.1 I (1648948) wifi:ic_enable_sniffer I (1648948) smartconfig: Start to find channel... I (1648948) WiFiManager: Scan done I (1650108) smartconfig: lock channel: 6 I (1650108) smartconfig: TYPE: ESPTOUCH_V2 I (1650108) smartconfig: offset:52 tods: 0 I (1650108) WiFiManager: Found channel I (1667528) smartconfig: start scanning again
I have a few of those boards. I'll put the firmware on one tonight. I can make the radar and config pins configurable. I have used all my radar modules so I'll add a little emulator so I can test it for you.
I am surprised the esptouch v2 does not work. It's the most reliable way for me to config the wifi. I'll try it on an esp32 dev board as well.
I added the GPIO button configuration to a menuconfig. Now you can run menuconfig and set the button.
When you are using esptouch v2, you should make sure the AES and extra info fields are empty.
I just rebuilt it for a lilygo tt-display and I can reset the config with the button on gpio 35, set in the menuconfig and configure the wifi with esptouch.
ps, once it's up you can query the config with:
curl http://<IP>/settings
piping through 'jq' if you have it installed. ..
curl http://131.84.1.70/settings | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 225 100 225 0 0 3099 0 --:--:-- --:--:-- --:--:-- 3125
{
"mqttBrokerUri": "mqtt://mqtt2.mianos.com",
"mqttUserName": "",
"mqttUserPassword": "",
"sensorName": "radar3",
"tracking": 0,
"presence": 1000,
"detectionTimeout": 10000,
"tz": "AEST-10AEDT,M10.1.0,M4.1.0/3",
"ntpServer": "time.google.com"
}
I'll try and find a vroom board tomorrow. I have also used all my LD2450s so I'll add one of their other radars and set up menuconfig to set the serial pins now I know how to make modules.
pps you can also set the sensor name to something with a slash in it like radar/office and radar/hall so this works now:
mosquitto_sub -h localhost -v -t 'tele/radar/+/+'
tele/radar/office/presence {"entry":1,"type":"rng","x":-0.009,"y":1.31,"speed":0,"reference":0}
tele/radar/office/presence {"entry":1,"type":"rng","x":-0.081,"y":1.319,"speed":0,"reference":0}
ps, you won't regret switching from arduino to esp-idf. I used arduino over the esp for years but I'd never go back. The IDF is way more stable to me and my own C++ wrappers are much better to me than any of the arduino wrappers.
I've tried it with esptouch v2 and now it connects. How to write the webpage to the flash? When accessing the IP address with a browser I get "Nothing matches the given URI"
And in the log:
W (9298) httpd_uri: httpd_uri: URI '/' not found W (9298) httpd_txrx: httpd_resp_send_err: 404 Not Found - Nothing matches the given URI W (10208) httpd_uri: httpd_uri: URI '/favicon.ico' not found W (10208) httpd_txrx: httpd_resp_send_err: 404 Not Found - Nothing matches the given URI
curl http://
Not on just /
I also put the curl commands in the readme.md.
The POST to set the mqtt server is also there. See how you go.
you are almost there now. If you want to chat on a messenger later we can get it going.
Yes almost there :-)
Now I can't connect to mqtt. It looks like the mqtt password isn't stored, it is not shown during start of the module
This is printed:
I (748) mqtt_main: Settings {"mqttBrokerUri":"mqtt://someip","mqttUserName":"username","mqttUserPassword":"","sensorName":"radar3","tracking":0,"presence":1000,"detectionTimeout":10000,"tz":"AEST-10AEDT,M10.1.0,M4.1.0/3","ntpServer":"time.google.com"}
this is the error
I (5078) MqttClient: MQTT_EVENT_DISCONNECTED I (20088) MqttClient: Other MQTT Event ID: 7 W (20108) mqtt_client: Connection refused, not authorized I (20108) MqttClient: MQTT_EVENT_ERROR E (20108) mqtt_client: MQTT connect failed I (20108) MqttClient: MQTT_EVENT_DISCONNECTED
ok, I can test it. Is the mqtt server URI stored?
Yes it is
OK, the user is stored, just the password not working. Odd. Fixing it now. Also some updates to the json decoder and added a post /reboot.
OK fixed, turns out keys can not be more than 15 characters. My NVS component now checks the size and reports storage failure errors.
Note that I had to shorten the JSON keys:
"mqttBrokerUri": "mqtt://mqtt2.mianos.com",
"mqttUserName": "hikaru",
"mqttPassword": "nakamura",
"sensorName": "radar/office",
"tracking": 0,
"presence": 1000,
"detectTime": 10000,
"tz": "AEST-10AEDT,M10.1.0,M4.1.0/3",
"ntpServer": "time.google.com"
pps. remember to run the menuconfig and add the custom partition sizes and maybe adjust your serial pins.
As I switch cores (I am running an S3), I am not sure how I can save an sdk config to git.
hmm now I'm getting Medidation errors. Looks like after initialising the gpio button ` I (998) NvsStorageManager: Did not get NVS value 'ssid' I (998) WiFiManager: No stored WiFi credentials, starting SmartConfig... I (1008) Web: Starting web server on port 80 I (1008) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
Core 1 register dump: PC : 0x4008ad74 PS : 0x00060e34 A0 : 0x8008a927 A1 : 0x3ffca270 0x4008ad74: spinlock_acquire at C:/Users/rik/esp/v5.2.1/esp-idf/components/esp_hw_support/include/spinlock.h:130 (inlined by) xPortEnterCriticalTimeout at C:/Users/rik/esp/v5.2.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:473
A2 : 0x3ffbfc70 A3 : 0xffffffff A4 : 0x06b9beaa A5 : 0x00060e23 A6 : 0xb33fffff A7 : 0x0000abab A8 : 0x8008ad80 A9 : 0x3ffca250 A10 : 0x00000000 A11 : 0xb339f9df A12 : 0x00060620 A13 : 0x00060023 A14 : 0x00000001 A15 : 0x00000001 SAR : 0x0000001a EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff 0x4000c2e0: memcpy in ROM `
Did you set the button pin in the menuconfig? It's getting reset on checkout. I'm not sure how to make it stay.
Yes it is, and it is being used also see this line
I (1008) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I'll try another one again I see 15 is a strapping pin
Or just comment it out. It is only there to clear the wifi credentials.
next one `
I (907) phy_init: phy_version 4791,2c4672b,Dec 20 2023,16:06:06 I (997) wifi:mode : sta (d4:8a:fc:c9:31:50) I (997) wifi:enable tsf I (997) NvsStorageManager: Did not get NVS value 'ssid' I (997) WiFiManager: No stored WiFi credentials, starting SmartConfig... I (1007) Web: Starting web server on port 80 Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1).
Core 1 register dump: PC : 0x4008ad7d PS : 0x00060c34 A0 : 0x8008a927 A1 : 0x3ffca270 0x4008ad7d: spinlock_acquire at C:/Users/rik/esp/v5.2.1/esp-idf/components/esp_hw_support/include/spinlock.h:130 (inlined by) xPortEnterCriticalTimeout at C:/Users/rik/esp/v5.2.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:473
A2 : 0x3ffbfc70 A3 : 0xffffffff A4 : 0x040513f7 A5 : 0x00060a23 A6 : 0xb33fffff A7 : 0x0000abab A8 : 0x8008ad80 A9 : 0x3ffca250 A10 : 0x3ffbfc70 A11 : 0xb33fffff A12 : 0x0000abab A13 : 0x00060023 A14 : 0x00000001 A15 : 0x00000001 SAR : 0x0000001a EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff 0x4000c2e0: memcpy in ROM 0x4000c2f6: memcpy in ROM
Backtrace: 0x4008ad7a:0x3ffca270 0x4008a924:0x3ffca2a0 0x4008a9fe:0x3ffca2e0 0x401b171d:0x3ffca300 0x401b17f6:0x3ffca340 0x401b0e09:0x3ffca370 0x40109017:0x3ffca390 0x400e5f96:0x3ffca3b0 0x4008ab29:0x3ffca3e0 0x4008ad7a: spinlock_acquire at C:/Users/rik/esp/v5.2.1/esp-idf/components/esp_hw_support/include/spinlock.h:130 (inlined by) xPortEnterCriticalTimeout at C:/Users/rik/esp/v5.2.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:473 0x4008a924: vPortEnterCritical at C:/Users/rik/esp/v5.2.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h:571 (inlined by) xQueueSemaphoreTake at C:/Users/rik/esp/v5.2.1/esp-idf/components/freertos/FreeRTOS-Kernel/queue.c:1727 0x4008a9fe: xQueueTakeMutexRecursive at C:/Users/rik/esp/v5.2.1/esp-idf/components/freertos/FreeRTOS-Kernel/queue.c:835 0x401b171d: esp_event_handler_register_with_internal at C:/Users/rik/esp/v5.2.1/esp-idf/components/esp_event/esp_event.c:715 0x401b17f6: esp_event_handler_register_with at C:/Users/rik/esp/v5.2.1/esp-idf/components/esp_event/esp_event.c:763 0x401b0e09: esp_event_handler_register at C:/Users/rik/esp/v5.2.1/esp-idf/components/esp_event/default_event_loop.c:24 0x40109017: esp_smartconfig_start at C:/Users/rik/esp/v5.2.1/esp-idf/components/esp_wifi/src/smartconfig.c:46 0x400e5f96: WiFiManager::smartConfigTask(void*) at C:/Users/rik/Dropbox/SharedHome/mqttradar/components/wifimanager/src/WifiManager.cpp:92 0x4008ab29: vPortTaskWrapper at C:/Users/rik/esp/v5.2.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134
Core 0 register dump:
PC : 0x40087f56 PS : 0x00060e34 A0 : 0x800d4162 A1 : 0x3ffbc390
0x40087f56: esp_cpu_wait_for_intr at C:/Users/rik/esp/v5.2.1/esp-idf/components/esp_hw_support/cpu.c:145
A2 : 0x00000000 A3 : 0x00000001 A4 : 0x8008aece A5 : 0x3ffc2810 A6 : 0x00000003 A7 : 0x00060023 A8 : 0x800ebd8a A9 : 0x3ffbc350 A10 : 0x00000000 A11 : 0x00000001 A12 : 0x8008aece A13 : 0x3ffc2810 A14 : 0x00000003 A15 : 0x3ffafe10 SAR : 0x00000000 EXCCAUSE: 0x00000006 EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace: 0x40087f53:0x3ffbc390 0x400d415f:0x3ffbc3b0 0x4008bbed:0x3ffbc3d0 0x4008ab29:0x3ffbc3f0 0x40087f53: xt_utils_wait_for_intr at C:/Users/rik/esp/v5.2.1/esp-idf/components/xtensa/include/xt_utils.h:81 (inlined by) esp_cpu_wait_for_intr at C:/Users/rik/esp/v5.2.1/esp-idf/components/esp_hw_support/cpu.c:132 0x400d415f: esp_vApplicationIdleHook at C:/Users/rik/esp/v5.2.1/esp-idf/components/esp_system/freertos_hooks.c:59 0x4008bbed: prvIdleTask at C:/Users/rik/esp/v5.2.1/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4273 (discriminator 1) 0x4008ab29: vPortTaskWrapper at C:/Users/rik/esp/v5.2.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134
ELF file SHA256: 4cf6d5b94 `
okay got it sorted. I erased the flash and tried again. Now it connects
I got another esp and tried the same. I was trying to work out how to clean the nvram.
So now it shows up in mqtt under tele/radar3. Where do I see the radar activity?
Mine is set to radar/office, so I use
mosquitto_sub -h localhost -v -t 'tele/radar/+/+'
tele/radar/office/presence {"entry":1,"type":"rng","x":0.122,"y":1.295,"speed":0,"reference":0}
tele/radar/office/presence {"entry":1,"type":"rng","x":0.132,"y":1.294,"speed":0,"reference":0}
tele/radar/office/presence {"entry":1,"type":"rng","x":0.172,"y":1.283,"speed":0,"reference":0}
tele/radar/office/presence {"entry":1,"type":"rng","x":0.079,"y":1.396,"speed":0,"reference":0}
tele/radar/office/presence {"entry":1,"type":"rng","x":0.076,"y":1.505,"speed":0,"reference":0}
tele/radar/office/presence {"entry":1,"type":"rng","x":0.315,"y":1.641,"speed":0,"reference":0}
so
mosquitto_sub -h localhost -v -t 'tele/radar3/+'
Should work if you have some data.
PS. the provisioning problem is my bug. Fixing it now.
I guess there is no data then, as it only shows radar3/init. I'm using the same pins as I'm using with another sketch (tx 16/ rx 17), where I am able to read the radar. How can I troubleshoot this?
Yes, the best way to troubleshoot it is put an ESP_LOGI("LDX", "%x ", byteValue); on: https://github.com/mianos/mqttradar/blob/main/main/ld2450.h#L84
Did you get the serial pins correct in the menuconfig? Anyway that will 100% show the binary data is coming from the radar module. If it is not, maybe the RX and TX are swapped.
Yes I've set the pins and tried swapping them already in the config. I've tried again and reset the sensor and now something is happening! Thanks for your support!
All the way to mqtt? (ps. I am still looking at the provisioning. My code is much the same as the example. Annoying, it should work but I found a way, 100% it does not).
The provisioning is fixed and the "entry" json entry is back to a bool true/false if you want to pull the new version.
Thanks! I'll try to test it soon. Which home automation software are you using?
I amusing node-red
I assume you are using platformio, can you include the ini file for that also?