Skip to content

Instantly share code, notes, and snippets.

@reacto11mecha
Forked from iqfareez/captive_portal_login.ino
Last active August 6, 2025 06:23
Show Gist options
  • Select an option

  • Save reacto11mecha/9763e13a0840c2d0a722f8cfe5f23f2c to your computer and use it in GitHub Desktop.

Select an option

Save reacto11mecha/9763e13a0840c2d0a722f8cfe5f23f2c to your computer and use it in GitHub Desktop.
Login to WIFI UNJ Mahasiswa
#include <WiFi.h>
#include <Wire.h>
#include <HTTPClient.h>
#define AP_SSID "UNJ Hotspot (Mahasiswa)"
#define AP_PASSWORD "" // Kosong karena wifi mahasiswa ga ada input pw
const String username = "1111111"; // NIM
const String password = "blahblah"; // Password wifi
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
// Connecting to the WIFI AP
WiFi.begin(AP_SSID, AP_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to the WiFi network");
// Login to Captive Portal
HTTPClient login;
login.begin("http://192.168.0.1/login.html");
// Black magic
String body = "username=" + String(username) + "&password=" + String(password) + "&buttonClicked=4&err_flag=0&err_msg=&info_flag=0&info_msg=&redirect_url=&network_name=Guest+Network";
int res = login.POST(body);
Serial.println(res);
if (res == 200) {
Serial.println("Login ke wifi unj berhasil!");
} else if (res == 100) {
Serial.println("Udah pernah login, sung aja");
}
login.end();
}
void loop() {
// put your main code here, to run repeatedly:
HTTPClient http;
http.begin("https://www.google.com/");
int res = http.GET();
Serial.println(res); // status code
Serial.println(http.getString()); // API response
delay(2000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment