Community discussions

 
SurferTim
Forum Guru
Forum Guru
Topic Author
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

RB433UAH and Arduino Uno/Mega and Ethernet shield

Sun Nov 27, 2011 5:39 pm

Has anybody besides me figured out what a great team these are? Connect it to one of the usb ports on the RB433UAH, and suddenly you have a bunch of control.

You can login to the usb (serial) port on the Arduino from the router. I have a "console" program that works good with this router. I can read digital and analog pins, control digital and PWM output.

The Arduino can login to the router through the usb port. (requires a jumper cut on the Arduino). Haven't finished this yet, just the login.

54 digital i/o pins, of which 14 are 8-bit PWM outputs.
16 10-bit analog inputs
4 port UART, SPI, I2C, etc...

The ethernet shield has both server and client (http and smtp) capability. Connect it to ether2 and away you go.
add: I forgot to mention the microSD "hard drive" on the ethernet shield. Mine is 2GB.
All powered by the RB433UAH usb port.

This is fun! :D

Is anyone interested in a wiki on this?

Edit: These Arduino boards are not for the beginner. If you are not at least familiar with C, this is not for you.
 
jandafields
Forum Guru
Forum Guru
Posts: 1514
Joined: Mon Sep 19, 2005 6:12 pm

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Sun Nov 27, 2011 11:05 pm

Has anybody besides me figured out what a great team these are? Connect it to one of the usb ports on the RB433UAH, and suddenly you have a bunch of control.

You can login to the usb (serial) port on the Arduino from the router. I have a "console" program that works good with this router. I can read digital and analog pins, control digital and PWM output.

The Arduino can login to the router through the usb port. (requires a jumper cut on the Arduino). Haven't finished this yet, just the login.

54 digital i/o pins, of which 14 are 8-bit PWM outputs.
16 10-bit analog inputs
4 port UART, SPI, I2C, etc...

The ethernet shield has both server and client (http and smtp) capability. Connect it to ether2 and away you go.
add: I forgot to mention the microSD "hard drive" on the ethernet shield. Mine is 2GB.
All powered by the RB433UAH usb port.

This is fun! :D

Is anyone interested in a wiki on this?

Edit: These Arduino boards are not for the beginner. If you are not at least familiar with C, this is not for you.
I can see this being useful for literally unlimited number of applications! Thank you for letting me know about the usb compatibility, that is great!!!
 
Zapnologica
Long time Member
Long time Member
Posts: 594
Joined: Fri Sep 25, 2009 8:15 pm
Location: South frica

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Sat Jun 08, 2013 5:03 pm

Could you please provide me with some more info on this.

I have been wanting to do this for ever..

How do i communicate with the ardruino through the usb on the mikrotik.

I also would like to try and share the arduinos serial port via the network. This will allow me to connect to my ardruino via a wifi network...

I know i can share the normal serial port with the following command:
/port remote-access add port=serial0 protocol=rfc2217 tcp-port=10000
i just need to know how to mount the usb serial port to a port number as above its "serial0". How can I make the usb serial for example serial1 and then i can share serial1 via the network and access it from my pc.
 
SurferTim
Forum Guru
Forum Guru
Topic Author
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Sun Jun 09, 2013 1:15 pm

I connect to the usb port using a special-login user with ssh.
/user
add name=arduino password=arduino group=full

/special-login
add user=arduino port=usb1
Then ssh into the router. At the "Login:" prompt, enter user and password arduino, and you login to the usb port of the Arduino as if you were using the serial monitor. Connecting resets the Arduino unless you have cut the "reset-en" trace on the Arduino.

Or you can access the usb port direct.
/port remote-access
add port=usb1 tcp-port=8088
If you connect to the router using the ip and port 8088, you connect to the Arduino. Connecting resets the Arduino unless you have cut the "reset-en" trace on the Arduino.

I have an ethernet shield connected to one of the ethernet ports also.

edit: If you have remote sites that need a bit of security, this is the ticket. Monitors door/window/gate switches, controls cameras and lights,etc...then can send an email/sms to your cell phone if there is a problem.
 
