02_wifi.ino 626 B

123456789101112131415161718192021222324252627282930313233
  1. #include <WiFi.h>
  2. #define NETWORK "Guest WiFi Signal"
  3. #define PASSWORD "something easy"
  4. #define HOSTNAME "outdoor-weather-station"
  5. void connectWifi() {
  6. WiFi.begin(NETWORK, PASSWORD);
  7. debug("Connecting to wifi ..");
  8. while (WiFi.status() != WL_CONNECTED) {
  9. debug('.');
  10. showProgress(PROGRESS_BLUE);
  11. delay(500);
  12. }
  13. debugln();
  14. debugln("Connected!");
  15. debuglog("IP: ", WiFi.localIP());
  16. debuglog("Strength: ", WiFi.RSSI());
  17. debuglog("DNS: ", WiFi.dnsIP());
  18. debuglog("Gateway: ", WiFi.gatewayIP());
  19. }
  20. void initWifi() {
  21. WiFi.mode(WIFI_STA);
  22. // Set the hostname
  23. WiFi.setHostname(HOSTNAME);
  24. connectWifi();
  25. }