ESP32 ADC & WiFi problem

ziyun_cloud
Posts: 1
Joined: Tue Mar 16, 2021 7:30 am

ESP32 ADC & WiFi problem

Postby ziyun_cloud » Tue Mar 16, 2021 9:09 am

Hi there!
I'm working on a project that use ESP32's ADC1 read some data and send them to server, but there are some problems I've met.
If I use API adc1_get_raw() to read sensor directly, everything works just fine. But if I use dma method i2s_read() to read sensors, the i2s will output uncertain constant values after wifi event WIFI_EVENT_STA_CONNECTED. In this case, close the AP won't make adc output back to normal.
Is the initial configuration of my component incorrect, or is there some bugs with the chip or IDF, or adc1 with dma just won't work with wifi station mode?

here is ADC init code
  1. void adc_reader_init(void){
  2.     ESP_LOGI(TAG, "adc reader init.\n");
  3. #if CONFIG_ADC_USE_DMA
  4.     i2s_config_t i2s_cfg = {
  5.         .mode = I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN,
  6.         .sample_rate = 3200,    //real sample rate 16000
  7.         .bits_per_sample = 16,
  8.         .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
  9.         .communication_format = I2S_COMM_FORMAT_I2S_MSB,
  10.         .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // high interrupt priority
  11.         .dma_buf_count = 4,
  12.         .dma_buf_len = 800
  13.     };
  14.  
  15.     i2s_driver_install(I2S_NUM_0, &i2s_cfg, 10, &i2s_queue);
  16.     i2s_set_adc_mode(ADC_UNIT_1, ADC_CHANNEL_0);
  17. #else
  18.     adc1_config_width(ADC_WIDTH_12Bit);
  19.     adc1_config_channel_atten(ADC_CHANNEL_0, ADC_ATTEN_11db);
  20.     adc_gpio_init(ADC_UNIT_1, ADC_CHANNEL_0);
  21.     adc_power_on();
  22. #endif
  23.     wave_queue = xQueueCreate(10, sizeof(adc_data_t*));
  24.     if(NULL == wave_queue_lock){
  25.         wave_queue_lock = xSemaphoreCreateMutex();
  26.     }
  27. }
and the Wifi init code
  1. //wifi initialization
  2. void wifi_init(void) {
  3.     s_wifi_event_group = xEventGroupCreate();
  4.  
  5.     ESP_ERROR_CHECK_WITHOUT_ABORT(esp_netif_init());
  6.     ESP_ERROR_CHECK_WITHOUT_ABORT(esp_event_loop_create_default());
  7.     esp_netif_create_default_wifi_sta();
  8.     wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  9.     ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_init(&cfg));
  10.     ESP_ERROR_CHECK_WITHOUT_ABORT(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));
  11.     ESP_ERROR_CHECK_WITHOUT_ABORT(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &wifi_event_handler, NULL));
  12. }
  13.  
  14. esp_err_t wifi_sta_set_conn(const char *ssid, const char *pwd) {
  15.     esp_err_t err;
  16.     wifi_config_t wifi_cfg;
  17.  
  18.     if(NULL == ssid || NULL == pwd){
  19.         ESP_LOGE(TAG, "wifi config failed by null param\n");
  20.         return ESP_ERR_INVALID_ARG;
  21.     }
  22.  
  23.     if(strlen(ssid) >= 32 || strlen(pwd) >= 64 || strlen(ssid) == 0 || strlen(pwd) == 0){
  24.         ESP_LOGE(TAG, "ssid or password length invalid!\n");
  25.         return ESP_ERR_INVALID_ARG;
  26.     }
  27.  
  28.     strcpy((char *)wifi_cfg.sta.ssid, ssid);
  29.     strcpy((char *)wifi_cfg.sta.password, pwd);
  30.     wifi_cfg.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
  31.     wifi_cfg.sta.pmf_cfg.capable = true;
  32.     wifi_cfg.sta.pmf_cfg.required = false;
  33.  
  34.     ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_mode(WIFI_MODE_STA));
  35.     err = esp_wifi_set_config(WIFI_IF_STA, &wifi_cfg);
  36.     ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_start());
  37.  
  38.     return err;
  39. }
