enc28J60 and Arduino (11)

by luca
77 comments

Today’s tutorial is a bit different: I’m going to show you how to make your ethernet shield wireless!

You can find many Wi-fi shields for Arduino: starting from the official one,  up to shields based on Microchip’s ICs.

Sometimes however it could be easier (and maybe cheaper!) to connect an Arduino to the Wi-fi network using your ethernet shield in conjunction with a wireless router.

I found the TL-WR702N nano router by TP-LINK that, with a cost of about 20€ on eBay, can work also as a wireless client: in this mode the router acts like a “bridge” between the device connected to its ethernet port and a Wi-fi network.

The TL-WR702N router is also very small and you can power it through a micro USB connector:

 

Here’s how to configure it in client mode:

First, give to your PC a fixed IP address, 192.168.0.10, and connect it to the router using an ethernet cable:

Open your browser and type http://192.168.0.254; login with admin as username and password.

Choose Client mode:

Click Survey to find your Wi-fi network, then type your security settings (password…):

Wait till router restarts:

Now connect your Arduino+ethernet shield to the router; wait a couple of seconds and it will be available through your wireless network!

Related Posts

77 comments

Amario Sunday December 9th, 2012 - 08:13 PM

Ciao Luca, io mi sono procurato questo:
Vobets VAP11G
http://www.vonets.com/products/vonets-vap11g-wifi-bridge.htm

fa da bridge, lo uso anche per collegare l’ethernet del Blueray
pagato 27 euro

Reply
lucadentella.it – enc28J60 e Arduino (11) | E4Y Electronics For You | Scoop.it Sunday December 9th, 2012 - 10:25 PM

[…] Il tutorial di oggi è un po' particolare: spiega come rendere wireless il nostro ethernet shield. Esistono diversi shield Wi-fi per Arduino: partendo da quello ufficiale, fino a shields basati su integrati Microchip, “cugini” …  […]

Reply
Squonk42 Tuesday December 11th, 2012 - 10:44 PM

Yes, and if you buy a TL-WR703N for about the same price (or its global export RoHS/CE/FCC compliant sister product, the slightly larger TL-MR3020), you get an additional USB host port where you can connect the Arduino directly without needing the Ethernet shield. For this purpose though, you have to replace the original firmware by OpenWrt, but it is pretty easy.

Actually, you can even use the free Ethernet port to get wired Ethernet access… I recorded a few videos describing the setup:

http://www.youtube.com/playlist?list=PL4f_8Do1Z2EpyXm_wdCD5YM3V0KUQj4uj&feature=view_all

Reply
luca Wednesday December 12th, 2012 - 08:52 AM

Thanks Michel!

Reply
Squonk42 Wednesday December 12th, 2012 - 10:10 AM

You are welcome!

If you have a chance to open your TL-WR702N, I would be very interested if you could take some hi-res pictures of the PCB top and bottom side.

You just have to open the top blue lid gently with a knife, there is no screw, and the PCB is just positioned within the case without screws.

You can close it back again without problem, the operation is not destructive 🙂

Reply
Reint Monday February 11th, 2013 - 04:23 PM

Hi Squonk421,

Can you tell some more about. What router i need to get, to do the same trick. because the TL-WR703N is hard to get in The Netherlands. The TL-WR702N is much easier but will it work? And the TL-MR3020 is easy to get but will it work with the thing you explain at Youtube. I have seen on the openWRT site that it isen’t supporter jet.

Reply
Amario Wednesday December 12th, 2012 - 09:59 AM

Interessante

Reply
Mauro Wednesday December 12th, 2012 - 03:51 PM

Interessantissimo tutorial, ho acquistato anche io un nano router wireless della tp-link.

Proverò il tuo tutorial per rendere wireless alcuni dei miei progetti con arduino.

Grazie
Mauro

Reply
enc28J60 e Arduino (11) | Arduino - Ethernet | Scoop.it Saturday December 15th, 2012 - 03:07 PM

