Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Sa mga nangungulit kung meron tutorial sa arduino piso wifi.

/*

this is not a finished code, pagtulungan natin mabuo,
ive taken parts of code from other sources and put this together
di ko pa mahuli kng pano mg send command to add/delete user sa mk


it gets the ip address of the router, then logs in to the mikrotik router

*/

#include <SPI.h>
#include <Ethernet.h>
#include <TelnetClient.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display


EthernetClient client;
telnetClient tc(client);



// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield

byte mac[] = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};


void setup() {
// You can use Ethernet.init(pin) to configure the CS pin
//Ethernet.init(10); // Most Arduino shields
//Ethernet.init(5); // MKR ETH shield
//Ethernet.init(0); // Teensy 2.0
//Ethernet.init(20); // Teensy++ 2.0
//Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
//Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet

lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();

// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// start the Ethernet connection:
Serial.println("Communicating");
lcd.setCursor(0,0);
lcd.print("Communicating");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
lcd.setCursor(0,0);
lcd.print("Failed to configure Ethernet");
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
lcd.setCursor(0,0);
lcd.print("Ethernet shield was not found.");
} else if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
lcd.setCursor(0,0);
lcd.print("Ethernet cable is not connected.");
}
// no point in carrying on, so do nothing forevermore:
while (true) {
delay(1);
}
}
// print your local IP address:
//Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
lcd.setCursor(0,0);
lcd.print(Ethernet.localIP());
Serial.println(Ethernet.subnetMask());
lcd.setCursor(0,1);
lcd.print(Ethernet.subnetMask());
//Serial.println(Ethernet.gatewayIP());
Serial.println(Ethernet.dnsServerIP());
lcd.setCursor(0,2);
lcd.print(Ethernet.dnsServerIP());

Ethernet.begin (mac, Ethernet.localIP());

//how long the command sent may be long
const uint8_t MAX_OUT_BUFFER_LENGTH = 150;

IPAddress mikrotikRouterIp (Ethernet.dnsServerIP());


//want to use dhcp?
//if (!Ethernet.begin (clientMAC)){
//Serial.println("\r\nDHCP error");
//while(1);
//}


//WICH CHARACTER SHOULD BE INTERPRETED AS "PROMPT"?
tc.setPromptChar('>');

//this is to trigger manually the login
//since it could be a problem to attach the serial monitor while negotiating with the server (it cause the board reset)
//remove it or replace it with a delay/wait of a digital input in case you're not using the serial monitors
//char key = 0;
//Serial.println("\r\npress Enter to begin:");
//do{
// key = Serial.read();
//}while(key<=0);

delay(5000);


//PUT HERE YOUR USERNAME/PASSWORD
if(tc.login(mikrotikRouterIp, "admin", "")){ //tc.login(mikrotikRouterIp, "admin", "", 1234) if you want to specify a port different than 23
tc.sendCommand("ip");
tc.sendCommand("address");
tc.sendCommand("print");

}
else{
Serial.println("login failed");
}
tc.disconnect();




}

void loop() {
switch (Ethernet.maintain()) {
case 1:
//renewed fail
Serial.println("Error: renewed fail");
break;

case 2:
//renewed success
Serial.println("Renewed success");
//print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
break;

case 3:
//rebind fail
Serial.println("Error: rebind fail");
break;

case 4:
//rebind success
Serial.println("Rebind success");
//print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
break;

default:
//nothing happened
break;
}

}
 
Last edited:
bm muna lupit tong topic nato ah
ESP8266 nagamit ko na to para sa IOT via Alexa,
ecoconnect pa po ba to sa modem natin ?
 
ito yata yung kaparehas ng nabili ko piso wifi, mikrotkek yung mainboard, may lcd screen sya, pag hulog ng barya,pipindot sa button,lalabas yung 6 digit na number,yun yung password na ittype dun sa portal,connected na sila, 1 week ago pina configure ko sa seller kasi gusto ko ibahin yung time, yung software na gamit niya is WINBOX at THE USERMAN, tapos nya mag generate ng mga codes, i copy-paste lang pala sa SDcard yung DOX files,at yun may auto generate password na, punto ko dito kung makabuo kayo at same ng sakin, ibibgay ko yung file na pang SD para di na kayo ma hirapan mag program,kasi copy/paste lang pala. at ito yung time ng vendo ko 1-10minutes 5-1hour 10-2hours 20-12hours 50-2days dati 20-4hours, nilagyan ko promo kasi ganito, imbes na maghulog sila ng 10, eh ginagawa nila 20 kasi 12hours, halos lahat 20 na hinuhulog, sa lima ka tao may 100 ako per day, 3k monthly,sobra sobra na yun pambayad sa bill ng net at kuryente,sakin kasi sideline lang dito sa shop ko, eh kung lumagpas pa dun yung profit e mas maganda
 
