Loading...
Pages: [1]   Go Down
Author Topic: Write ip to arduino from web site (PHP).  (Read 560 times)
0 Members and 1 Guest are viewing this topic.
MG BRASIL
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hello to all forum participants. I am developing an automation project resindencial.
The project consists of 6 relay, 4 trigger 110v outlets, 2 trigger the gates, one gate pulse, and another gate drives, stops, reverses the motor. all this inside my web page. (for now on a wamp server).
The hardware consists of:
1 arduino uno
1 W5100 ether shield with SD.
and a PCB with 6 relays.
pretty much the mechanics.
Drive the page is already running. see the attachment.
however necessary that the ip is changed according to the local network.
researched enough here in the forum and did not see anything like what I do.
I saw a topic that the person used a code that would run from within the arduino. that is not what I want. I want the page to stay on my server and execute requests for the arduino. ex.

  ipxxx.xxx.xxx.xxx.
  maskxxx.xxx.xxx.xxx.
gatewayxxx.xxx.xxx.xxx. write the arduino through the page.

follows the attachments and the code I'm using.

« Last Edit: September 20, 2012, 07:04:55 am by mateusassuncao » Logged

Seis fases de um projeto:

- Entusiasmo;
- Desilusão;
- Pânico;
- Busca dos culpados;
- Punição dos inocentes;
- Glória aos não participantes.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 313
Posts: 35507
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
    msg[1]=msg[2]; msg[2]=msg[3]; msg[3]=msg[4]; msg[4]=msg[5]; msg[5]=msg[6];
Suppose you need to change the message size. Are you going to tack on a bunch more assignments? Or, are you going to learn how to use a for loop?

Quote
what I really want is to make another page to change the ip
OK.

Quote
and write the arduino
You seem to know how to do that. Although msg will need to get much bigger.

Quote
and then I send a pulse pro reset pin (using a resistor and capacitor course) at the end of the loop.
Why? All you need to do is call Ethernet.begin() again with the new value. You'll probably want to save the value in EEPROM so the Arduino can use the same value again after a reset.
Logged

MG BRASIL
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

actually do not know how to code for the arduino receive the new ip, mask, and gateway,
I got this code on the internet and made ​​some adjustments.
I need to do is a code similar to the one that will attach, but the page will not stay in arduino but the server www.

by I realized when I open the page with this code 10.20.30.50 Direct
and then type the new command ip and write, it copies in a specific area in EEPROM.
Quote
}
              for (int i = 0 ; i < 6; i++){
              EEPROM.write(i + 1,mac);
            }
            for (int i = 0 ; i < 4; i++){
              EEPROM.write(i + 7, ip);
            }
            for (int i = 0 ; i < 4; i++){
              EEPROM.write(i + 11, subnet);
            }
            for (int i = 0 ; i < 4; i++){
              EEPROM.write(i + 15, gateway);
            }
              EEPROM.write(0, 0x92);
            }

would somehow merge these two codes to work at the same time, or adapt this code exchange ip in php?
any help is welcome.

I do not know where to start to make that second page along with the first, all attempts I made, two codes stop working.
Logged

Seis fases de um projeto:

- Entusiasmo;
- Desilusão;
- Pânico;
- Busca dos culpados;
- Punição dos inocentes;
- Glória aos não participantes.

MG BRASIL
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

please someone with knowledge in php for arduino that can help me do the second page to change the ip of the arduino, please help me. I stopped in time ....
I have a code that changes the ip put it runs from within the arduino. but it is not what I need.

what I'm wanting to do is the following:
my client enters my site.
its authentication will be a ddns previously registered.
and the password is personal.
Once authenticated, the valid ip (fixed) directs the modem to the local ip and port arduino.
then open the page of your home where it will control gates and symptoms (or any device 110v).

why the page setup?
because the arduino go with ip 192.168.1.25 mask 255.255.255.0 manufactures and gateway 192.168.1.254.
the customer will enter the setup of the modem
ex. 192.168.254.254
Your local band would soon 192.168.254.0/24
then he will choose a local ip that is not being used and direct a valid ip port for this ip:
eg 189.69.69.69 dst-nat tcp, udp port 8000 ip 192.168.254.25 to local port 80
made the setting on the client vai cadastar ddns for access (which will be on site)
ex
exautomation.ddns.com.br = 189.69.69.69:8000 192.168.254.25:80 = ready is already on the internet.
the customer will change your ip in 192.168.1.2 mask 255.255.255.0 to computardor
open the browser enter the ip 192.168.1.25 arduino enter the ip setup tab and put the ip and port mascara gatwey he configured the modem for internet.

Ready your home is already online.

the page with the relay is already in place and configured in arduino.
the ddns is already running,
now lack a solution for my client write ip arduino according to your local network. but everything has to be via browser.

enables someone to help me?