[…] Il tutorial di oggi è un po' particolare: spiega come rendere wireless il nostro ethernet shield.  […]

Reply
Daj Friday December 21st, 2012 - 07:58 AM

Hello Sir Luca.nice tutorial!! Thats help me a lot!!
Sir, what is the equivalent code of CLIENT.PRINT of official arduino to the enc28j60 ethernet shield to ethercard library. ? Hoping for your valuable reply sir. 🙂

Reply
luca Friday December 21st, 2012 - 04:28 PM

Hello! It’s a bit more complex with this library… you have to “prepare” the response with Stash::prepare() and send it with ether.tcpSend().

Reply
Daj Saturday December 22nd, 2012 - 03:40 PM

Hello Sir. Thanks for the great idea. I’m planing to send this string data “Hello World”, its code in official arduino ethernet is CLIENT.PRINT(“HELLO WORLD”); . .is this right if i write the version of this code in ethercard like this:

Stash::prepare(“HELLO WORLD”);
ether.tcpSend();

Reply
luca Monday December 31st, 2012 - 12:33 PM

yes it should work…
is your client a web browser?

Reply
Daj Tuesday January 1st, 2013 - 04:01 PM

THANK YOU for your response Sir Luca. I really appreciate it.
My client is the arduino connect to visual basic using winsock. I’d found out that client.write is suitable for my application than client.print. Now, Sir Luca i would like to ask you again if what is client.write in ethercard library?. . I like your your tutorial very well. It helps beginners like us a lot. .!! 🙂 thankyou very much. Happy New Year!!

Reply
Renato Aloi Thursday January 10th, 2013 - 05:15 AM

Great tutorial Luca! Thank you very much for this article! I had it done and woks like a charm. But there is a situation I am facing here… Working as a client, the router has no access to internet. I mean, any form of external links doesn’t work. I have tried loading a external CSS file and the HTML does not load at all. The browser keeps loading the page forever and never get it done… But the same page loads ok on wired connection. Do you know somehow to solve that? Any thoughts about that? Once again, thanks for the tutorial!

Reply
luca Thursday January 10th, 2013 - 12:11 PM

Hi Renato,

if you configure the router as a “wireless client”, it acts as a PC or a smartphone connected to your network… you can forget it and consider it a “part” of your ethernet shield. How is your network configured? Have you got an ADSL router that connects you to Internet and also creates the local wireless network your TP-LINK is connected to?

Reply
bert Friday January 11th, 2013 - 09:53 AM

Hi Luca,

Thanks for your post, I tried it but for some reason I just can’t get the TP-link device to work with any of the wifi points I try and get it to connect to. It seems to connect to them but it doesn’t give my device and IP address, as DCHP is turned off I presume it acts as a bridge and should pass through any DCHP settings to the end device?

I’ve tried testing it using my laptop to see if it will give me a internet connection but for some reason it just won’t work. Any thoughts? Did you have to do any configuration on the wifi network you were connecting to? I’ve tried 3 and none of them seem to want to play ball.

Any help much appreciated, as it would be a great solution if I could get it working.

Best wishes

Bert

Reply
luca Friday January 11th, 2013 - 08:23 PM

Hi Bert!

if you configure your TP-LINK as a client, it acts like a bridge so you need a different DHCP server on your network. I can assure you that the router doesn’t block DHCP requests or response, so for example my Arduino is able to get its dynamic IP from my ADSL router.

Reply
Liber Wednesday March 6th, 2013 - 12:37 AM

Hello.
First of all, nice post!

But as bert, I must say that I’m unable to make it work in client mode; it doesn’t connect to the wireless network. Does it work in a network with WPA2 security? Or it needs to use WEP security, or nothing at all?

Thanks in advance for your reply.

Liber.

Reply
luca Wednesday March 6th, 2013 - 10:04 AM

Hi Liber,

I can confirm you that it works with WPA2 security: I’m using it with that security protocol.