Zapnologica
Long time Member
Long time Member
Posts: 594
Joined: Fri Sep 25, 2009 8:15 pm
Location: South frica

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Tue Jun 18, 2013 8:59 pm

I figured out that I just have to put in usb1 instead of serial0 and it works great.

This is the best thing ever. I just cannot wait to play. What a great combo i'm so glad that Mikrotik works with Ardruino.
 
SurferTim
Forum Guru
Forum Guru
Topic Author
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Wed Jun 19, 2013 12:58 pm

It opened a whole new world for me. :D

I'm on the arduino forum as SurferTim. Stop by if you need help.
http://forum.arduino.cc
My specialties are the ethernet shield and the SPI bus. I hang out in the Networking section.

edit: I wrote these two sketches specifically for use on the RB433UAH.
http://playground.arduino.cc/Code/WebClient
http://playground.arduino.cc/Code/Email

@Zapnologica: I guess I don't need to tell you that. I see your username there already.
 
dominuspolux
just joined
Posts: 2
Joined: Tue Aug 20, 2013 4:30 pm

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Sun Aug 25, 2013 10:54 pm

Hi. It is posible to read the RSSI signal strength of the router via arduino and show it in an LCD conected to arduino in real time?. It could be usefull to align antenna, even more the arduino could control some servos to do that.
 
dmcosta
just joined
Posts: 8
Joined: Wed Oct 30, 2013 3:47 pm

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Fri Jan 17, 2014 7:11 pm

Hi. It is posible to read the RSSI signal strength of the router via arduino and show it in an LCD conected to arduino in real time?. It could be usefull to align antenna, even more the arduino could control some servos to do that.
I had the same idea, but I need to read the signal strenght on a LTE interface. Such as lte1.
If arduino can read it, I can control a motorized antenna and do a sweep to find the best orientation.

Can any one shed some light on this?

Thank you.
 
SurferTim
Forum Guru
Forum Guru
Topic Author
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Fri Feb 07, 2014 4:57 pm

Hi. It is posible to read the RSSI signal strength of the router via arduino and show it in an LCD conected to arduino in real time?. It could be usefull to align antenna, even more the arduino could control some servos to do that.
I had the same idea, but I need to read the signal strenght on a LTE interface. Such as lte1.
If arduino can read it, I can control a motorized antenna and do a sweep to find the best orientation.

Can any one shed some light on this?

Thank you.
I have not found a way yet to go the other way. I can connect to the Arduino through the Mikrotik router, but not connect to the router from the Arduino. Maybe telnet from the ethernet shield to the Mikrotik router would work.

If I get a chance, I'll try it.
 
remedix
just joined
Posts: 9
Joined: Fri Jan 17, 2014 5:38 pm

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Fri Jun 06, 2014 10:35 am

Hey all, I know this is an old post but I think you guys can help me out.

I would like to read the serial output of an arduino connected using USB.

Every 1 minute the arduino is sending/writing to the serial the following:
"humidity:33.00,temperature:26.51,pressure:980.08"

I used everything you guys mentioned to enable the port but I keep getting errors in my logs saying:
"login failure for user humidity:33.00,temperature:26.51,pressure:980.08 via local"

I figure out that the RB expects login credentials first. How would I do that ?

Eventually I would like to save to the log file these data.

Any ideas ? Thanks
 
Zapnologica
Long time Member
Long time Member
Posts: 594
Joined: Fri Sep 25, 2009 8:15 pm
Location: South frica

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Fri Jun 06, 2014 11:27 am

Are you wanting to store these values on the actual RB, or on a pc some where.

Cause you have two options.

1: use the mikrotik to make a Virtual comport, Which you then run a client software on your pc, wich then allows you to get access to the ardruino.
It basically makes a pipe, from the pc to the ardruino. This can be over the internet or LAN / wireless what eva.

This would be the easiest, as you can use c# or any other pc language to deal with the serial messages.


2: Connect to the ardruino from the mikrotik, and log it locally. I haven't tried this my self, but I think the easiest way would be to write a script that asks the ardruino for its message and it then response with the message, and you save it in a file. Rather than listening the entire time.
 
remedix
just joined
Posts: 9
Joined: Fri Jan 17, 2014 5:38 pm

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Fri Jun 06, 2014 11:36 am