ito yata yung kaparehas ng nabili ko piso wifi, mikrotkek yung mainboard, may lcd screen sya, pag hulog ng barya,pipindot sa button,lalabas yung 6 digit na number,yun yung password na ittype dun sa portal,connected na sila, 1 week ago pina configure ko sa seller kasi gusto ko ibahin yung time, yung software na gamit niya is WINBOX at THE USERMAN, tapos nya mag generate ng mga codes, i copy-paste lang pala sa SDcard yung DOX files,at yun may auto generate password na, punto ko dito kung makabuo kayo at same ng sakin, ibibgay ko yung file na pang SD para di na kayo ma hirapan mag program,kasi copy/paste lang pala. at ito yung time ng vendo ko 1-10minutes 5-1hour 10-2hours 20-12hours 50-2days dati 20-4hours, nilagyan ko promo kasi ganito, imbes na maghulog sila ng 10, eh ginagawa nila 20 kasi 12hours, halos lahat 20 na hinuhulog, sa lima ka tao may 100 ako per day, 3k monthly,sobra sobra na yun pambayad sa bill ng net at kuryente,sakin kasi sideline lang dito sa shop ko, eh kung lumagpas pa dun yung profit e mas maganda

boss
pwede pa share ng sayo... ano po yung DOX files

thanks

- - - Updated - - -

/*

this is not a finished code, pagtulungan natin mabuo,
ive taken parts of code from other sources and put this together
di ko pa mahuli kng pano mg send command to add/delete user sa mk


it gets the ip address of the router, then logs in to the mikrotik router

*/

#include <SPI.h>
#include <Ethernet.h>
#include <TelnetClient.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display


EthernetClient client;
telnetClient tc(client);



// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield

byte mac[] = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};


void setup() {
// You can use Ethernet.init(pin) to configure the CS pin
//Ethernet.init(10); // Most Arduino shields
//Ethernet.init(5); // MKR ETH shield
//Ethernet.init(0); // Teensy 2.0
//Ethernet.init(20); // Teensy++ 2.0
//Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
//Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet

lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();

// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// start the Ethernet connection:
Serial.println("Communicating");
lcd.setCursor(0,0);
lcd.print("Communicating");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
lcd.setCursor(0,0);
lcd.print("Failed to configure Ethernet");
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
lcd.setCursor(0,0);
lcd.print("Ethernet shield was not found.");
} else if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
lcd.setCursor(0,0);
lcd.print("Ethernet cable is not connected.");
}
// no point in carrying on, so do nothing forevermore:
while (true) {
delay(1);
}
}
// print your local IP address:
//Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
lcd.setCursor(0,0);
lcd.print(Ethernet.localIP());
Serial.println(Ethernet.subnetMask());
lcd.setCursor(0,1);
lcd.print(Ethernet.subnetMask());
//Serial.println(Ethernet.gatewayIP());
Serial.println(Ethernet.dnsServerIP());
lcd.setCursor(0,2);
lcd.print(Ethernet.dnsServerIP());

Ethernet.begin (mac, Ethernet.localIP());

//how long the command sent may be long
const uint8_t MAX_OUT_BUFFER_LENGTH = 150;

IPAddress mikrotikRouterIp (Ethernet.dnsServerIP());


//want to use dhcp?
//if (!Ethernet.begin (clientMAC)){
//Serial.println("\r\nDHCP error");
//while(1);
//}


//WICH CHARACTER SHOULD BE INTERPRETED AS "PROMPT"?
tc.setPromptChar('>');

//this is to trigger manually the login
//since it could be a problem to attach the serial monitor while negotiating with the server (it cause the board reset)
//remove it or replace it with a delay/wait of a digital input in case you're not using the serial monitors
//char key = 0;
//Serial.println("\r\npress Enter to begin:");
//do{
// key = Serial.read();
//}while(key<=0);

delay(5000);


//PUT HERE YOUR USERNAME/PASSWORD
if(tc.login(mikrotikRouterIp, "admin", "")){ //tc.login(mikrotikRouterIp, "admin", "", 1234) if you want to specify a port different than 23
tc.sendCommand("ip");
tc.sendCommand("address");
tc.sendCommand("print");

}
else{
Serial.println("login failed");
}
tc.disconnect();




}