Reply
Kirill Sunday January 13th, 2013 - 11:21 AM

Hi!

I am using the TL-WR702N too. And I have wrote new article with link to you about the TL-WR702N:

http://ksdu.in/o/2s

Reply
luca Sunday January 13th, 2013 - 12:46 PM

Thanks!

Reply
Kirill Sunday January 13th, 2013 - 06:59 PM

Thank you too!
Welcome to KSduino: http://ksduino.org

Reply
Mikael Nyberg Friday January 18th, 2013 - 07:54 AM

I ordered one on ebay:http://www.ebay.com/itm/150893487418?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649
Device has Chinese User Interface and there is no information of this. What shall I do?

Reply
luca Friday January 18th, 2013 - 11:18 PM

Hi Mikael,

it seems the exact model I own… I can change the interface’s language: did you try following the english manual linked in the auction?

Reply
Mikael Nyberg Saturday January 19th, 2013 - 11:37 AM

I used Google tranlation to understand what do. From chinese to swedish works very well. Thanks for information how to use an AP in client mode. Mikael

Reply
Istrice Wednesday February 13th, 2013 - 06:34 PM

Salve stavo cercando le stesse librerie per la ethercard enc28j da utilizzare però in bascom in quanto l’implementazione del codice asm con questo linguaggio comportava una maggiore facilità di scrittura e una sensibile riduzione di codice macchina da caricare sull’atmega328… qualche giorno fa girando fra i siti e i link vari avevo trovato chi si stava occupando del porting… purtroppo non ho salvato quella pagina e nemmeno il link… qualcuno ha informazioni in merito? grazie

Reply
DMV Thursday February 14th, 2013 - 03:15 AM

Hi,
This is close to what I am looking for, but was wondering if there is a way to just have the WR702N connected to the ethernet shield of the Arduino and connect to it with an iphone without the use of any other internet or computer. I am trying to make a project where the arduino can be accessed and send messages to an iphone or other device wirelessly.So the WR702N would be a stand alone AP. I cannot seem to figure this out.
Thanks,
D

Reply
luca Thursday February 14th, 2013 - 08:56 AM

Hi! I think you may connect your iPhone with the router using an “ad hoc” wireless network, i.e. a wireless network between two devices without the need of an AP.

Reply
Dauhee Saturday February 23rd, 2013 - 10:08 PM

a raspberry pi model A + dongle is cheaper than wifi router + ethernet card + arduino . . . . . also have more processing power etc.

Reply
Darius Wednesday March 6th, 2013 - 10:20 PM

Hi, I am using a similar system to this. I have an Arduino board, ethernet shield and portable router. I give my laptop a fixed IP to access the router. I was wondering if you could suggest a way to connect my laptop to the internet at the same time, so I can control the Arduino remotely over the internet. Any thoughts? Thanks.

Reply
Ben Wednesday March 27th, 2013 - 05:04 PM

Hi, One issue i have is how to power it without a device to plug the USB into? The reason i got it was to make it wireless not having to connect to a PC. Any suggestions ? Check micro USB battery pack?

Reply
luca Thursday March 28th, 2013 - 09:28 AM

Hi Ben! You can use any power supply with microusb connector (5V 1A minimum) or – for example – the Lipo Rider if you need a battery source.

Reply
André Saturday April 13th, 2013 - 10:41 PM

Dear Luca, please I bought the BL-MP01,

http://www.lefen.com/index.php/Product/views/id/300

this dosen’t works with my arduino ethernet shield,only work how a cliente in my PC is it necessary to make somechanges in the Arduino program to work with BL-MP01? In my opinion it is similar to TL-WR702N.

Ciao

André

Reply
luca Sunday April 14th, 2013 - 01:25 PM

Ciao Andrè

It should work, moving the switch in the “client” (= middle) position… no changes are required to the arduino sketch.

Reply
André Monday April 15th, 2013 - 12:24 AM

