khoih-prog / WiFiWebServer

This is simple yet complete WebServer library for AVR, Portenta_H7, Teensy, SAM DUE, SAMD, STM32, RP2040-based, etc. boards running WiFi modules/shields (WiFiNINA, CYW43439, U-Blox W101, W102, etc.). The functions are similar and compatible to ESP8266/ESP32 WebServer libraries to make life much easier to port sketches from ESP8266/ESP32. Now using WiFiMulti_Generic library
MIT License
105 stars 21 forks source link

CO2-Ampel board support #10

Closed philippesikora closed 3 years ago

philippesikora commented 3 years ago

Thank your for your great job.

I would like to use WiFiWebServer library on CO2-Ampel board with information as below: SAMD21 + WINC1501B (WiFi101)

/ Needed for WINC1501B (WiFi101) library // --------------------------------------

define WINC1501_RESET_PIN (12u) // reset pin

define WINC1501_WAKE_PIN (11u) // wake pin

define WINC1501_CHIP_EN_PIN (10u) // enable pin

define WINC1501_INTN_PIN (13u) // int pin

define WINC1501_SPI SPI

define WINC1501_SPI_CS_PIN (14u) // cs pin

https://github.com/mariolukas/Watterott-CO2-Ampel-Plus-Firmware https://learn.watterott.com/breakouts/co2-ampel/

I tried the following settings with many compilation errors

include

define USE_WIFI_NINA false

define USE_WIFI101 true

Is it possible to make a slight modification on WiFiWebServer library to support CO2-Ampel board running WiFi101 ? Thank you

khoih-prog commented 3 years ago

Hi @philippesikora

The CO2-Ampel board has been implicitly supported, because it's using SAMD21 and WiFi101 library.

You have to follow these steps

  1. Install the CO2-Ampel core by following the instruction in Compile your own traffic light version from the sources
  2. Select the board CO2-Ampel from Arduino IDE
  3. Compile and upload

This is the compile result as well as the illustration

  1. Illustration

Selection_022

  1. Compile result =>OK
In file included from /home/kh/Arduino/khoih-prog_working/WiFiWebServer_GitHub/examples/AdvancedWebServer/AdvancedWebServer.ino:39:0:
/home/kh/Arduino/khoih-prog_working/WiFiWebServer_GitHub/examples/AdvancedWebServer/defines.h:76:4: warning: #warning Using WiFi101 using WiFi101 Library [-Wcpp]
   #warning Using WiFi101 using WiFi101 Library
    ^~~~~~~
In file included from /home/kh/Arduino/khoih-prog_working/WiFiWebServer_GitHub/examples/AdvancedWebServer/defines.h:348:0,
                 from /home/kh/Arduino/khoih-prog_working/WiFiWebServer_GitHub/examples/AdvancedWebServer/AdvancedWebServer.ino:39:
/home/kh/Arduino/libraries/WiFiWebServer-1.3.0/src/WiFiWebServer.h:55:4: warning: #warning Use SAMD architecture from WiFiWebServer [-Wcpp]
   #warning Use SAMD architecture from WiFiWebServer
    ^~~~~~~
In file included from /home/kh/Arduino/khoih-prog_working/WiFiWebServer_GitHub/examples/AdvancedWebServer/defines.h:348:0,
                 from /home/kh/Arduino/khoih-prog_working/WiFiWebServer_GitHub/examples/AdvancedWebServer/AdvancedWebServer.ino:39:
/home/kh/Arduino/libraries/WiFiWebServer-1.3.0/src/WiFiWebServer.h:117:4: warning: #warning Use WiFi101 from WiFiWebServer [-Wcpp]
   #warning Use WiFi101 from WiFiWebServer
    ^~~~~~~
In file included from /home/kh/Arduino/khoih-prog_working/WiFiWebServer_GitHub/examples/AdvancedWebServer/defines.h:348:0,
                 from /home/kh/Arduino/khoih-prog_working/WiFiWebServer_GitHub/examples/AdvancedWebServer/AdvancedWebServer.ino:39:
/home/kh/Arduino/libraries/WiFiWebServer-1.3.0/src/WiFiWebServer.h:141:4: warning: #warning SENDCONTENT_P_BUFFER_SZ using default 4 Kbytes [-Wcpp]
   #warning SENDCONTENT_P_BUFFER_SZ using default 4 Kbytes
    ^~~~~~~
/home/kh/.arduino15/packages/co2ampel/hardware/samd/1.0.7/libraries/WiFi101/src/WiFi.cpp: In member function 'char* WiFiClass::firmwareVersion()':
/home/kh/.arduino15/packages/co2ampel/hardware/samd/1.0.7/libraries/WiFi101/src/WiFi.cpp:343:7: warning: '%d' directive writing between 1 and 3 bytes into a region of size between 1 and 5 [-Wformat-overflow=]
 char* WiFiClass::firmwareVersion()
       ^~~~~~~~~
/home/kh/.arduino15/packages/co2ampel/hardware/samd/1.0.7/libraries/WiFi101/src/WiFi.cpp:343:7: note: directive argument in the range [0, 255]
/home/kh/.arduino15/packages/co2ampel/hardware/samd/1.0.7/libraries/WiFi101/src/WiFi.cpp:356:10: note: 'sprintf' output between 6 and 12 bytes into a destination of size 9
   sprintf(_version, "%d.%d.%d", rev.u8FirmwareMajor, rev.u8FirmwareMinor, rev.u8FirmwarePatch);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sketch uses 59052 bytes (22%) of program storage space. Maximum is 262144 bytes.
Global variables use 3788 bytes of dynamic memory.

Enjoy and be safe,

Good Luck,

philippesikora commented 3 years ago

Thank you for your quick reply. I used AdvancedWebServer example, select the board CO2-Ampel from Arduino IDE, compile (set my ssid[ ] & pass[ ] ) and upload successfully to the board I got the following result on serial monitor:

Starting AdvancedServer on SAMD MKR1000 with WiFi101 using Wifi101 Library WiFiWebServer v1.3.0 Connecting to WPA SSID: sceslaw HTTP server started @ 3003623616

I cannot see my IP address

khoih-prog commented 3 years ago

The very old WiFi101 library uses the medieval way to return IP address in uint32_t, such as

uint32_t localIP();

whereas the modern library returns IPAddress, such as

IPAddress localIP();

The 3003623616 in uint32_t is IPAddress(192, 168, 7, 179) or 192.168.7.179 or B3,07,A8,C0 in HEX

You have to use a cast to convert from uint32_t to IPAddress to modify WiFi.localIP() in the code from

Serial.print(F("HTTP server started @ "));
Serial.println(WiFi.localIP());

to

Serial.print(F("HTTP server started @ "));
Serial.println( (IPAddress) WiFi.localIP());

to print the normal IP = 192.168.7.179