Hey thanks for the reply.

No I don't want to use a computer to read any values. I think option 2 is more close to what I'm trying to do.

Basically the idea is for the arduino to dump serial data to the mikrotik and store them on the mikrotik's logs (memory not disk)

Then a mikrotik script will read the logs, find the 'arduino' logs and pushed the results to a webservice. I've written the mikrotik script and the webservice. So I'm missing the part where mikrotik logs the dumped serial data.
 
SurferTim
Forum Guru
Forum Guru
Topic Author
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Fri Jun 06, 2014 4:50 pm

My apology for not experimenting with this in a while. I've been busy with another project. I am now at a point where this function would be useful.

I will try to make time soon to see if I can login to the Mikrotik router through the USB port. That would probably be the simplest solution involving the least amount of hardware (no ethernet shield).

Maybe I can get some assistance from MikroTik support, it would help. Any ideas?
 
RogerWilco
Member
Member
Posts: 326
Joined: Wed Feb 16, 2011 6:02 am
Location: Australia

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Sun Jun 08, 2014 3:39 am

My apology for not experimenting with this in a while. I've been busy with another project. I am now at a point where this function would be useful.

I will try to make time soon to see if I can login to the Mikrotik router through the USB port. That would probably be the simplest solution involving the least amount of hardware (no ethernet shield).

Maybe I can get some assistance from MikroTik support, it would help. Any ideas?
I'd be interested in this. My post from the other day is about the same sort thing (logging into the serial device, not the other way around though): http://forum.mikrotik.com/viewtopic.php?f=2&t=85781
I'm not connecting to an Arduino but the same sort of thing. I do plan though to use a Netduino in the future.

@remedix:
You mean something like:
- MK router connection to the Arduino or your serial device via TTL/USB
- MK connecting to the Arduino or your serial device through the terminal
- MK asking for data or the device automatically sending data upon connecting
- MK logging the data it receives to the log
 
remedix
just joined
Posts: 9
Joined: Fri Jan 17, 2014 5:38 pm

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Sun Jun 08, 2014 10:28 am

Hey guys I managed to solve my problem.

Here's my findings:

My arduino spits data every 30 seconds to the usb port

I used /port to bind logging from usb to a file using:
/port set 0 data-bits=7 name=usb1
/port remote-access add log-file=arduino.dat port=usb1 protocol=raw tcp-port=65535
I then wrote a script to read the 'arduino.dat' every 5 minutes, get the last line and then log the line the console and also push it to a webservice.

Notes:
The tricky part was that you can only read from a file that's less than 4096 so I had to delete the file once I read it and then recreate it.
Also all lines read from the 'arduino.dat' contain the \r at the end to indicate a new line (carriage return). I had to clean that special character counting the length of the line and then deleting the last character.

You can find the final working code here if anyone is interested:
if ( [/file get [/file find name=arduino.dat] size] > 0 ) do={ 
   :global content [/file get [/file find name="arduino.dat"] contents] ;
   :global contentLen [:len $content ];  
   :global lineEnd 0;
   :global line "";
   :global lastEnd 0;
   :global lastLine "";
   :global sizeOfLine "";
   :do {
        :set lineEnd [:find $content "\n" $lastEnd ] ;
        :set line [:pick $content $lastEnd $lineEnd] ;
        :set lastEnd ( $lineEnd + 1 ) ;   
        :if ( [:pick $line 0 1] != "#" ) do={   
           :local entry [:pick $line 0 $lineEnd ]
           :if ( [:len $entry ] > 0 ) do={
               :global lineSize [:len $entry];
               :set lastLine $entry       
           }
        }
   } while ($lineEnd < $contentLen)

# push data to webservice
:set sizeOfLine [:len $lastLine];
:local thisLineSize ($sizeOfLine - 1);
:set lastLine [:pick $lastLine 0 $thisLineSize];
:tool fetch url="http://URL/post.php\3Freadings=$lastLine" mode=http dst-path=arduino.reading
:log info $lastLine;
}

# housekeeping. delete file and recreate to be able to read it next time before it reaches 4096 bytes
/file remove arduino.dat
/port remote-access disable [find where port=usb1 ]
/port remote-access enable [find where port=usb1 ]
 
