Hi everyone,
I have to use Arduino with an ethernet shield in different networks, I mean with different network settings.
I have to set different static IP and server IP.
For this, I connect to the device with Arduino IDE and make these changes from codes.
My question is, can I make these changes externally, without using the IDE?
It comes to mind to put an LCD shield on board and change IP settings with the buttons on the shield and write to EEPROM at startup.
Or maybe I can write settings to an sd card that I will install in an ethernet shield and the board can read it from there.
But Is there another way?
For example, is it possible to access the SD Card without removing it from the shield, so anyone with a computer can connect to the board with a USB cable change these settings without IDE.
Is there any reason why you could not just use a serial link to obtain the details if, say, on startup a given pin was shorted to ground - this could easily be done with a button, jumper or even a switch. You would need to have something linked to the serial interface that could interact, such as a PC.
playako:
Thank you for your reply. But I'm too ignorant and noob to understand your advice.
We all have to start somewhere and without asking we get nowhere.
Re-reading your first post and bearing in mind that you are new to this, the first solution you might try is relying on DHCP. Most routers support this and most larger networks rely on this as managing IP addresses manually quickly becomes a major PIA. DHCP allows an Arduino (or anything else) to obtain an IP address, subnet mask, gateway address and DNS server address automatically without you having to manually set anything. If you are just starting out this is probably the way you should go as it avoids lots of work and will allow your Arduino to work on different networks without you needing to enter the network details everytime you change network.
If you have a router at home linked to the Internet it will almost certainly have DHCP capability and unless you have turned it off will probably supply DHCP addresses to everything that is on your home network. If your PC when connected to your home network via Ethernet cable or WiFi automatically gets an IP address (probably something like 192.168.0.x) then it is most likely using DHCP.
If you do need to o things manualy post again and I will try and give you a fuller explanation of what I first suggested.
First of all, thank you very much for your interest.
I will research and apply your DHCP advice.
But there is one more problem, the device sends data to MQTT Broker, so each network has an MQTT Server with a different IP address.
Because of this, I still have to change this server IP setting manually when I change the location of the device.
Maybe I can handle this with a code (eg by redirecting the Broker's IP to a static domain name).
If you use the MQTT Brokers node name, then the DNS server assigned using DHCP should be able to resolve that to the ip address of the broker so needing no changes at your end. If the name of the broker changes between networks (which is likely) use a unique name for the broker and that can be put in DNS at each site - so no code changes on your arduino required at your end.
Without knowing moe about the environment you are using it becomes difficult to advise the best solution. If networks are home based and don't use a local DNS server things may be more difficult. You could for example register your own domain name, but that would not work well with private networks addresses and if you have more than one installation you might need a different address for each setup. There is no guarantee as to how long a change in DNS would take to propagate, so if you are only using a particular netowrk for an hour using a proper domain name would probably be pointless.
Providing a little more information on the networks you will be using may be helpful in allowing us to give you better alternatives.
I will replace the static IP obtaining part with DHCP settings as you told me , but I need to enter IP in the server part.
The device sends the data T.P.H. data of the cellars of small stores to a PC in the local network for a period of one week (Simple home type networks).
But while I was writing these for you, the idea came to mind to set up a broker with a fixed IP on the internet and send it to him.