pythag / pc-60fw-esp32-logger

An Arduino sketch to read blood oxygen saturation and pulse rate from a PC-60FW Bluetooth Oximeter, store readings in flash, then display them in a web browser.
MIT License
0 stars 0 forks source link

Web server not working #1

Open Rejang-IT-King opened 2 years ago

Rejang-IT-King commented 2 years ago

test with below ino is working, but not working with your code.

include // quote to use ETH

include

include // Introduce corresponding libraries

define ETH_ADDR 1

define ETH_POWER_PIN 16//-1 //16 // Do not use it, it can cause conflict during the software reset.

define ETH_POWER_PIN_ALTERNATIVE 16 //17

define ETH_MDC_PIN 23

define ETH_MDIO_PIN 18

define ETH_TYPE ETH_PHY_LAN8720

define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT // ETH_CLOCK_GPIO0_IN

IPAddress local_ip(192, 168, 0, 124); IPAddress gateway(192, 168, 0, 1); IPAddress subnet(255, 255, 255, 0); IPAddress dns1(8, 8, 8, 8); IPAddress dns2 = (uint32_t)0x00000000;

// Web page String myhtmlPage = String("") + "\r\n" + "" + "\r\n" + "" + "\r\n" + " ESP32 WebServer Test" + "\r\n" + " " + "\r\n" + "" + "\r\n" + "" + "\r\n" + " <div id=\"txtRandomData\">Unkwon

" + "\r\n" + " <input type=\"button\" value=\"random\" onclick=\"getData()\">" + "\r\n" + "" + "\r\n" + "";

WebServer server(80); // Declare the WebServer object

void handleRoot() // Callback { server.send(200, "text/html", myhtmlPage); //!!! Note that returning to the web page requires "text / html" !!! }

void handleAjax() // Callback { String message = "Random data: "; message += String(random(10000)); // Get random number server.send(200, "text/plain", message); // Send message back to page }

static bool eth_connected = false;

