This shows you the differences between two versions of the page.
|
iothings:laboratoare:2025:lab12 [2026/01/03 22:36] dan.tudose [4. Wi‑Fi Webserver + BME680 Sensor Data] |
iothings:laboratoare:2025:lab12 [2026/01/03 23:05] (current) dan.tudose [Build, flash, test] |
||
|---|---|---|---|
| Line 197: | Line 197: | ||
| ==== Configure the Project ==== | ==== Configure the Project ==== | ||
| - | Create a new folder, e.g. ''sparrow_web_bme'' and unzip the project {{:iothings:laboratoare:2025:sparow_web_bme.zip|here}}. | + | Create a new folder, e.g. ''sparrow_web'' and unzip the project {{:iothings:laboratoare:2025:sparrow_littlefs_ws.zip|here}}. |
| ==== Build, flash, test ==== | ==== Build, flash, test ==== | ||
| Line 212: | Line 212: | ||
| </code> | </code> | ||
| - | Open serial output and note the printed IP address. | + | |
| - | From a machine on the same LAN, open ''http://[device-ip]:[port]'' | + | The code runs a HTTP static file server backed by LittleFS and auto-started at boot; it serves files from /lfs/www on port 8080 and uses the HTTP server’s static_fs handler. |
| + | |||
| + | In the serial shell, you need to run the following commands: | ||
| + | |||
| + | 1. Connect to WiFi: | ||
| + | <code> | ||
| + | wifi scan | ||
| + | wifi connect -s "SSID" -p "PASS" -k 1 | ||
| + | wifi status | ||
| + | </code> | ||
| + | |||
| + | 2. Check the webserver is up and running and get the board IP address: | ||
| + | <code> | ||
| + | net http | ||
| + | net iface | ||
| + | </code> | ||
| + | |||
| + | 3. Write a simple index.html file into ''/lfs/www'': | ||
| + | <code>fs write /lfs/www/index.html -o 0 3c 68 31 3e 48 69 3c 2f 68 31 3e</code> | ||
| + | |||
| + | 4. Browse: http://[board-ip]:8080/ | ||
| Expected: | Expected: | ||
| - | * browser receives a response containing the latest sensor values | + | * browser receives a response containing "Hi" |
| - | ==== Troubleshooting ==== | + | <note>Assignment: Add a dynamic HTTP endpoint that serves the current contents of bme_log.dat as an HTML page with a 10‑second auto‑refresh. So, if you conect to http://[board-ip]:8080/bme_log it will automatically serve the contents of the log file.</note> |
| - | * No Wi‑Fi logs: | + | |
| - | * raise log level (e.g. default level or module-specific) | + | |
| - | * ensure Wi‑Fi mgmt is enabled | + | |
| - | * No IP address: | + | |
| - | * verify DHCP is enabled | + | |
| - | * ensure DHCP is started after link is up | + | |
| - | * “memory allocation failed” from Wi‑Fi adapter: | + | |
| - | * reduce concurrent HTTP clients | + | |
| - | * reduce buffer sizes (HTTP response buffer) | + | |
| - | * avoid repeated dynamic allocations in the HTTP thread | + | |
| - | * consider increasing heap pool size only if you have flash/RAM headroom | + | |
| - | * Browser connects but gets no response: | + | |
| - | * verify socket calls are using Zephyr’s socket headers | + | |
| - | * verify server binds to INADDR_ANY on the chosen port | + | |
| - | * ensure response includes valid HTTP headers and CRLF | + | |