Dear Luca, so i think that i’m made some mistake, because I can’t acess my arduino shield by the IP adress that I put in my sketch, in your sketch you are using the IP 192.168.0.10 of your example above? In the router configuration are you using DHCP (Auto Config) or Static Mode (fixed IP)?
Thanks
André

Reply
luca Tuesday April 16th, 2013 - 08:26 PM

Andrè,

when you use the router in “client” mode, you don’t need to configure IP address… it acts like a “transparent” bridge between the Arduino (with the assigned IP) and your wireless network: you have only to configure the wireless parameters (SSID, encryption…) to ensure your router can connect to your wifi.

Reply
alb3 Thursday May 23rd, 2013 - 10:13 AM

ciao Luca!
che versione di arduino hai usato?
Arduino Ethernet Rev3 WITH PoE??

Posso alimentare il router tplink direttamente da arduino alimentato tramite una presa a muro?? (quindi evitando collegamenti col pc)

grazie!!!

Reply
luca Thursday May 23rd, 2013 - 11:06 AM

Ciao Albe,

attento: se usi Arduino Ethernet non puoi usare la libreria Ethercard, devi usare quella ufficiale e quindi rivedere i vari esempi.
Per quanto riguarda l’alimentazione, Arduino non è in grado di fornire sufficiente corrente per il TPLink (che comunque viene fornito con il suo alimentatore a muro, non devi per forza collegarlo al PC).

Reply
alb3 Thursday May 23rd, 2013 - 01:29 PM

grazie della risposta immediata!!!
… quindi cosa mi conviene usare? una qualsiasi e poi aggiungere un modulo ehternet esterno??

Reply
luca Thursday May 23rd, 2013 - 07:15 PM

esatto, se vuoi seguire i miei tutorial ti serve un arduino qualsiasi (consigliato l’arduino uno) e uno shield basato su chip enc28j60

Reply
Mike Saturday June 1st, 2013 - 09:20 PM

Salve a tutti vi informo che arduino é in grado di alimentare perfettamente il nano router basta solo spillare i fili di un cavo micro USB e collegarsi a Vin e Gnd di arduino ed il gioco é fatto.

Reply
Sloba Wednesday July 10th, 2013 - 02:34 AM

How could ENC28J60 and Arduino wirelessly connect to the TL-VR702N then TL-VR702N ethernet cable to the internet modem?

Reply
luca Wednesday July 10th, 2013 - 03:37 PM

Hello! The usage of TL-VR702N is different: it connects using the wire (ENC28J60 is an ethernet shield) to the shield and then it connects via wireless to a router/cable modem.

Reply
Sloba Thursday July 11th, 2013 - 03:25 PM

Yes, but when I changed enc ENC28J60 chip AN1284 wifi chip, how many is it feasible?

Reply
luca Friday July 12th, 2013 - 01:45 PM

Are you trying to use the Microchip WiFi chip? You need a totally different library for that…

Reply
Paolo Tuesday September 24th, 2013 - 11:31 AM

Ciao Luca, il tuo tutorial era proprio quello che cercavo per far funzionare la mia Ethernet Shield con una rete wireless. Ho comprato il TP-LINK WR-702N e ho seguito i tuoi passaggi. Purtroppo però mi sono accorto che dopo aver settato a Client il TP, non riesco più ad entrarci con l’indirizzo 192.168.0.254. Questo sia collegando il cavo direttamente al PC, sia passando attraverso il mio router WiFi. La necessità di ricollegarmi a TP viene dal fatto che mi sono dimenticato di impostare i parametri di sicurezza della rete. Hai qualche consiglio?
grazie

Reply
luca Tuesday September 24th, 2013 - 12:44 PM

ciao Paolo

la cosa più veloce è fare il reset del router: a router acceso premi con una graffetta per 10 secondi il pulsante RESET. Al riavvio il router tornerà alle impostazioni di fabbrica.

Reply
Hamza Saturday November 30th, 2013 - 04:45 AM