and here is the ESP output log:
  1. Hello world!
  2. This is ESP32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 4MB external flash
  3. I (554) adc reader: adc reader init.
  4.  
  5. I (554) I2S: queue free spaces: 10
  6. I (554) I2S: DMA Malloc info, datalen=blocksize=3200, dma_buf_count=4
  7. I (554) I2S: PLL_D2: Req RATE: 3200, real rate: 200.000, BITS: 16, CLKM: 416, BCK: 60, MCLK: 416.667, SCLK: 6400.000000, diva: 64, divb: 42
  8. I (574) adc reader: task ADC read task start.
  9.  
  10. I (584) wifi:wifi driver task: 3ffc60c4, prio:23, stack:6656, core=0
  11. I (584) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
  12. I (594) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
  13. I (624) wifi:wifi firmware version: bcf771b
  14. I (624) wifi:config NVS flash: enabled
  15. I (624) wifi:config nano formating: disabled
  16. I (624) wifi:Init data frame dynamic rx buffer num: 32
  17. I (624) wifi:Init management frame dynamic rx buffer num: 32
  18. I (634) wifi:Init management short buffer num: 32
  19. I (634) wifi:Init dynamic tx buffer num: 32
  20. I (644) wifi:Init static rx buffer size: 1600
  21. I (644) wifi:Init static rx buffer num: 10
  22. I (654) wifi:Init dynamic rx buffer num: 32
  23. I (654) wifi_init: rx ba win: 6
  24. I (654) wifi_init: tcpip mbox: 32
  25. I (664) wifi_init: udp mbox: 6
  26. I (664) wifi_init: tcp mbox: 6
  27. I (664) wifi_init: tcp tx win: 5744
  28. I (674) wifi_init: tcp rx win: 5744
  29. I (674) wifi_init: tcp mss: 1440
  30. I (684) wifi_init: WiFi IRAM OP enabled
  31. I (684) wifi_init: WiFi RX IRAM OP enabled
  32. I (784) phy: phy_version: 4500, 0cd6843, Sep 17 2020, 15:37:07, 0, 0
  33. I (784) wifi:mode : sta (24:0a:c4:1d:2c:84)
  34. ADC i2s read: 1543 1542 1458 1456 1425 1415 1374 1392 1370 1395 1415 1457 1536 1536 1567 1592 1648 1663 1663 1713 1760 1712 1722 1663 1639 1553 1536 1457 1427 1390 1394 1381 1392 1378 1437 1395 1424 1423 1437 1409 1432 1423 1434 1423 1404 1390 1343 1279 1279 1338 1361 1432 1536 1584 1590 1750 1785 1840 1852 1905 1855 1852 1789 1731 1663 1648 1567 1536 1459 1458 1409 1402 1379 1333 1279 1279 1264 1259 1262 1264 1279 1339 1422 1451 1536 1546 1599 1615 1642 1642 1663 1627 1645 1599 1599 1543 1539 1536 1536 1434
  35. ADC i2s read: 1432 1411 1439 1439 1536 1536 1575 1596 1648 1663 1712 1735 1754 1735 1777 1791 1695 1663 1599 1563 1536 1536 1536 1628 1663 1791 1875 1978 2008 2048 1997 1975 1887 1791 1695 1599 1457 1359 1279 1231 1206 1251 1339 1465 1566 1695 1809 1823 1847 1835 1773 1663 1663 1564 1555 1536 1547 1551 1627 1663 1776 1843 1965 2011 2096 2134 2166 2171 2169 2131 2096 2003 1989 1965 1919 1912 1895 1910 1923 1962 1984 2048 2063 2131 2175 2207 2207 2207 2151 2091 1974 1905 1791 1753 1707 1695 1715 1763 1791 1888
  36. I (2834) wifi: retry to connect to the AP
  37. I (2834) wifi: connect to the AP fail
  38. ADC i2s read: 1939 1987 2048 2055 2067 2063 2048 1999 2017 1971 1991 1985 2048 2048 2068 2048 2022 1951 1935 1877 1854 1814 1838 1823 1926 1967 2078 2146 2251 2303 2401 2454 2523 2544 2573 2525 2554 2523 2487 2447 2393 2367 2288 2271 2175 2111 2053 1984 1907 1855 1791 1791 1774 1791 1784 1838 1823 1875 1853 1835 1791 1783 1743 1731 1710 1712 1713 1752 1776 1815 1855 1871 1902 1880 1881 1852 1846 1791 1785 1695 1663 1621 1599 1543 1536 1457 1435 1362 1366 1337 1343 1339 1376 1399 1427 1459 1536 1536 1446 1422
  39. ADC i2s read: 1376 1333 1265 1272 1240 1250 1231 1279 1329 1421 1439 1536 1539 1564 1536 1537 1536 1456 1407 1373 1341 1279 1279 1279 1279 1279 1264 1236 1231 1183 1151 1145 1180 1202 1270 1340 1439 1541 1648 1695 1776 1791 1855 1791 1791 1721 1663 1587 1536 1432 1411 1376 1387 1398 1432 1536 1536 1543 1594 1614 1630 1625 1639 1637 1626 1650 1599 1663 1648 1663 1663 1735 1734 1757 1760 1771 1712 1713 1663 1649 1551 1536 1446 1408 1329 1279 1279 1279 1279 1328 1362 1383 1423 1439 1461 1414 1425 1392 1428 1466
  40. I (4884) wifi: retry to connect to the AP
  41. I (4884) wifi: connect to the AP fail
  42. ADC i2s read: 1551 1616 1728 1810 1915 1968 2050 2074 2129 2079 2092 2049 2014 1919 1855 1750 1663 1621 1587 1551 1536 1536 1540 1581 1582 1632 1661 1709 1710 1753 1777 1823 1821 1855 1880 1939 1937 1998 1998 2048 2048 2051 2048 2064 2023 2016 1980 1949 1904 1855 1791 1744 1722 1663 1635 1599 1599 1563 1587 1583 1599 1599 1643 1584 1567 1536 1536 1383 1363 1279 1378 1421 1536 1583 1695 1783 1883 1951 2003 2022 2048 1959 1919 1820 1731 1646 1584 1536 1437 1406 1343 1357 1331 1371 1376 1431 1423 1536 1536 1537
  43. ADC i2s read: 1543 1592 1599 1649 1615 1646 1645 1663 1648 1663 1663 1695 1663 1663 1663 1663 1663 1651 1651 1633 1615 1635 1663 1663 1733 1728 1789 1788 1791 1821 1853 1870 1889 1848 1808 1756 1729 1643 1632 1598 1633 1663 1745 1840 1923 2014 2093 2175 2175 2224 2175 2141 2063 1987 1894 1817 1663 1649 1567 1536 1536 1536 1536 1540 1557 1616 1625 1658 1661 1695 1701 1716 1728 1745 1721 1723 1701 1695 1712 1663 1712 1715 1703 1705 1703 1663 1703 1651 1661 1635 1663 1656 1712 1739 1779 1817 1878 1914 1959 1958
  44. I (6924) wifi: retry to connect to the AP
  45. I (6924) wifi: connect to the AP fail
  46. ADC i2s read: 1997 2005 2059 2048 2073 2063 2048 1981 1919 1872 1823 1791 1779 1823 1875 1999 2050 2175 2253 2303 2400 2481 2473 2483 2414 2417 2303 2258 2146 2099 2014 1977 1916 1895 1855 1843 1852 1855 1855 1871 1889 1913 1951 1987 2015 2055 2111 2111 2144 2160 2175 2175 2230 2207 2215 2175 2175 2168 2153 2104 2099 2048 2048 1997 1983 1951 1951 1971 2001 2002 2062 2094 2131 2159 2175 2175 2175 2175 2096 2048 1918 1829 1721 1707 1661 1663 1712 1785 1838 1935 1968 2048 2054 2063 2003 1942 1835 1734 1599 1536
  47. ADC i2s read: 1363 1273 1183 1114 1063 1011 1013 1008 1087 1127 1216 1248 1359 1395 1536 1567 1648 1663 1743 1747 1791 1782 1791 1776 1791 1785 1763 1735 1712 1710 1714 1663 1703 1663 1695 1703 1708 1729 1728 1756 1742 1773 1734 1753 1731 1731 1712 1744 1663 1663 1598 1553 1459 1445 1392 1437 1453 1543 1599 1718 1831 1901 1991 2048 2065 2062 2048 1984 1899 1791 1695 1591 1536 1420 1392 1279 1279 1279 1279 1329 1400 1410 1536 1536 1599 1629 1663 1663 1727 1719 1751 1725 1726 1712 1720 1715 1742 1727 1718 1743
  48. I (8974) wifi: retry to connect to the AP
  49. I (8974) wifi: connect to the AP fail
  50. ADC i2s read: 1733 1779 1743 1779 1776 1813 1781 1791 1779 1819 1781 1791 1752 1767 1707 1695 1663 1663 1663 1663 1661 1663 1599 1567 1536 1536 1536 1566 1599 1663 1767 1835 1959 2018 2111 2134 2175 2175 2175 2111 2077 1966 1892 1752 1695 1615 1593 1536 1536 1536 1536 1536 1567 1599 1659 1693 1695 1731 1756 1785 1790 1823 1830 1855 1831 1845 1823 1840 1791 1821 1791 1791 1776 1789 1743 1745 1743 1767 1755 1791 1763 1811 1791 1817 1791 1791 1774 1756 1734 1723 1741 1743 1747 1735 1663 1624 1599 1552 1595 1599
  51. ADC i2s read: 1663 1743 1849 1912 2055 2127 2224 2241 2291 2239 2224 2111 2063 1933 1841 1726 1663 1599 1560 1553 1538 1543 1555 1575 1599 1587 1657 1703 1717 1763 1775 1831 1843 1855 1855 1923 1888 1922 1900 1903 1888 1890 1855 1889 1855 1855 1833 1855 1822 1823 1823 1838 1823 1851 1855 1855 1919 1927 1979 1963 2048 1990 2003 1915 1883 1791 1791 1756 1791 1791 1904 1959 2076 2138 2253 2297 2303 2303 2303 2259 2174 2079 1937 1791 1663 1574 1536 1417 1376 1343 1359 1371 1371 1425 1423 1469 1536 1536 1538 1599
  52. I (11024) wifi: retry to connect to the AP
  53. I (11024) wifi: connect to the AP fail
  54. ADC i2s read: 1616 1703 1747 1791 1828 1891 1871 1904 1855 1840 1791 1779 1747 1721 1712 1712 1721 1721 1722 1750 1776 1760 1791 1791 1791 1778 1779 1722 1723 1651 1648 1584 1565 1536 1536 1459 1536 1536 1575 1651 1745 1791 1907 1991 2111 2175 2252 2303 2367 2416 2423 2411 2303 2303 2207 2111 1976 1875 1727 1639 1536 1433 1328 1279 1260 1265 1267 1279 1343 1426 1466 1551 1582 1599 1598 1599 1584 1543 1536 1434 1372 1279 1272 1219 1238 1229 1279 1363 1458 1543 1648 1663 1790 1785 1823 1815 1791 1765 1743 1695
  55. ADC i2s read: 1663 1627 1585 1536 1536 1466 1536 1536 1542 1617 1703 1791 1895 1999 2065 2146 2156 2160 2111 2105 1970 1899 1776 1663 1567 1464 1395 1382 1343 1360 1383 1462 1536 1599 1663 1755 1823 1904 1941 1969 1990 1951 1951 1886 1853 1757 1712 1639 1625 1555 1586 1563 1626 1648 1723 1749 1823 1855 1895 1907 1904 1855 1814 1738 1703 1599 1587 1560 1558 1583 1629 1629 1639 1643 1643 1663 1649 1663 1743 1843 1910 2051 2127 2255 2297 2303 2303 2303 2256 2222 2111 2048 1914 1842 1776 1763 1752 1782 1791 1823
  56. I (13064) wifi: retry to connect to the AP
  57. I (13064) wifi: connect to the AP fail
  58. ADC i2s read: 1855 1888 1934 1931 1951 1945 1937 1900 1831 1651 1439 1103 736 309 0 0 0 0 0 0 0 0 0 11 113 177 254 297 298 255 250 199 153 79 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 63 255 512 752 962 1136 1279 1366 1392 1451 1536 1562
  59. ADC i2s read: 1662 1855 2023 2223 2303 2519 2586 2751 2874 3159 3542 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095 4095
  60. ADC i2s read: 4095 4095 4095 4095 4095 4095 4095 4095 4095 3804 3565 3371 3327 3238 3225 3153 3083 2939 2815 2642 2480 2303 2169 1999 1823 1663 1536 1373 1150 975 716 465 126 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 46 122 158 236 333 460 562 736 830 975 1053 1183 1197 1254 1255 1279 1279 1337 1279 1343 1279 1200 1151 1131 1042 975 944 911 944 939 1023 1087 1215 1279 1536 1635 I (15114) wifi:new:<11,0>, old:<1,0>, ap:<255,255>, sta:<11,0>, prof:1
  61. 1854 2001 2175 2301 2431 2419 2407
  62. I (15894) wifi:state: init -> auth (b0)
  63. I (15904) wifi:state: auth -> assoc (0)
  64. I (15914) wifi:state: assoc -> run (10)
  65. I (15934) wifi:connected with WA_Guest, aid = 1, channel 11, BW20, bssid = 3e:6f:c9:14:c6:91
  66. I (15934) wifi:security: WPA2-PSK, phy: bgn, rssi: -37
  67. I (15944) wifi:pm start, type: 1
  68.  
  69. I (15944) wifi: other Wifi event: 4
  70.  
  71. I (15954) wifi:AP's beacon interval = 102400 us, DTIM period = 1
  72. ADC i2s read: 2303 2175 1968 1758 1536 1279 979 704 384 76 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 26 19 85 89 163 208 307 364 476 526 639 711 783 844 944 1037 1107 1190 1273 1360 1439 1551 1646 1774 1855 1976 2076 2175 2246 2359 2390 2503 2543 2623 2674 2719 2739 2787 2771 2803 2787 2811 2798 2805 2771 2774 2736 2687 2623 2544 2494 2407 2387 2291 2275 2207 2175 2111 2151 2065 2051 1969 1982 1931 1968 1950 1999 1970 1948 1855 1843 1773 1747 1695
  73. ADC i2s read: 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695
  74. ADC i2s read: 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695
  75. ADC i2s read: 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695
  76. ADC i2s read: 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695
  77. I (20074) esp_netif_handlers: sta ip: 192.168.137.42, mask: 255.255.255.0, gw: 192.168.137.1
  78. I (20074) wifi: got ip:192.168.137.42
  79. I (20084) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
  80. W (20084) MQTT_CLIENT: Transport config set, but overridden by scheme from URI: transport = 1, uri scheme = mqtt
  81. I (20094) wa sntp clock: sntp clock init.
  82.  
  83. I (20094) MQTT app: MQTT client connect websocket
  84.  
  85. I (20094) mqtt cli: Other event id:7
  86. I (20164) mqtt cli: MQTT_EVENT_CONNECTED
  87. I (20194) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=62933
  88. I (20224) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=64191
  89. I (20224) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=10369
  90. I (20244) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=62742
  91. I (20244) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=61251
  92. I (20264) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=13084
  93. I (20274) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=9854
  94. I (20274) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=61908
  95. I (20294) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=22554
  96. I (20294) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=48347
  97. ADC i2s read: 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695
  98. I (20974) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=28178
  99. ADC i2s read: 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695
  100. I (21934) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=61281
  101. ADC i2s read: 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695 1695
  102. I (22904) mqtt cli: MQTT_EVENT_PUBLISHED, msg_id=43482

