sklas / CofFi

7 stars 3 forks source link

Does not work without being connected to a machine #1

Open denizkoekden opened 7 years ago

denizkoekden commented 7 years ago

Hello, I tried flashing it to a Generic ESP8266 Module. I have one with 512k Mem and one with 1M Mem. But it keeps reconnecting (I see it in my router logs).

To make it compile I set this before the Software Serial.

define D2 0 // RX -> GPIO 0

define D1 2 // TX -> GPIO 2

I see it connecting to my router and when opening the IP in the Browser I get a "ERR_CONNECTION_REFUSED" in Chrome.

Could it be that it has to less memory?

I used1M (512K Spliffs) but it does not work. I also tried 160MHz CPU speed and different build configs. Would be good if it works with the cheap generic 2$ boards too.

sklas commented 7 years ago

Hi Deniz,

I think the memory is fine, the sketch takes only about 260k and it would probably not connect at all. It's configured to use a static IP, here 192.168.0.9. Have you checked your router config or adapted the gateway and ip to your router (lines 48-80 in the sketch)?

I don't have a generic ESP8266 here for testing, but I think it should work exactly the same, apart from different GPIO naming.

denizkoekden commented 7 years ago

Hello, yes everything is set.

Here is some Debug output I got, when turning on the Serial port.

I changed the WIfi setup to this (ignore the hostname part):

// serial for cm communication
  mySerial.begin(9600);
  Serial.begin(9600);

  // WLAN-Verbindung herstellen
  WiFi.config(ip, gateway, subnet); // auskommentieren, falls eine dynamische IP bezogen werden soll
  WiFi.begin(ssid, password);
  wifi_station_set_hostname(wiFiHostname); 

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
    // Print the IP address
  Serial.println(WiFi.localIP());

and this is what I get via Serial Monitor when turning on the ESP:

...........
WiFi connected
192.168.178.88
sending NTP packet...

and then when opening the URL in a Browser I get this in Serial Console:

Soft WDT reset

ctx: cont 
sp: 3fff0e30 end: 3fff11c0 offset: 01b0

>>>stack>>>
3fff0fe0:  00000009 3fff1040 3fff1040 4020aa4a  
3fff0ff0:  3ffe98c0 00000000 3fff1070 4020a9c7  
3fff1000:  3fff00a8 00000292 000000ff 40202964  
3fff1010:  00000009 3ffe98c0 3fff1040 4010068c  
3fff1020:  3ffe98c0 3ffe98c0 3fff1070 40206470  
3fff1030:  00000009 3ffe98c0 3fff1090 40202b02  
3fff1040:  00000000 00000000 00000000 4020acfd  
3fff1050:  3fff2b24 000000e5 3fff109c 40206470  
3fff1060:  00000001 00000001 3fff109c 4020adfe  
3fff1070:  3fff2b0c 0000000f 00000000 4020ab28  
3fff1080:  00000001 3fff109c 3ffef46c 40202d0e  
3fff1090:  00000010 3fff1120 00000000 3fff3974  
3fff10a0:  000000ff 000000f1 3fff1100 4020a978  
3fff10b0:  3fff2e44 00000001 3fff1100 4020a9c7  
3fff10c0:  3fff00a8 00000292 00000292 40206470  
3fff10d0:  00000001 00000001 3fff32dc 4020b4be  
3fff10e0:  00000000 3fffc6fc 3fff32dc 40206466  
3fff10f0:  3fff32dc 3ffef51c 3fff32dc 402064a2  
3fff1100:  00000000 00000000 00000000 4020ab28  
3fff1110:  3fff32dc 3ffef51c 3ffef4dc 40206535  
3fff1120:  3fff2e44 0000000f 00000001 40204c1c  
3fff1130:  3ffef51c 3ffef4dc 3ffef4dc 00000001  
3fff1140:  00000001 4020576c 0000000f 4020b4b4  
3fff1150:  00000000 00000000 3ffef4dc 3fff018c  
3fff1160:  00000001 3ffef500 3ffef4dc 40206717  
3fff1170:  3ffe8cd0 00000000 000003e8 4020946f  
3fff1180:  00000000 3fff3854 00000000 402094ea  
3fff1190:  3fffdad0 00000000 3fff0184 40202410  
3fff11a0:  3fffdad0 00000000 3fff0184 4020b2ec  
3fff11b0:  feefeffe feefeffe 3fff01a0 40100718  
<<<stack<<<