Hi Luca,
I have Arduino Mega + ethernet shield + WR-702N router. I’m able to display the values on Analog input usin Arduino and ethernet shield. I want to do the same using the WR-702N router. Please, help me in this regard.

Reply
Hamza Saturday November 30th, 2013 - 12:16 PM

How to use client mode with ethernet shield, arduino mega 2560 and wr-702n router..?
please give steps to configure

Reply
luca Monday December 2nd, 2013 - 09:41 AM

Hi Hamza,

the client mode is independent from the device you connect: use the instructions in this blog post.

Reply
Jean Monday December 2nd, 2013 - 08:52 AM

Hi, is it possible to connect my arduino + ethernet shield to mysql database?
For example: Arduino and ethernet shield connected to wireless router, and my laptop (with mysql database) is also connected to the wireless router. If it’s possible, can you give me the codes on how to do it?

Reply
luca Monday December 2nd, 2013 - 09:37 AM

Hi Jean

there are a couple of MySQL drivers for Arduino, like the following one:
http://drcharlesbell.blogspot.it/2013/04/introducing-mysql-connectorarduino_6.html

They are usually designed to work with the official ethernet shield… I found an interesting library for ENC28J60 that should be compatible with that code, give it a try.

Reply
Jean Monday December 2nd, 2013 - 01:26 PM

thanks for the quick response. i already tried this one. but it didn’t work for me.
[…]

Reply
luca Monday December 2nd, 2013 - 01:57 PM

Hi Jean

sorry but I’ve no experience with that library so I can’t help you…

Reply
Jean Monday December 2nd, 2013 - 02:23 PM

Ok Luca, thanks. i’ll try it again using the sample you gave me. thankyou

Jean Monday December 2nd, 2013 - 01:42 PM

I have another question. How about using PIC16F877A and an Ethernet shield. is that also possible?

Reply
luca Monday December 2nd, 2013 - 01:52 PM

Yes I think but you need to find/write compatible libraries…

Reply
Jean Wednesday December 4th, 2013 - 10:10 AM

Hi Luca! what about using Atmega328 and ethernet shield? do you have any schematic diagram that I can use. And the program to save the data coming form my MCU to mysql databse. Sorry for having so many questions. Thanks in advance. 🙂

Reply
luca Wednesday December 4th, 2013 - 05:52 PM

Hi Jean, the ATMega328 is the microcontroller Arduino uses so you can follow the instructions in this tutorial: http://arduino.cc/en/Tutorial/ArduinoToBreadboard

Reply
Jean Wednesday December 4th, 2013 - 10:11 AM Reply
Tim Sunday December 15th, 2013 - 04:06 PM

Ciao Luca, thanks for your great tutorial. I have realized a cabled network based on the WZ5100 breakout (Itead) with fixed IP’s sending and receiving a string over UDP. I want to transfer this to wireless with your wifi router solution. So I connected the modules with the WR702N, but somehow I didn’t manage to run this with fixed IP’s, to keep the units addressable. I even couldn’t ping them. Do you have any suggestions?

Reply
luca Monday December 16th, 2013 - 02:13 PM

Hi Tim,

if you configure the router in “client mode”, it should be “transparent” in your network… are you sure it is connected to the wifi? You should be able to find the Arduino in the list of connected devices in your router/AP.

Reply
jason Friday December 27th, 2013 - 03:18 PM

hi luca! can you write a tutorial on how to connect an arduino+ethernetnet shield using the library ethercard and an additional library for mysql connector. thanks in advance 😀

Reply
luca Tuesday January 14th, 2014 - 06:59 PM

Hi Jason

unfortunately the MySQL library requires a “W5100-compatible” library… but the only one I found doesn’t work for the lack of free RAM.

Reply
ezio labruzzo Tuesday March 11th, 2014 - 02:46 PM