void loop() {
switch (Ethernet.maintain()) {
case 1:
//renewed fail
Serial.println("Error: renewed fail");
break;

case 2:
//renewed success
Serial.println("Renewed success");
//print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
break;

case 3:
//rebind fail
Serial.println("Error: rebind fail");
break;

case 4:
//rebind success
Serial.println("Rebind success");
//print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
break;

default:
//nothing happened
break;
}

}

Boss
ito ba ang code on demand type?
 
unfinished user / code generator
need to incorporate sa previous post

ang balak ko kasi arduino na mag auto config nya un mikrotik, the arduino can then send commands sa mk to create the user profile, timelimit according sa ihulog na amount. tapos auto delete na rin

meron nang gumagawa nito ala lang mag share ng source code, im just sharing what i have learned, kaya wag nyo akong husgahan kng mali ginagawa ko

kung meron kayo source code ng arduino piso vendo on demand pa share naman dyan



#include <LiquidCrystal_I2C.h>


int i = 0;
int numBytes = 0;
String randString = "";
String letters[62] = {"a", "b", "c", "d", "e", "f","g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0","A", "B", "C", "D", "E", "F","G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};



#define PASSLENGTH 5


LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display

//char bb[] = {"abcdefghijklmnopqrstuvwxyz0123456789"};

void setup()
{
Serial.begin(9600);
lcd.init();
lcd.backlight();
randomSeed(analogRead(0));
}

void loop()
{
lcd.clear();
//if(Serial.available())
//{
//numBytes = Serial.parseInt();
//for(i = 0; i<numBytes; i++)
//{
// function that generates a new password
//if (generatePass == 1)
//{
for (int i = 0; i < PASSLENGTH; i++)


// show password on the display
//lcd.setCursor(0, 1);
//lcd.print(pass);



randString = randString + letters[random(0, 62)];
delay(500);
Serial.println(randString);

// show password on the display
lcd.setCursor(0, 0);
lcd.print(randString);

// erase password from memory
//memset(pass, '\0', PASSLENGTH);

randString = "";
// = 0;




bro Ulshop patingin ng dox file baka makatulung sa ginagawa ko
 
Last edited:
code for coinslot, needs to be modified for use




#include <Wire.h>
#include <LiquidCrystal_I2C.h>

int buttonPress = 0;
int button = 3;
int coinsChange = 0;
//A Coin has been inserted flag

int i = 0;
int numBytes = 0;
String randString = "";
String letters[62] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};



#define PASSLENGTH 5


const int coinInt = 0;
//Attach coinInt to Interrupt Pin 0 (Digital Pin 2). Pin 3 = Interrpt Pin 1.

volatile float coinsValue = 0.00;
//Set the coinsValue to a Volatile float
//Volatile as this variable changes any time the Interrupt is triggered

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup()
{

pinMode(button, OUTPUT);

Serial.begin(9600);
//Start Serial Communication

lcd.begin();
// initialize the LCD

// Turn on the blacklight and print a message.
lcd.backlight();

lcd.setCursor(0, 0);
lcd.print("Please Insert Coin");

attachInterrupt(coinInt, coinInserted, RISING);
//If coinInt goes HIGH (a Pulse), call the coinInserted function
//An attachInterrupt will always trigger, even if your using delays
}

void coinInserted()
//The function that is called every time it recieves a pulse
{
coinsValue = coinsValue + 0.1666666;
delay(2000);
//As we set the Pulse to represent 5p or 5c we add this to the coinsValue
coinsChange = 1;
//Flag that there has been a coin inserted
}


void loop()
{

if (coinsChange == 1)
//Check if a coin has been Inserted
{
coinsChange = 0;
//unflag that a coin has been inserted

Serial.print("Credit: ");
Serial.println(coinsValue);
//Print the Value of coins inserted

lcd.setCursor(0, 1);
lcd.print("Credit: ");
lcd.setCursor(0, 2);
lcd.print(coinsValue, 0);
lcd.print(".00");
}
buttonPress = digitalRead(button);
if (buttonPress == 1) {

delay(100);

buttonPress = digitalRead(button);

if (buttonPress == 0) {

Serial.println("Generating Code");
coinsValue = 0;
lcd.clear();


randomSeed(analogRead(0));


//lcd.clear();
//if(Serial.available())
//{
//numBytes = Serial.parseInt();
//for(i = 0; i<numBytes; i++)
//{
// function that generates a new password
//if (generatePass == 1)
//{
for (int i = 0; i < PASSLENGTH; i++)


// show password on the display
//lcd.setCursor(0, 1);
//lcd.print(pass);



randString = randString + letters[random(0, 62)];
delay(500);
Serial.println(randString);

// show password on the display
lcd.setCursor(0, 0);
lcd.print(randString);

// erase password from memory
//memset(pass, '\0', PASSLENGTH);

randString = "";
// = 0;


}
}

}




arduino SD card read/write sunod
 
Last edited:
need to modify so that you can read/write on the sd card para kng mag crash un system meron k back up record.

again ngayon palang ako gagawa ng piso wifi , eto lng nasearch ko n mga kailangan para makabuo





Code
The code below is configured for use with an Ethernet shield, which has an onboard SD slot. In the setup(), we call SD.begin(), naming pin 4 as the CS pin. This pin varies depending on the make of shield or board you are using.

In setup(), create a new file with SD.open() named "test.txt". FILE_WRITE enables read and write access to the file, starting at the end. If a file "test.txt" was already on the card, that file would be opened.

Name the instance of the opened file "myFile".

Once opened, use myFile.println() to write a string to the card, followed by a carriage return. Once the content is written, close the file.

Again, open the file with SD.open(). Once opened, ask the Arduino to read the contents of the file with SD.read() and send them over the serial port. After all the contents of the file are read, close the file with SD.close().

/*
SD card read/write

This example shows how to read and write data to and from an SD card file
The circuit:
SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

created Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe

This example code is in the public domain.

*/

#include <SPI.h>
#include <SD.h>

File myFile;

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}