edit:

I decoded the Stack:

`Decoding 23 results
0x4020aa4a: String::String(char const*) at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/WString.cpp line 519
0x4020a9c7: String::reserve(unsigned int) at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/WString.cpp line 519
0x40202964: fromCoffeemaker() at C:\Users\Deniz\Documents\Arduino\Coffi/Coffi.ino line 208
0x4010068c: free at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266\umm_malloc/umm_malloc.c line 1733
0x40206470: FunctionRequestHandler::handle(ESP8266WebServer&, HTTPMethod, String) at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WebServer\src\detail/RequestHandlersImpl.h line 53
0x40202b02: getStatus() at C:\Users\Deniz\Documents\Arduino\Coffi/Coffi.ino line 235
0x40206470: FunctionRequestHandler::handle(ESP8266WebServer&, HTTPMethod, String) at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WebServer\src\detail/RequestHandlersImpl.h line 53
0x4020a978: String::changeBuffer(unsigned int) at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/WString.cpp line 519
0x4020a9c7: String::reserve(unsigned int) at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/WString.cpp line 519
0x40202237: std::_Function_handler ::_M_invoke(std::_Any_data const&) at c:\users\deniz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2/functional line 2071
0x4010068c: free at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266\umm_malloc/umm_malloc.c line 1733
0x40206466: std::function ::operator()() const at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WebServer\src\detail/RequestHandlersImpl.h line 53
0x402064a2: FunctionRequestHandler::handle(ESP8266WebServer&, HTTPMethod, String) at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WebServer\src\detail/RequestHandlersImpl.h line 53
0x4020ab28: String::String(String const&) at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/WString.cpp line 519
0x40206535: ESP8266WebServer::_handleRequest() at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WebServer\src\detail/RequestHandlersImpl.h line 53
0x40204c1c: WiFiClient::~WiFiClient() at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src/WiFiClient.cpp line 149
0x4020576c: FunctionRequestHandler::canHandle(HTTPMethod, String) at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WebServer\src\detail/RequestHandlersImpl.h line 53
0x40206717: ESP8266WebServer::handleClient() at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WebServer\src\detail/RequestHandlersImpl.h line 53
0x4020946f: TimeAlarmsClass::serviceAlarms() at C:\Program Files (x86)\Arduino\libraries\TimeAlarms/TimeAlarms.cpp line 266
0x402094ea: TimeAlarmsClass::delay(unsigned long) at C:\Program Files (x86)\Arduino\libraries\TimeAlarms/TimeAlarms.cpp line 266
0x40202410: loop at C:\Users\Deniz\Documents\Arduino\Coffi/Coffi.ino line 668
0x4020b2ec: loop_wrapper at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/core_esp8266_main.cpp line 56
0x40100718: cont_norm at C:\Users\Deniz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/cont.S line 109
`

I use esp8266 by ESP8266 Community Version 2.3.0 as Boardfiles in my Arduino IDE.

Settings: Generic ESP 8266 Module, CPU-Frequency: 80 MHz, Flashmode: DIO, Baudrate: 115200, Flash Size: 1M(512k SPIFFS), Reset Method: ck, Debug Mode: Disabled, Debug Port: None

sklas commented 7 years ago

Hi,

it looks like it can't handle the answer from the coffeemaker. Which model do you have? Could you paste your line 208 which seems causing it?

You could try if you can send to the coffeemaker by calling ip/api?command=on It will probably also crash, but the coffeemaker should turn on before.

You could also comment line 461 (" http_answer = http_answer + "

Status: " + getStatus() + "

"; ") to avoid communication with the coffeemaker on the main page.

denizkoekden commented 7 years ago

It was my fault. I thought it works without being connected to the Machine so I wanted to do a dryrun. But of course it does not.

I tried it with a NodeMCU and with a Wemos D1 Mini now and it works.

So the issue should be "The Code does not work without beeing connected to the Machine".