I use Photon as TCP server to a slave unit. An application installed in PC can control this slave unit but demands the IP address of server. How could i get the IP of Photon using my PC? I’m not expert on networks and internet protocols, so please in English not Chinese!
Its documented here in the docs with this example:
// PRINT THE DEVICE'S IP ADDRESS IN // THE FORMAT 192.168.0.10 IPAddress myIP = WiFi.localIP(); Serial.println(myIP); // prints the device's IP address
If you have access to your router, there’s often a list of connected devices.
Yes, in router web interface and under the menu WLAN–>Associated Devices, the IP of Photon is listed each time is connected. The same applies and for my custom P1 module. The same and for my smartphone. There is a list of 3 associated devices and i couldn’t locate which one is the Photon, without disabling the WLAN of router, disconnecting all 3 devices, enabling again WLAN and connecting only the Photon. Only in this way, the Photon is solely listed. Disconnecting all 3 devices without disabling WLAN, are continuously listed as connected. So the right way could be:
a) Make sure that your router is connected to internet
b) Disable or disconnect all WiFi devices (in smartphone disable the WiFi connection)
c) Disable the WLAN of router
d) Enable again the WLAN
e) Connect only Photon
f) The Photon IP and MAC address are shown in WLAN–>Associated Devices menu of router.
However, each time the Photon or the P1 is disconnected–>connected, it may appear with a different IP address (Is this the so called Dynamic IP?). Only the MAC address is unique for each device. For that reason, another one step is necessary in the above sequence:
g) Are you sure that in WLAN only the Photon is listed? If yes write down its MAC address. The next time you will need the Photon IP, is the assigned IP address that corresponds to its unique MAC address.
The code @Postler mentioned then quickly becomes a whole lot more attractive
You can request the IP with a variable, or have it published, or get it over serial.
you can also turn off the other 2 devices and reboot your gateway/modem the one listed will be the photon. at least that is my method if i’m hunting an IP. i think if you hover the cursor over the IP that you’ll get some identifying info that may help.
I agree that is very attractive but how could i obtain all these? I’m still in the reading of Docs provided. It is a labyrinth and I haven’t so much time available. I have installed both the CLI and Desktop IDE. What is the right tool for each of the above? The IP address is just a small detail in the whole project that i have to implement within 1 - 1.5 month. My knowledge is restricted to PIC and Atmel micros and i’m used in the use of Flowcode of Matrix TSL to develop the program code required for my projects. Flowcode offers a lot of ready compiled components, for that reason i use it, is fast. The last Flowcode v7 includes and the STM32F processor that is used by Photon but the supported TCP/IP components are designed to work with WIZnet modules.
This is a nice tutorial for variables: Tutorial: Spark Variable and Function on One Web Page
Here’s one for publishes: Tutorial: Getting Started with Spark.publish()
As for serial, that’s just regular Serial communication, as you would with an Arduino for example. Any serial monitor should be able to receive that.
On the router front you should be able to identify a Photon using the MAC, the E0:4F:43: prefix belongs to USI who make the module and its quite likely to be the only one listed unless your house is bristling with Photons.
For a one-off installation you could assign the device a static IP in your routers settings so that you don’t need to find it, another option is to use mDNS so you can connect to it by name.