void WiFiEvent(WiFiEvent_t event) { switch (event) { case SYSTEM_EVENT_ETH_START: Serial.println("ETH Started"); //set eth hostname here ETH.setHostname("esp32-ethernet"); break; case SYSTEM_EVENT_ETH_CONNECTED: Serial.println("ETH Connected"); break; case SYSTEM_EVENT_ETH_GOT_IP: Serial.print("ETH MAC: "); Serial.print(ETH.macAddress()); Serial.print(", IPv4: "); Serial.print(ETH.localIP()); if (ETH.fullDuplex()) { Serial.print(", FULL_DUPLEX"); } Serial.print(", "); Serial.print(ETH.linkSpeed()); Serial.println("Mbps"); eth_connected = true; break; case SYSTEM_EVENT_ETH_DISCONNECTED: Serial.println("ETH Disconnected"); eth_connected = false; break; case SYSTEM_EVENT_ETH_STOP: Serial.println("ETH Stopped"); eth_connected = false; break; default: break; } }

void setup() { pinMode(ETH_POWER_PIN_ALTERNATIVE, OUTPUT); digitalWrite(ETH_POWER_PIN_ALTERNATIVE, HIGH); Serial.begin(115200); delay(2500); Serial.println("hello");

WiFi.onEvent(WiFiEvent);

ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLK_MODE); // Enable ETH

//ETH.config(local_ip, gateway, subnet, dns1, dns2); // Static IP, leave without this line to get IP via DHCP

while(!((uint32_t)ETH.localIP())){}; // Waiting for IP (leave this line group to get IP via DHCP)

server.on("/", handleRoot); // Register link and callback function server.on("/getRandomData", HTTP_GET, handleAjax); // Request and callback function of the get method sent by ajax in the registration web page

server.begin(); // Start server Serial.println("Web server started"); }

void loop() { server.handleClient(); // Handling requests from clients }

pythag commented 2 years ago

Can you confirm what hardware you're running this on? (including board revision if you can find it).

Are you able to paste the debug output from the serial console here?

Many Thanks, Martin.

pythag commented 2 years ago

It looks like you have slightly different hardware.

Change line 420 FROM:

ETH.begin(0, -1, 23, 18, ETH_PHY_LAN8720, ETH_CLOCK_GPIO17_OUT);

TO:

ETH.begin(1, 16, 23, 18, ETH_PHY_LAN8720, ETH_CLOCK_GPIO17_OUT);

Hope that helps! Martin.

Rejang-IT-King commented 2 years ago

Thanks! it's working.

Rejang-IT-King commented 2 years ago

My board as below, Wireless-Tag ETH01 image

Hi, not sure why just one records appear on webpage? image

Below is output from my terminal

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:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1216 ho 0 tail 12 room 4 load:0x40078000,len:10944 load:0x40080400,len:6388 entry 0x400806b4

E (61) psram: PSRAM ID read error: 0xffffffff

ETH Started File system stats: Used space 502 free space 895819 Starting PC-60FW Pulse Oximeter proxy... Starting scan... ETH Connected ETH MAC: 0C:DC:7E:5D:9C:F3, IPv4: 192.168.0.124, FULL_DUPLEX, 100Mbps Sending NTP request... Time set from NTP response. BLE Advertised Device found: Name: PC-60F_SN8161XX, Address: f5:05:b8:9a:73:3d, serviceUUID: 6e400001-b5a3-f393-e0a9-e50e24dcca9e Forming a connection to f5:05:b8:9a:73:3d

After confirm clear data got error below:- image

Rejang-IT-King commented 2 years ago

after reset few time got different result as below:- but only 2 line show up. image

How to set time to UTC +8 ?

Rejang-IT-King commented 2 years ago

Got error after I try refresh website 5 times or above continually.

Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception) Debug exception reason: Stack canary watchpoint triggered (TaskWebHandler) Core 0 register dump: PC : 0x400904b5 PS : 0x00060636 A0 : 0x00060630 A1 : 0x3ffdab30
A2 : 0x3ffdb784 A3 : 0x3ffdaf30 A4 : 0x00000007 A5 : 0x00000010
A6 : 0x00000007 A7 : 0x3ffdae54 A8 : 0x8010579c A9 : 0x00000007
A10 : 0x3fff5a68 A11 : 0x3f4002b8 A12 : 0x3fff5a6f A13 : 0x00000001
A14 : 0x00000008 A15 : 0x3ffc8798 SAR : 0x0000000a EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000 LBEG : 0x40093aa9 LEND : 0x40093ab9 LCOUNT : 0xfffffffe

ELF file SHA256: 0000000000000000

Backtrace: 0x400904b5:0x3ffdab30 0x0006062d:0x3ffdac20 0x400face1:0x3ffdaf30 0x400d85e8:0x3ffdaff0 0x400d7cfa:0x3ffdb070 0x400d1b71:0x3ffdb0a0 0x401f8d31:0x3ffdb550 0x400dd456:0x3ffdb570 0x400dd505:0x3ffdb590 0x400dd572:0x3ffdb5c0 0x400dd6f6:0x3ffdb610 0x400d0f1d:0x3ffdb660 0x40095a56:0x3ffdb680

Rebooting...

pythag commented 2 years ago

The system only records new data at most once per minute (it doesn't really make much sense to record data more often).

With regards to the crash - I think this is a real bug.

Please can you try changing line 445:

 xTaskCreatePinnedToCore(
  TaskWebHandler
  ,  "TaskWebHandler"
  ,  3072  // This stack size can be checked & adjusted by reading the Stack Highwater
  ,  NULL
  ,  2  // Priority (3=High, 0=Low)
  ,  NULL 
  ,  0); // Arduino loop is run on core 1, so use core 0 here

TO

xTaskCreatePinnedToCore(
  TaskWebHandler
  ,  "TaskWebHandler"
  ,  10240  // This stack size can be checked & adjusted by reading the Stack Highwater
  ,  NULL
  ,  2  // Priority (3=High, 0=Low)
  ,  NULL 
  ,  0); // Arduino loop is run on core 1, so use core 0 here

(i.e. change the stack size of the web server task from 3k to 10k).

If this fixes your issue I'll commit this fix to the code.

Many thanks for spotting this, Martin.

Rejang-IT-King commented 2 years ago

Thanks, it's work and better than before. May i request post result to to MQTT like format below? deviceid\heartrate deviceid\pulse deviceid\connection

Really appreciate your work! Ting.