Ciao Luca. Io uso una shield W5100 che collegata direttamente al router via cavo funziona come server web utilizzando lo sketch d’esempio nell’ide. Il problema compare quando lo collego al tl-wr702n. Non funziona quasi mai e se dopo diversi reset del mio arduino uno finalmente diviene raggiungibile dal browser, dopo una decina di minuti ritorna il black out. Tieni conto che il tl-wr702n lo uso regolarmente per il decoder mysky sulla stessa rete. Ho cambiato hardware ma il problema permane. Puoi autarmi?

Reply
luca Saturday March 15th, 2014 - 10:26 AM

ciao Ezio, purtroppo non ho lo shield con il W5100: posso dirti che con quello che ho io non riscontro problemi di blackout…

Reply
shorda Tuesday April 15th, 2014 - 07:00 PM

Hi, I just need to know, if i buy it , can i do this without another wifi router? Can I directly setup bridge between my notebook and arduino with TL-WR702N. Get signal from TL-WR702N by using my notebook. Thanks for answer and sorry for english!!

Reply
luca Sunday April 27th, 2014 - 12:39 PM

Hi Shorda, hope I understood what you asked: yes the WR702 may act as an access point between your laptop and arduino.

Reply
fxstrike Friday January 16th, 2015 - 09:09 AM

I use prolink WNR1004 it’s works – the backsoon examples works without modification, same procedure.

Reply
Fernando Friday February 20th, 2015 - 12:14 AM

Just wanted to thank you for your Arduino tutorials, they are awesome and helpfull 🙂 Please keep making them.

Reply
luca Tuesday February 24th, 2015 - 08:56 PM

Hi Fernando and thanks a lot for your feedback!

Reply
Sean Friday March 27th, 2015 - 07:18 AM

I managed to get OpenWrt installed on WR710N, which is similar to WR703N, but with 2 Ethernet and 1 USB. My goal is to use the USB to connect to Uno. However, I am not sure how to achieve that. can anyone help?

Reply
VINCENZO Sunday October 8th, 2017 - 06:10 PM

Ciao Luca, Sto utilizzando un TP-Link TL-WR802N configurato come client (seguendo la tua guida) ma non riesco a connettermi a internet. Mi potresti aiutare?

Reply
luca Tuesday October 10th, 2017 - 12:40 PM

Ciao Vicenzo… con così poche informazioni è difficile riuscire ad aiutarti: il TP-Link risulta connesso alla tua rete? Da Arduino non riesci a raggiungere Internet o anche altri dispositivi in rete? Se usi DHCP è stato assegnato correttamente un indirizzo IP?

Reply
VINCENZO Sunday October 15th, 2017 - 04:15 PM

Ciao Luca, di seguito i dettagli:

CONFIGURAZIONE:
1. configuro il TP-LINK come client.
2. seleziono, dalla lista che viene fuori dalla scansioine delle reti, la rete wifi di casa a cui voglio connettere il mio TP-LINK.
3. seleziono “SmartIP(DHCP)” al posto di “StaticIP”
4. procedo con il reboot del TP-LINK
A questo punto mi aspetto che il mio TP-LINK mi fornisca la connessione ad internet poichè si appoggia alla wifi di casa, se lo attacco via ethernet al PC, ciò è vero…..se attacco via ethernet il TP-Link ad Arduino, la shield non risponde al ping.

Rispondo alle tue domande:
1. Il T-LINK risulta essere connesso alla rete poichè se lo attacco al PC mi consente di navigare
2. Da Arduino, solo tramite il TP-Link, non riesco a reggiungere internet
3. Ho assegnato ad Arduino un indirizzo IP del tipo 192.168.2.2

Reply
luca Sunday October 15th, 2017 - 09:33 PM

ciao, prova a configurare arduino con IP dinamico (DHCP) perché è così che hai configurato il tp-link: in modalità client infatti lui “passa” l’IP che ottiene dal tuo router al dispositivo che hai collegato.

Reply

Leave a Reply to luca Cancel Reply

sixteen + 14 =