Get broadcast ip from ip and gateway in Arduino

Is there a way to get the broadcast ip from ip and subnet in Arduino?
I know if the system has an ip of and subnet of, then is its broadcast ip.
But how do I get it programmatically in Arduino, without any kind of hardcoding?

I need this because, I need the Arduino's to report its presence in the network, so that its controller can detect them and control them. The controller will not be a specific machine. It could be an Android app, and whoever has the app installed should be able to identify the Arduino and control it.

Once broadcast ip is known, I can transmit periodic pings over udp, and have the controllers detect them.

If you invert the subnet and OR that with the ip address you should normally end up with the broadcast address iirc.

simply use to broadcast in the same network. you would use network address if you want to broadcast in a specific network

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.