Thank you.
« Last Edit: September 12, 2012, 09:17:19 am by mateusassuncao » Logged

Seis fases de um projeto:

- Entusiasmo;
- Desilusão;
- Pânico;
- Busca dos culpados;
- Punição dos inocentes;
- Glória aos não participantes.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 313
Posts: 35507
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
please someone with knowledge in php for arduino that can help me do the second page to change the ip of the arduino, please help me.
There are no experts on php for Arduino, because php doesn't run on the Arduino.

Quote
my client enters my site.
Which the Arduino is serving, or not? If the Arduino serves the page, it doesn't contain php code, does it? If the Arduino is not the server, then, I don't see any easy way of changing it's IP address using browser code. The Arduino would have to issue a GET request to get the data, and it would have no way of knowing that there was a need to do so.
Logged

MG BRASIL
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yes i did not install the arduino code in php.
but it receives commands via socket_write the page in php right?
"<? Php
$ sock = socket_create (AF_INET, SOCK_STREAM, SOL_TCP);
/ / Connects to IP and Port:
socket_connect ($ sock, "10.20.30.50", 80); "
I want to know is if he gets 0 and 1 for on and off the relay.
would have some code that would change the ip alert by socket_write the area responsible for the ip type in arduino

'}
               for (int i = 0; i <6; i + +) {
               EEPROM.write (i + 1, mac );
             }
             for (int i = 0, i <4; i + +) {
               EEPROM.write (i + 7, ip );
             }
             for (int i = 0, i <4; i + +) {
               EEPROM.write (i + 11, subnet );
             }
             for (int i = 0, i <4; i + +) {
               EEPROM.write (i + 15, gateway );
             }
               EEPROM.write (0, 0x92); "
understood now.?
would also want to know how the php code to be run action?

possibility exists?
Logged

Seis fases de um projeto:

- Entusiasmo;
- Desilusão;
- Pânico;
- Busca dos culpados;
- Punição dos inocentes;
- Glória aos não participantes.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 313
Posts: 35507
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You have PHP code now that sends data in a format that the Arduino understands. You need to expand on what the Arduino understands.
Code:
    if (msg[6]=='#') {
      switch(msg[5]) {
        case 'R':
          // Se receber o comando 'R#' envia de volta o status dos
          //   dispositivos. (Que é a string 'Luz')
          client.write(Luz);
        break;
You might have 4 more letters that correspond to the 4 octets of the IP address. Match the write-to-EEPROM code to the correct letter. 6 additional letters for the MAC address parts would work, too.

Of course, turning the whole protocol around so that the command comes first, followed by a variable number of values would let you use use two more commands (I and M, perhaps).
Logged

MG BRASIL
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Gotta Make sure the new code and put it here later

my problem is that when I start to move the code that is working to put the exchange ip, it stops working.
I'm lost, because not know much about programming, my area is electronic,
you have a variable name that I will use to write the ip of the arduino alert page?
ex
would only include the
# include <Ethernet.h>
# include <SPI.h>
outeria to put some more ex # include <Client.h>

and a function that would write
EEPROM.write the void loop?

anything to start researching.
so I can understand how.
Thank you.
Logged

Seis fases de um projeto:

- Entusiasmo;
- Desilusão;
- Pânico;
- Busca dos culpados;
- Punição dos inocentes;
- Glória aos não participantes.

0
Offline Offline
Tesla Member
***
Karma: 50
Posts: 6546
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
however necessary that the ip is changed according to the local network.
researched enough here in the forum and did not see anything like what I do.

Well, what you want to do is somewhat like randomly changing your telephone number and then expecting people to be able to call you.
Logged

Why I like my 2005 rio yellow Honda S2000 with the top down, and more!
GOOGLE ADVANCED FORUM SEARCH BELOW!  
Go to:  http://www.google.com/advanced_search?hl=en
put in key search words,
use site or domain:  http://arduino.cc/forum
or in a google search box put key words site:http://arduino.cc/forum

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 313
Posts: 35507
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Well, what you want to do is somewhat like randomly changing your telephone number and then expecting people to be able to call you.
I was thinking it was more like "Your phone number today is xxx.xxx.xxx.xxx; go answer the phone". But, I like your idea, too.
Logged

MG BRASIL
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I had another idea for the ip. I use dhcp and put a display, will be more functional for the end customer. the site is already in operation with 6 relays, have a lcd 20x4'll test here, I'll try to do it in print ip lcd ....
anything I post here if it works or not ...
« Last Edit: September 16, 2012, 07:23:05 pm by mateusassuncao » Logged

Seis fases de um projeto:

- Entusiasmo;
- Desilusão;
- Pânico;
- Busca dos culpados;
- Punição dos inocentes;
- Glória aos não participantes.

Pages: [1]   Go Up
Print
 
Jump to: