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.
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?
what I really want is to make another page to change the ip
OK.
and write the arduino
You seem to know how to do that. Although msg will need to get much bigger.
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.
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.
}
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); } [/quote]* 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._
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.
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.
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.
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?_
You have PHP code now that sends data in a format that the Arduino understands. You need to expand on what the Arduino understands.
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).
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.
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 ...