Topic: A few questions about connecting arduino to the internet via wifi using router (Read 4255 times)previous topic - next topic

Greetings! I am new with arduino so firstly I will explain what am I trying to achieve and then ask you some questions about it.

I want to make a simple weather "station" which prints the temperature and humidity on a web page.

I've read that this can be done with the Arduino Ethernet Shield and the Ethernet Library. Great, but I will place it outside the house so I want it to connect to my wifi network and do the exactly same thing. I've seen and read about the wifi shields but they are quite expensive. After reading for hours I found some articles that explain how cheap routers can be hacked with dd-wrt and used as clients (bridge mode) to connect to the main wifi network. There is one thing that I didn't understand - is this only to controll remotely the arduino or arduino can access internet (and ethernet library can be used) ? (link to the article)

Another method I found is this. I think that this is better than the one i explained above. It uses an ethernet shield and a cheap router which offers bridge mode. A lan cable is connected to the ethernet shield and the router and according to the article the arduino can access the internet.

So my question is - has anybody tried one of these methods and which one do you recommend me to use? Are there any other cheap methods? Do you have any suggestions about them?

As long as your wireless router support OpenWRT then you can eliminate the use of Ethernet shield and Wifi shield. Plug your Arduino to the USB port of wireless router & coding with HTLM+Javascript+Lua, or HTML+Javascript+PHP

True, you could eliminate the WiFi and Ethernet shield this way, howevr, you'd obviously loose all compatibility to the Ethernet shiled library.

Depending on yopur projects requirements you may end up having to write a lot of code that otherwise is provided in form of the Ethenet library and a host of other libraries that depend on the Ethenet library.

But, yes, connecting a cheap router that preferably runs on 5V USB power is a safe bet. I use that approah in two projects with more coming up. I use a TP-Link TL-WR703n, TP-Link TL-WR702n and the TP-Link TL-WR703n and the 3020 should also work witout problems.

There is no point to use ethernet shield library if a wireless router is being used in the project.I think using HTML & javascript is much more easy than using ethernet shield library since most of the people already learn HTML and javascript.I will post my project which only install a serial library for the FDTI USB2Serial without installing additional OpenWRT packages. The project will control & query the Arduino output.

If you are using existing libraries that rely on the Ethernet library, e.g, ArdOSC or DHCP/Bonjour you save yourself a lot of time coding things that are already coded. Good luck trying to code that functionality in HTML & javascript ;-)

I understand that the motivations of people for engaging in Arduino projects is different. Perhaps if you consider it a learnig experience and time for coding is not a problem, in that case elimiating the Ethernet card and library and associated functionality a a valid approach.

However, if one intends to get a project on their feet quickly and has a specific functionality in mind, then spending $30 on a little extra hardware is not an issue.

I agree that in certain use cases the Ethernet card is a bit superflous, but if you start that argument you may as well replace the whole Arduino, again depending on what you do and what your embedded coding skills are.

The TL WR703n hosts a 300Mhz Atheros processor (Arduino 16Mhz) with 32MB dram (Arduino MEGA 128kb). It has some GPIO and OpenWRT is an embedded Linux box.

I personally think that using an ethernet shield is better because i can use the ethernet library which is very nice and easy to understand.I don't like connecting arduino to the serial port of a router because basically it doesn't have a "direct connection" to the internet. (correct me if I am wrong) This means that there must be sth that constantly controlls the data from the router to the arduino and from the arduino to the router. (much complicated) Although it is the cheapest method I don't really like to try it because I am a beginner with arduino .

I am planning to collect the data from the arduino web server page with a VPS with a php cron job and store it in a MySQL database, so that I can play with it in web or software apps.

Final question: Will my arduino have internet access if I put TP-Link TL-WR702N in bridge mode with my home wi-fi network, and simply connect it with the ethernet shield with a lan cable?

I have some other questions but they are not related to networking so I'll open another thread.

Yes, you will have an Internet connection, but then it depends what you want to send or receive through the connection and if the connection will be initiated from the Arduino to the out to the internet, for example to post the data to a web site ( relatively easy) or if you want a web site to initiate a connection from the outside to your router (somewhat less easy).

It is not important to "Direct connection" as long as your project is running without problem.

If you had this sketch upload to your Arduino http://www.oceancontrols.com.au/KTA-223.html and you had the following file put in the /www/cgi-bin folder of router . Then you can control the Arduino with one line URL without knowing how it work.

Save the following file as luaSerial and save it to /www/cgi-bin directory of router & set its permission to 0755

-- LuaSerial interface-- for Wireless Router Home Automation-- by SM.Ching http://ediy.com.my---- Put this file to /www/cgi-bin directory of router-- use code below to allow 0755 permission for luaSerial file-- chmod 0755 /www/cgi-bin/luaSerial---- protocol (Receiving from serial port):-- @aaccpp -- where aa is the Arduino address ranged from 0 to 255 (0 means all Arduino)-- where cc in the command (TG, ON, OF, RS)-- where pp is the parameters or channel ranged from 0 to 8 (0 means all channes)-- to toggle output for channel 1: @00TG1-- to get status from all output: @00RS0---- protocal (Sending to serial port):-- #aapp-- where aa is the Arduino address ranged from 0 to 255 (0 means all Arduino)-- where pp is either 1 or 0 (ON or OFF for a channel), or ranged from 0(00000000) to 255(11111111) for all channels