Darmann
Posts: 2
Joined: Sun Mar 04, 2018 12:40 pm

Re: ESP32 ADC & WiFi problem

Postby Darmann » Tue Mar 23, 2021 7:31 pm

Hello!

I have a similar problem. On my project I'm writing very large data directly to an sd-card without filesystem. So I'm using sdmmc_write_sectors_dma().
Everything is ok until I make a wifi connection to my esp32-wroom32.

Please check out, that I write 100MB to the sd-card in chunks of 8kb. But after connecting with wifi the spi communcation stops working.
I think there is a problem with DMA and wifi (or NVS access?).

Code: Select all

I (2320) AirCaptureEsp32: logging new file index=163
I (5510) AirCaptureEsp32: written to sd-card: filesize=1572864
I (10510) AirCaptureEsp32: written to sd-card: filesize=6209536
I (15510) AirCaptureEsp32: written to sd-card: filesize=10838016
I (20510) AirCaptureEsp32: written to sd-card: filesize=14319616
I (25510) AirCaptureEsp32: written to sd-card: filesize=18956288
I (30510) AirCaptureEsp32: written to sd-card: filesize=23584768
I (35510) AirCaptureEsp32: written to sd-card: filesize=28213248
I (40510) AirCaptureEsp32: written to sd-card: filesize=32849920
I (41280) AirCaptureEsp32: logging new file index=164
I (45530) AirCaptureEsp32: written to sd-card: filesize=3260416
I (50520) AirCaptureEsp32: written to sd-card: filesize=7610368
I (55520) AirCaptureEsp32: written to sd-card: filesize=12247040
I (60520) AirCaptureEsp32: written to sd-card: filesize=16875520
I (65510) AirCaptureEsp32: written to sd-card: filesize=21504000
I (70510) AirCaptureEsp32: written to sd-card: filesize=26140672
I (75520) AirCaptureEsp32: written to sd-card: filesize=29827072
I (79570) AirCaptureEsp32: logging new file index=165
I (80520) AirCaptureEsp32: written to sd-card: filesize=884736
I (85520) AirCaptureEsp32: written to sd-card: filesize=5521408
I (90520) AirCaptureEsp32: written to sd-card: filesize=10149888
I (95520) AirCaptureEsp32: written to sd-card: filesize=14786560
I (100520) AirCaptureEsp32: written to sd-card: filesize=19349504
I (105520) AirCaptureEsp32: written to sd-card: filesize=23109632
I (110510) AirCaptureEsp32: written to sd-card: filesize=27729920
I (115510) AirCaptureEsp32: written to sd-card: filesize=32366592
I (116820) AirCaptureEsp32: logging new file index=166
I (120520) AirCaptureEsp32: written to sd-card: filesize=3416064
I (125510) AirCaptureEsp32: written to sd-card: filesize=8044544
I (129940) wifi:new:<6,0>, old:<6,0>, ap:<6,0>, sta:<255,255>, prof:6
I (129950) wifi:station: a4:c4:94:51:59:73 join, AID=1, bgn, 20
I (129960) AirCaptureEsp32: station a4:c4:94:51:59:73 join, AID=1
I (129970) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 172.16.0.2
I (129970) AirCaptureEsp32: IP_EVENT_AP_STAIPASSIGNED
I (130530) AirCaptureEsp32: written to sd-card: filesize=11837440
W (130570) wifi:<ba-add>idx:4 (ifx:1, a4:c4:94:51:59:73), tid:0, ssn:38, winSize:64
E (133080) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x109
I (133080) AirCaptureEsp32: write to sd-card failed: filesize=14082048

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: ESP32 ADC & WiFi problem

Postby WiFive » Tue Mar 23, 2021 9:39 pm

ziyun_cloud wrote: Hi there!
I'm working on a project that use ESP32's ADC1 read some data and send them to server, but there are some problems I've met.
If I use API adc1_get_raw() to read sensor directly, everything works just fine. But if I use dma method i2s_read() to read sensors, the i2s will output uncertain constant values after wifi event WIFI_EVENT_STA_CONNECTED. In this case, close the AP won't make adc output back to normal.
Is the initial configuration of my component incorrect, or is there some bugs with the chip or IDF, or adc1 with dma just won't work with wifi station mode?

https://github.com/espressif/esp-idf/issues/3714

Who is online

Users browsing this forum: Baidu [Spider] and 237 guests