Finding IP address of an WiFi device
One of the problems when playing with WiFi robots, is finding out what IP address it is so you can send commands to control or update its on-board program.
There are various manual methods
- give it a static IP (last resort method but it works)
- mount a display, can just be simple 7 seg display
- Flash a led using morse code – tedious and not child friendly
- etc etc
My SID method for a RaspberryPi using LAN broadcasts to send its IP but this doesn’t work if the LAN router doesn’t support broadcasts (and many don’t)
Yesterday, at Preston Hackspace meeting, Jim Burns came up with concept of using an intermediate server to store the IP.
So basic concept is robot (or any WiFi Iot device) finds out its IP and then sends it to a known server. The controlling computer contacts the server and retrieves the IP.
Luckily, @OmerK showed us dweet.io @WutheringBytes. which makes its trivial (and free ) to post data from a connected device up to a server and then that info can be read back by any other computer/device that knows the feed name.
So, I added some code to my NodeMCU miniBot and got the first bit working
So to find find out the last know IP address of my NodeMCU minibot – I just need to check
Only downside I see at moment is need for device to have internet access and not just LAN connection (and for dweet to be working of course)
I know have to see if I can turn it around as in my case, which is using Scratch with its broadcast mechanism, my bot needs to find out the IP of the controlling PC
This is almost exactly what I do!
I also run a programming club at a school with Raspberry Pis, and what I did was write a server that received all the IPs of the Raspberry Pis, and then when you launched Scratch, it provided a list of IP addresses of which you could connect to. Clicking on an IP address lit up the ACT light on the Pi, so you would know which one was which.
It was the only way I could get the Pis connected on the school’s VERY large and VERY restricted network. I’ve never shared the code or access to my server, but I would if people were interested in something like this.