I’m a bit of a Perl beginner but I’ve been creating a basic program to log data from my energy meter so it can be plotted via gnuplot, using the info UDP request/responses I’ve found here and elsewhere. I’ve been developing this on my new Raspberry Pi, and things have been going pretty well until the power got cut the to Pi yesterday. After it booted up I started the program again (I mean to make it a daemon at some point), but it no longer captures anything – it just times out waiting for the UDP response.
I don’t think it is an issue with recent changes to my prog, as none of my little test progs to turn lights on/off etc are working any more either….
The Pi has a static IP address, and I’ve checked that the wifi-link is still on the same IP address that I’ve set. I have also rebooted the wifi-link just in case there was some sort of old connection held. My iOS app is able to get energy readings with no problems. The pi can ping the wifi-link.
I’ve been watching the wifi-link display when running it in case my Pi needs authorising again, but nothing shows up.
Any thoughts on what might have changed?
I’m feeling like a right idiot now….
I just thought; just because the IP address I’ve previously been communicating with the wifi link on is still pinging, doesn’t necessarily mean it’s still the same device! Checked the wifi link menu and sure enough, it is now on a different IP address, and the previously used address is now used by a laptop!
Corrected the IP address in my hosts file, and my program is working fine again. I have an issue with my router where I can’t assign static IP addresses to a MAC address at the moment, so I guess I’d better get that sorted so this doesn’t happen again…..
If you are getting to grips with UDP, you could send a UDP broadcast out to the whole network. The Wi-Fi link will then respond back to the originating IP address. Sending a signal which does nothing (or perhaps even an invalid one), will cause the Wi-Fi link to respond back to the originating host with a response (or error code). If you do this when your program starts, you will be able to obtain the IP address irrespective of what it is at the time.
Thanks very much for that info – I didn’t realise that was possible. I’d better read up on how to send a broadcast packet from the Perl module I’m using.
You must be logged in to reply to this topic.