Community discussions

MikroTik App
 
Rockford0310
just joined
Topic Author
Posts: 1
Joined: Thu Nov 11, 2021 9:18 am

ESP8266 API login to Mikrotik RouterOS

Fri Nov 12, 2021 10:40 am

Dear All, looking for help to initiate API login of ESP8266 to RouterOS using Arduino IDE.. I grab this script from the internet but no success. Please help.

#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>

const char *ssid = "admin";
const char *pwd = "1234";
const char *username = "api";
const char *password = "45678";

void setup() {

Serial.begin(9600); //Serial connection
WiFi.begin(ssid, pwd); //WiFi connection

while (WiFi.status() != WL_CONNECTED) { //Wait for the WiFI connection completion

delay(500);
Serial.println("Waiting for connection");

}

}

void loop() {

if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status

HTTPClient http; //Declare object of class HTTPClient

http.begin("http://11.0.0.1/api/user/login"); //Specify request destination
http.addHeader("Content-Type", "text/plain"); //Specify content-type header

int httpCode = http.POST("username, password"); //Send the request
String payload = http.getString(); //Get the response payload

Serial.println(httpCode); //Print HTTP return code
Serial.println(payload); //Print request response payload

http.end(); //Close connection

} else {

Serial.println("Error in WiFi connection");

}

delay(30000); //Send a request every 30 seconds

}
 
eruma94
just joined
Posts: 1
Joined: Thu Oct 07, 2021 2:49 am

Re: ESP8266 API login to Mikrotik RouterOS

Thu Jun 16, 2022 6:43 am

Hi
@Rockford0310

Have you manage to communicate to mikrotikAPI using esp8266 ?
 
Topito1990
just joined
Posts: 1
Joined: Sat Jan 20, 2024 7:44 am

Re: ESP8266 API login to Mikrotik RouterOS

Sat Jan 20, 2024 7:49 am

Hello I have the same problem I can connect to hotspot but I don't have access as admin

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot], elbob2002, Ward and 26 guests