Serial.print("Initializing SD card...");

if (!SD.begin(4)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");

// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);

// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}

// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");

// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}

void loop() {
// nothing happens after setup
}
 
pa bookmark nito mayrun ako alam sa mikrotik medyo hirap lang kumausap from arduino to mk using telnet.
 
up.



Mga sir/s

anong best specs/latest specs ngaun ng piso wifi,
ano ang dpat iconsidered kapag bibili ng vendo,
meron ba mabibili sa raon na gawa na,

salamat:clap::clap::clap::clap::clap:
 
/*

this is not a finished code, pagtulungan natin mabuo,
ive taken parts of code from other sources and put this together
di ko pa mahuli kng pano mg send command to add/delete user sa mk


it gets the ip address of the router, then logs in to the mikrotik router

*/

#include <SPI.h>
#include <Ethernet.h>
#include <TelnetClient.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display


EthernetClient client;
telnetClient tc(client);



// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield

byte mac[] = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};


void setup() {
// You can use Ethernet.init(pin) to configure the CS pin
//Ethernet.init(10); // Most Arduino shields
//Ethernet.init(5); // MKR ETH shield
//Ethernet.init(0); // Teensy 2.0
//Ethernet.init(20); // Teensy++ 2.0
//Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
//Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet

lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();

// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// start the Ethernet connection:
Serial.println("Communicating");
lcd.setCursor(0,0);
lcd.print("Communicating");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
lcd.setCursor(0,0);
lcd.print("Failed to configure Ethernet");
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
lcd.setCursor(0,0);
lcd.print("Ethernet shield was not found.");
} else if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
lcd.setCursor(0,0);
lcd.print("Ethernet cable is not connected.");
}
// no point in carrying on, so do nothing forevermore:
while (true) {
delay(1);
}
}
// print your local IP address:
//Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
lcd.setCursor(0,0);
lcd.print(Ethernet.localIP());
Serial.println(Ethernet.subnetMask());
lcd.setCursor(0,1);
lcd.print(Ethernet.subnetMask());
//Serial.println(Ethernet.gatewayIP());
Serial.println(Ethernet.dnsServerIP());
lcd.setCursor(0,2);
lcd.print(Ethernet.dnsServerIP());

Ethernet.begin (mac, Ethernet.localIP());

//how long the command sent may be long
const uint8_t MAX_OUT_BUFFER_LENGTH = 150;

IPAddress mikrotikRouterIp (Ethernet.dnsServerIP());


//want to use dhcp?
//if (!Ethernet.begin (clientMAC)){
//Serial.println("\r\nDHCP error");
//while(1);
//}


//WICH CHARACTER SHOULD BE INTERPRETED AS "PROMPT"?
tc.setPromptChar('>');

//this is to trigger manually the login
//since it could be a problem to attach the serial monitor while negotiating with the server (it cause the board reset)
//remove it or replace it with a delay/wait of a digital input in case you're not using the serial monitors
//char key = 0;
//Serial.println("\r\npress Enter to begin:");
//do{
// key = Serial.read();
//}while(key<=0);

delay(5000);