chambri
just joined
Posts: 2
Joined: Sun Jun 19, 2011 1:25 pm

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Wed Dec 31, 2014 11:32 am

Some time ago I was trying to connect arduino with mikrotik, but not enough help obtube. the aim is that by network, arduino send telnet commands to modify the behavior of mikrotik several buttons.
Here I leave a link to what I got. if anyone can help me.

http://forum.arduino.cc/index.php?topic=77187.0
 
icezinho
just joined
Posts: 2
Joined: Wed Jan 10, 2018 1:47 pm

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Wed Jan 10, 2018 1:48 pm

Hi, how do ur arduino send data to MK? can u print a exemple plz? i try to use the code but dont work well, i think the arduino data is the problem!!

Hey guys I managed to solve my problem.

Here's my findings:

My arduino spits data every 30 seconds to the usb port

I used /port to bind logging from usb to a file using:
/port set 0 data-bits=7 name=usb1
/port remote-access add log-file=arduino.dat port=usb1 protocol=raw tcp-port=65535
I then wrote a script to read the 'arduino.dat' every 5 minutes, get the last line and then log the line the console and also push it to a webservice.

Notes:
The tricky part was that you can only read from a file that's less than 4096 so I had to delete the file once I read it and then recreate it.
Also all lines read from the 'arduino.dat' contain the \r at the end to indicate a new line (carriage return). I had to clean that special character counting the length of the line and then deleting the last character.

You can find the final working code here if anyone is interested:
if ( [/file get [/file find name=arduino.dat] size] > 0 ) do={ 
   :global content [/file get [/file find name="arduino.dat"] contents] ;
   :global contentLen [:len $content ];  
   :global lineEnd 0;
   :global line "";
   :global lastEnd 0;
   :global lastLine "";
   :global sizeOfLine "";
   :do {
        :set lineEnd [:find $content "\n" $lastEnd ] ;
        :set line [:pick $content $lastEnd $lineEnd] ;
        :set lastEnd ( $lineEnd + 1 ) ;   
        :if ( [:pick $line 0 1] != "#" ) do={   
           :local entry [:pick $line 0 $lineEnd ]
           :if ( [:len $entry ] > 0 ) do={
               :global lineSize [:len $entry];
               :set lastLine $entry       
           }
        }
   } while ($lineEnd < $contentLen)

# push data to webservice
:set sizeOfLine [:len $lastLine];
:local thisLineSize ($sizeOfLine - 1);
:set lastLine [:pick $lastLine 0 $thisLineSize];
:tool fetch url="http://URL/post.php\3Freadings=$lastLine" mode=http dst-path=arduino.reading
:log info $lastLine;
}

# housekeeping. delete file and recreate to be able to read it next time before it reaches 4096 bytes
/file remove arduino.dat
/port remote-access disable [find where port=usb1 ]
/port remote-access enable [find where port=usb1 ]
 
icezinho
just joined
Posts: 2
Joined: Wed Jan 10, 2018 1:47 pm

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Wed Jan 10, 2018 1:51 pm

@remedix, hi u can help me with ur code plz?
 
guestph
just joined
Posts: 4
Joined: Sat May 04, 2019 7:26 am

Re: RB433UAH and Arduino Uno/Mega and Ethernet shield

Sat May 04, 2019 7:58 am

Is this also possible for the mikrotik hAP lite TC (RB941-2nD-TC)?
I want my Arduino+Ethernet shield to communicate with the hAP lite using its LAN Ports but apparently there's something wrong with the ethernet shield. My shield can't link with the hAP lite but when i tried to connect my Arduino+Ethernet to my PC using RJ45 Cable, there's no problem. My guess is that i will use modem and connect my hAP Lite to the modems LAN Port (Lets say LAN1) and my Arduino+Ethernet shield to (LAN2) then let them communicate using TelnetClient. The thing is that i can't Telnet to my hAP Lite from Arduino+Shield using the provided IP Address in my modem. Am i missing something?

I used the TelnetClient library of Alejho from Github (https://github.com/alejho/Arduino-Telnet-Client)

Who is online

Users browsing this forum: No registered users and 12 guests