Advertisement
pleasedontcode

WiFi Monitor rev_02

Mar 19th, 2024
48
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 09:04:06
  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.  
  26. /********* User code review feedback **********
  27. #### Feedback 1 ####
  28. - using esp32 control 12 relay via esprainmaker code and get live
  29. feed back from the 12 manual switch show in the esprainmaker
  30.  
  31. ********* User code review feedback **********/
  32.  
  33. /****** DEFINITION OF LIBRARIES *****/
  34. #include <WiFi.h>
  35.  
  36. /****** FUNCTION PROTOTYPES *****/
  37. void setup(void);
  38. void loop(void);
  39.  
  40. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  41. const uint8_t relay_PIN_D4 = 4;
  42.  
  43. void setup(void)
  44. {
  45.   // put your setup code here, to run once:
  46.  
  47.   pinMode(relay_PIN_D4, INPUT_PULLUP);
  48.  
  49.   // Connect to WiFi network
  50.   WiFi.begin("your_SSID", "your_PASSWORD");
  51.  
  52.   // Wait for connection
  53.   while (WiFi.status() != WL_CONNECTED)
  54.   {
  55.     delay(1000);
  56.     Serial.println("Connecting to WiFi...");
  57.   }
  58.  
  59.   // Print ESP32 Local IP Address
  60.   Serial.begin(115200);
  61.   Serial.println();
  62.   Serial.print("Connected to WiFi. IP Address: ");
  63.   Serial.println(WiFi.localIP());
  64. }
  65.  
  66. void loop(void)
  67. {
  68.   // put your main code here, to run repeatedly:
  69.  
  70.   // Read the state of the relay_PIN_D4
  71.   int relayState = digitalRead(relay_PIN_D4);
  72.  
  73.   // Print the relay state on the Serial Monitor
  74.   Serial.print("Relay State: ");
  75.   Serial.println(relayState);
  76.  
  77.   delay(1000); // Wait for 1 second before reading again
  78. }
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement