{"action":"created","issue":{"url":"https://api.github.com/repos/plerup/espsoftwareserial/issues/63","repository_url":"https://api.github.com/repos/plerup/espsoftwareserial","labels_url":"https://api.github.com/repos/plerup/espsoftwareserial/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/plerup/espsoftwareserial/issues/63/comments","events_url":"https://api.github.com/repos/plerup/espsoftwareserial/issues/63/events","html_url":"https://github.com/plerup/espsoftwareserial/issues/63","id":299509143,"number":63,"title":"SoftwareSerial is unstable in 2.4.0","user":{"login":"Anton-V-K","id":20116984,"avatar_url":"https://avatars3.githubusercontent.com/u/20116984?v=4","gravatar_id":"","url":"https://api.github.com/users/Anton-V-K","html_url":"https://github.com/Anton-V-K","followers_url":"https://api.github.com/users/Anton-V-K/followers","following_url":"https://api.github.com/users/Anton-V-K/following{/other_user}","gists_url":"https://api.github.com/users/Anton-V-K/gists{/gist_id}","starred_url":"https://api.github.com/users/Anton-V-K/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Anton-V-K/subscriptions","organizations_url":"https://api.github.com/users/Anton-V-K/orgs","repos_url":"https://api.github.com/users/Anton-V-K/repos","events_url":"https://api.github.com/users/Anton-V-K/events{/privacy}","received_events_url":"https://api.github.com/users/Anton-V-K/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-22T21:09:43Z","updated_at":"2018-02-25T13:03:56Z","closed_at":null,"author_association":"NONE","body":"I've installed ESP8266 core 2.4.0 for Arduino 1.8.5 (Windows 7 SP1 64-bit) and immediately encountered problems when comminucating with one of my sensors (MH-Z19) which is utilized through `SoftwareSerial` library: readings return 0 (zeros) in some uncertain conditions (probably when WiFi-connection is active).\r\nI had to **downgrade ESP8266 core to 2.3.0** to restore stable work with the sensor.\r\n\r\nMCU: LoLin (NodeMCU, esp8266, ESP12-E)\r\n\r\nThe reading code is more-less standard (I haven't changed it for months) - here are few fragments:\r\n```\r\n#  include <SoftwareSerial.h>\r\n\r\nSoftwareSerial co2Serial(MH_Z19_TX, MH_Z19_RX); // define MH-Z19\r\n\r\nvoid CO2_begin()\r\n{\r\n  LOG_println(Fx(\"CO2-sensor: begin(9600)\"));\r\n  co2Serial.begin(9600); //Init sensor MH-Z19(14)\r\n}\r\n\r\nint readCO2()\r\n{\r\n  // command to ask for data (0x86)\r\n  const byte cmd[9] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};\r\n  byte response[9] = { 0 }; // for answer\r\n\r\n  co2Serial.write(cmd, sizeof(cmd)); //request PPM CO2\r\n  co2Serial.readBytes(response, sizeof(response));\r\n#ifdef ENABLE_DIAG\r\n  char raw[64];\r\n  sprintf(raw, \"CO2 RAW: %02X %02X %02X %02X %02X %02X %02X %02X %02X\"\r\n         , response[0], response[1], response[2], response[3]\r\n         , response[4], response[5], response[6], response[7], response[8]);\r\n  LOG_println(raw);\r\n#endif\r\n  if (response[0] != 0xFF)\r\n  {\r\n    LOG_print  (F(\"Wrong starting byte from co2 sensor: 0x\"));\r\n    LOG_println(response[0], HEX);\r\n    return -1;\r\n  }\r\n\r\n  if (response[1] != 0x86)\r\n  {\r\n    LOG_print  (F(\"Wrong command from co2 sensor: 0x\"));\r\n    LOG_println(response[1], HEX);\r\n    return -1;\r\n  }\r\n\r\n  const int responseHigh = response[2];\r\n  const int responseLow  = response[3];\r\n  const int ppm = (256 * responseHigh) + responseLow;\r\n  return ppm;\r\n}\r\n```\r\nWith `SoftwareSerial` from 2.4.0 the sensor in some situations just returns all zeros:\r\n```\r\n348086: loop: millis() = 348086, 2018-02-22 21:44:40, Thursday\r\n348141: reading data:\r\n349150: CO2 RAW: 00 00 00 00 00 00 00 00 00\r\n349150: Wrong starting byte from co2 sensor: 0x0\r\n349151:   CO2 = -1\r\n349151: CO2 not valid\r\n349479: DHT #1 Humidity = 40.7\r\n349533: DHT #1 Temperature = 18.8\r\n349586:   Free RAM: 19952\r\n349586:   Online Queue: 0\r\n349587: Data reading error #3/15\r\n349587: loop finished, 1501 millis spent\r\n```\r\nI guess, the problem may be caused by other parts of ESP8266 core, but it reveals itself through `SoftwareSerial` class.\r\nAnd it may be related to WiFi-part, since there were similar issues like https://github.com/esp8266/Arduino/issues/2937, https://github.com/esp8266/Arduino/issues/4315"},"comment":{"url":"https://api.github.com/repos/plerup/espsoftwareserial/issues/comments/368307683","html_url":"https://github.com/plerup/espsoftwareserial/issues/63#issuecomment-368307683","issue_url":"https://api.github.com/repos/plerup/espsoftwareserial/issues/63","id":368307683,"user":{"login":"torntrousers","id":12925578,"avatar_url":"https://avatars0.githubusercontent.com/u/12925578?v=4","gravatar_id":"","url":"https://api.github.com/users/torntrousers","html_url":"https://github.com/torntrousers","followers_url":"https://api.github.com/users/torntrousers/followers","following_url":"https://api.github.com/users/torntrousers/following{/other_user}","gists_url":"https://api.github.com/users/torntrousers/gists{/gist_id}","starred_url":"https://api.github.com/users/torntrousers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/torntrousers/subscriptions","organizations_url":"https://api.github.com/users/torntrousers/orgs","repos_url":"https://api.github.com/users/torntrousers/repos","events_url":"https://api.github.com/users/torntrousers/events{/privacy}","received_events_url":"https://api.github.com/users/torntrousers/received_events","type":"User","site_admin":false},"created_at":"2018-02-25T13:03:56Z","updated_at":"2018-02-25T13:03:56Z","author_association":"NONE","body":"I see similar with SoftwareSerial and a GPS module at 9600 baud. Really unstable, missing lots of bytes and regular crashes. Same setup and sketch is rock solid going back to 2.3.0.\r\nException decoder of crash is:\r\n\r\nException (0):\r\nepc1=0x40202c24 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000\r\n\r\nctx: sys \r\nsp: 3ffffc00 end: 3fffffb0 offset: 01a0\r\n\r\n>>>stack>>>\r\n3ffffda0:  3fffc278 40101f8c 3fffc200 00000022  \r\n3ffffdb0:  31af3954 4010696c 3fffc258 4000050c  \r\n3ffffdc0:  40000f83 00000030 00000012 00000020  \r\n3ffffdd0:  ffffffff 00000005 00000000 4010686d  \r\n3ffffde0:  401069a6 000000fc 00000000 40106a00  \r\n3ffffdf0:  c0037015 3ffe8ff4 3ffeea78 401067a5  \r\n3ffffe00:  31adf3f8 00000005 00000000 00000022  \r\n3ffffe10:  3fffc200 4010696c 3fffc258 4000050c  \r\n3ffffe20:  4000437d 00000030 00000012 ffffffff  \r\n3ffffe30:  60000200 00000008 34033402 80000000  \r\n3ffffe40:  20000000 3fff15c0 80000000 203fc0c0  \r\n3ffffe50:  80000000 3ffe8ff4 3ffee478 3fff15c4  \r\n3ffffe60:  000001b4 003fc0c0 60000600 00000030  \r\n3ffffe70:  40221e5c 00000030 00000012 ffffffff  \r\n3ffffe80:  40222edd 00000000 ffffffff fffedf88  \r\n3ffffe90:  3ffee478 40222ed4 3ffee478 00000c37  \r\n3ffffea0:  3ffee478 3ffe8ff4 3ffee478 3ffed2f4  \r\n3ffffeb0:  3ffee4a0 009eed2a 60000600 00000030  \r\n3ffffec0:  4020fa58 00000000 3fff01b8 000001f4  \r\n3ffffed0:  4020a058 3ffe8ef8 3ffe8ef8 401004d8  \r\n3ffffee0:  3ffeb3f0 000000dd 3ffeb40a 4020fd8c  \r\n3ffffef0:  3ffeb410 3ffeb3f0 3fff01b8 40209414  \r\n3fffff00:  3ffeecd0 00000007 3ffe8ef8 40209450  \r\n3fffff10:  00000000 400042db 3ffe8ff4 00000000  \r\n3fffff20:  40004b31 3fff1584 000001f4 003fc080  \r\n3fffff30:  40105acc 000001f4 3ffed480 401004f4  \r\n3fffff40:  40106ddd 3fff1584 00000000 009eed2a  \r\n3fffff50:  40104e5a 3ffed2f4 3ffed480 40223ec6  \r\n3fffff60:  40222edd 40222ee6 3ffed2f4 3ffee4a0  \r\n3fffff70:  40228215 3ffee4a0 3ffee478 40228215  \r\n3fffff80:  4022825a 3fffdab0 00000000 3fffdcb0  \r\n3fffff90:  3ffee4c8 3fffdab0 00000000 40202b4f  \r\n3fffffa0:  40000f49 40000f49 3fffdab0 40000f49  \r\n<<<stack<<<\r\n\r\n ets Jan  8 2013,rst cause:2, boot mode:(3,6)\r\n\r\nload 0x4010f000, len 1384, room 16 \r\ntail 8\r\nchksum 0x2d\r\ncsum 0x2d\r\nv4ceabea9\r\n~ld\r\n\r\nPaste your stack trace here\r\n\r\nException 0: Illegal instruction\r\nDecoding 38 results\r\n0x40202c24: optimistic_yield at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\cores\\esp8266/core_esp8266_main.cpp line 57\r\n0x40101f8c: wDev_ProcessFiq at ?? line ?\r\n0x4010696c: interrupt_handler at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\cores\\esp8266/core_esp8266_wiring_digital.c line 122\r\n0x4010686d: sws_isr_5() at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\libraries\\SoftwareSerial/SoftwareSerial.cpp line 131\r\n0x401069a6: interrupt_handler at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\cores\\esp8266/core_esp8266_wiring_digital.c line 128\r\n0x40106a00: interrupt_handler at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\cores\\esp8266/core_esp8266_wiring_digital.c line 147\r\n0x401067a5: EspClass::getCycleCount() at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\libraries\\SoftwareSerial/SoftwareSerial.cpp line 131\r\n:  (inlined by) SoftwareSerial::rxRead() at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\libraries\\SoftwareSerial/SoftwareSerial.cpp line 216\r\n0x4010696c: interrupt_handler at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\cores\\esp8266/core_esp8266_wiring_digital.c line 122\r\n0x40221e5c: rc_only_sta_trc at ?? line ?\r\n0x40222edd: esf_buf_setup at ?? line ?\r\n0x40222ed4: esf_buf_setup at ?? line ?\r\n0x4020fa58: sntp_retry at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/apps/sntp/sntp.c line 612\r\n0x4020a058: cyclic_timer at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/timeouts.c line 165\r\n0x401004d8: malloc at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\cores\\esp8266\\umm_malloc/umm_malloc.c line 1668\r\n0x4020fd8c: mem_malloc at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/mem.c line 136\r\n0x40209414: do_memp_malloc_pool at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/memp.c line 231\r\n0x40209450: memp_malloc at /home/david/dev/esp8266/origin/tools/sdk/lwip2/builder/lwip2-src/src/core/memp.c line 231\r\n0x40105acc: spi_flash_read at ?? line ?\r\n0x401004f4: calloc at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\cores\\esp8266\\umm_malloc/umm_malloc.c line 1688\r\n0x40106ddd: __wrap_spi_flash_read at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\cores\\esp8266/core_esp8266_phy.c line 267\r\n0x40104e5a: ets_timer_setfn at ?? line ?\r\n0x40223ec6: pm_open at ?? line ?\r\n0x40222edd: esf_buf_setup at ?? line ?\r\n0x40222ee6: esf_buf_setup at ?? line ?\r\n0x40228215: ets_timer_handler_isr at ?? line ?\r\n0x40228215: ets_timer_handler_isr at ?? line ?\r\n0x4022825a: ets_timer_handler_isr at ?? line ?\r\n0x40202b4f: loop_task at C:\\Arduino\\ESP8266\\2.4.0-1.8.3\\arduino-1.8.3\\portable\\packages\\esp8266\\hardware\\esp8266\\2.4.0\\cores\\esp8266/core_esp8266_main.cpp line 57\r\n\r\n\r\n"}}
{"actor":{"display_login":"torntrousers"}}