//PUT HERE YOUR USERNAME/PASSWORD
if(tc.login(mikrotikRouterIp, "admin", "")){ //tc.login(mikrotikRouterIp, "admin", "", 1234) if you want to specify a port different than 23
tc.sendCommand("ip");
tc.sendCommand("address");
tc.sendCommand("print");

}
else{
Serial.println("login failed");
}
tc.disconnect();




}

void loop() {
switch (Ethernet.maintain()) {
case 1:
//renewed fail
Serial.println("Error: renewed fail");
break;

case 2:
//renewed success
Serial.println("Renewed success");
//print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
break;

case 3:
//rebind fail
Serial.println("Error: rebind fail");
break;

case 4:
//rebind success
Serial.println("Rebind success");
//print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
break;

default:
//nothing happened
break;
}

}

sir Code on Demand po ba to or yung manual/sd card type?
 
sana may master na gagawa ng vid gamit tong tut na to. hehe
 
/*

this is not a finished code, pagtulungan natin mabuo,
ive taken parts of code from other sources and put this together
di ko pa mahuli kng pano mg send command to add/delete user sa mk


it gets the ip address of the router, then logs in to the mikrotik router

*/

#include <SPI.h>
#include <Ethernet.h>
#include <TelnetClient.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display


EthernetClient client;
telnetClient tc(client);



// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield

byte mac[] = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};


void setup() {
// You can use Ethernet.init(pin) to configure the CS pin
//Ethernet.init(10); // Most Arduino shields
//Ethernet.init(5); // MKR ETH shield
//Ethernet.init(0); // Teensy 2.0
//Ethernet.init(20); // Teensy++ 2.0
//Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
//Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet

lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();

// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// start the Ethernet connection:
Serial.println("Communicating");
lcd.setCursor(0,0);
lcd.print("Communicating");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
lcd.setCursor(0,0);
lcd.print("Failed to configure Ethernet");
if (Ethernet.hardwareStatus() == EthernetNoHardware) {
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
lcd.setCursor(0,0);
lcd.print("Ethernet shield was not found.");
} else if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Ethernet cable is not connected.");
lcd.setCursor(0,0);
lcd.print("Ethernet cable is not connected.");
}
// no point in carrying on, so do nothing forevermore:
while (true) {
delay(1);
}
}
// print your local IP address:
//Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
lcd.setCursor(0,0);
lcd.print(Ethernet.localIP());
Serial.println(Ethernet.subnetMask());
lcd.setCursor(0,1);
lcd.print(Ethernet.subnetMask());
//Serial.println(Ethernet.gatewayIP());
Serial.println(Ethernet.dnsServerIP());
lcd.setCursor(0,2);
lcd.print(Ethernet.dnsServerIP());

Ethernet.begin (mac, Ethernet.localIP());

//how long the command sent may be long
const uint8_t MAX_OUT_BUFFER_LENGTH = 150;

IPAddress mikrotikRouterIp (Ethernet.dnsServerIP());


//want to use dhcp?
//if (!Ethernet.begin (clientMAC)){
//Serial.println("\r\nDHCP error");
//while(1);
//}


//WICH CHARACTER SHOULD BE INTERPRETED AS "PROMPT"?
tc.setPromptChar('>');

//this is to trigger manually the login
//since it could be a problem to attach the serial monitor while negotiating with the server (it cause the board reset)
//remove it or replace it with a delay/wait of a digital input in case you're not using the serial monitors
//char key = 0;
//Serial.println("\r\npress Enter to begin:");
//do{
// key = Serial.read();
//}while(key<=0);

delay(5000);


//PUT HERE YOUR USERNAME/PASSWORD
if(tc.login(mikrotikRouterIp, "admin", "")){ //tc.login(mikrotikRouterIp, "admin", "", 1234) if you want to specify a port different than 23
tc.sendCommand("ip");
tc.sendCommand("address");
tc.sendCommand("print");

}
else{
Serial.println("login failed");
}
tc.disconnect();




}

void loop() {
switch (Ethernet.maintain()) {
case 1:
//renewed fail
Serial.println("Error: renewed fail");
break;

case 2:
//renewed success
Serial.println("Renewed success");
//print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
break;

case 3:
//rebind fail
Serial.println("Error: rebind fail");
break;

case 4:
//rebind success
Serial.println("Rebind success");
//print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
break;

default:
//nothing happened
break;
}

}

boss san makukuha yung <TelnetClient.h> library?
 
sir good day po tanong lng po po pag nag OUT of service ung nakalagay sa LCD ng Vendo machine arduino Mega po ang board at pati po pala pano mag lagay ng mga new code para maka open sila ng net. salamt po sitt
 
Back
Top Bottom