Advertisement
pleasedontcode

WiFi Monitor rev_01

Mar 19th, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: WiFi Monitor
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-03-19 08:59:05
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* using esp32 control 12 relay via esprainmaker code */
  21.     /* and get live feed back from the 12 manual switch */
  22.     /* show in the esprainmaker */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <WiFi.h>
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31.  
  32. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  33. const uint8_t relay_PIN_D4 = 4;
  34.  
  35. void setup(void)
  36. {
  37.   // put your setup code here, to run once:
  38.  
  39.   pinMode(relay_PIN_D4, INPUT);
  40.  
  41.   // Connect to WiFi network
  42.   WiFi.begin("your_SSID", "your_PASSWORD");
  43.  
  44.   // Wait for connection
  45.   while (WiFi.status() != WL_CONNECTED)
  46.   {
  47.     delay(1000);
  48.     Serial.println("Connecting to WiFi...");
  49.   }
  50.  
  51.   // Print ESP32 Local IP Address
  52.   Serial.println(WiFi.localIP());
  53. }
  54.  
  55. void loop(void)
  56. {
  57.   // put your main code here, to run repeatedly:
  58.  
  59.   // Read the state of the relay_PIN_D4
  60.   int relayState = digitalRead(relay_PIN_D4);
  61.  
  62.   // Print the relay state on the Serial Monitor
  63.   Serial.println(relayState);
  64.  
  65.   delay(1000); // Wait for 1 second before reading again
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement