[{"element_type":"text","content":"\n  \n        \u003ch3\u003e\u003cstrong\u003eThe Problem:\u003c/strong\u003e\u003c/h3\u003e\n\u003cp\u003eA frequent problem I have when creating a new Raspberry Pi-based project is determining the IP address of the device.  I am often working with Pi projects in a \"headless\" (no monitor) configuration using SSH to log in from a PC on the same LAN network.  But to log in this way, I need the Pi's IP address, which sets up a chicken-and-egg problem that goes like this:\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp style=\"text-align: left;\"\u003e\u003cem\u003eI want to connect (SSH) to a headless Raspberry Pi, but before I can do so, I first need to attach a monitor and keyboard to it to login locally and get its IP address (with 'ifconfig').  \u003c/em\u003e\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eThis is the very thing I would like to avoid since the system will ultimately be \"headless\".  In truth, while it is only a minor inconvenience, it is one I'd like to do without.  The more new RPi systems that you set up, the more tedious it is to pull out a monitor and keyboard to find the IP address of each one before you can begin remotely connecting to it over the LAN using SSH.\u003c/p\u003e\n      \n","metadata":{}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003ch3\u003e\u003cstrong\u003eMy Solution:\u003c/strong\u003e\u003c/h3\u003e\n\u003cp\u003eI would like to be able to find the IP address of a headless RPi without having to connect a monitor and keyboard to it.  Ideally, I would be able to connect my new RPi to my network, and know the IP address that is it assigned.  Then, I could simply connect directly to it using SSH from my PC on the same network.\u003c/p\u003e\n\u003cp\u003eAs is the case for many others,\u003cstrong\u003e \u003c/strong\u003e\u003cspan style=\"text-decoration: underline;\"\u003emy minor annoyance at \"the problem\" turned into a full-blown project to solve it\u003c/span\u003e.  I created a program I called \u003cem\u003eHello Pi\u003c/em\u003e that can be run on a Linux or Windows computer to identify the IP address of a Pi (or other device) connected to the same network segment.\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"text","content":"\n  \n        \u003ch3\u003e\u003cstrong\u003eThe How:\u003c/strong\u003e\u003c/h3\u003e\n\u003cp\u003e\u003cem\u003eHello Pi\u003c/em\u003e running on a PC passively listens for DHCP messages that are multicast by other devices on the network.  When an RPi (or any device that uses DHCP) first powers up when connected to a network, it sends a multicast DHCP message to identify itself (by MAC address) and request an IP address from the network's DHCP server.  The DHCP server responds with an IP address that it assigns to the MAC address specified in the request.\u003c/p\u003e\n\u003cp\u003e\u003cem\u003eHello Pi\u003c/em\u003e listens for these DHCP messages and displays the IP addresses that are assigned.  It can be used to display only RPis that are connecting on the network by automatically filtering on MAC address ranges used by those devices, or it can display ALL devices connecting that use DHCP.\u003c/p\u003e\n\u003cp\u003eDHCP message are not only sent when a device is first connected to a network (to request an IP address), but periodically over longer time intervals to notify the DHCP server that it is still present and would like to continue using the same IP address.  If \u003cem\u003eHello Pi \u003c/em\u003eis left running, you will see these messages over time as devices connect and/or renew their DHCP \"lease\".\u003c/p\u003e\n      \n","metadata":{}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003ch3\u003e\u003cstrong\u003eExample Usage:\u003c/strong\u003e\u003c/h3\u003e\n\u003cp\u003e\u003cem\u003eHello Pi\u003c/em\u003e is run from a computer (the 'Host') connected to the same DHCP-configured LAN as the RPi (the 'Target') or other device to be discovered.\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eUsing the command-prompt, start \u003cem\u003eHello Pi\u003c/em\u003e on the Host.\n\u003cul\u003e\n\u003cli\u003eNote that the -h option can be used to see a list of available command options.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003eThe initial state of the Target (RPi or device) is powered-down/unpowered.\u003c/li\u003e\n\u003cli\u003eConnect Target to the LAN.\n\u003cul\u003e\n\u003cli\u003eIf using Ethernet, physically connect the cable.\u003c/li\u003e\n\u003cli\u003eIf using WiFi, configure the \u003cem\u003ewpa_supplicant.conf\u003c/em\u003e file in the boot folder of the OS image.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/li\u003e\n\u003cli\u003ePower-up the Target and wait while it boots.\u003c/li\u003e\n\u003cli\u003eObserve the output of \u003cem\u003eHello Pi\u003c/em\u003e on the Host to learn the ip address assigned to the Target.\u003c/li\u003e\n\u003cli\u003eTo repeat the process, power-down the Target and return to step 2.\u003c/li\u003e\n\u003c/ol\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/339/original/IMG_2984.jpeg?1700335955","metadata":{"caption":"Hello Pi reporting the IP address of all RPis on the network."}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/341/original/IMG_2988.jpeg?1700336139","metadata":{"caption":"Hello Pi reporting the IP address of all devices on the network."}},{"element_type":"text","content":"\n  \n        \u003ch3\u003e\u003cstrong\u003eHow You Can Use It:\u003c/strong\u003e\u003c/h3\u003e\n\u003cp\u003e\u003cem\u003eHello Pi \u003c/em\u003eis available on PyPi and on Github.  The project page on each site includes a very detailed description of how it works and how to use it. \u003c/p\u003e\n\u003ch4 style=\"text-align: left;\"\u003e\n\u003cem\u003eHello Pi\u003c/em\u003e on PyPi:\u003c/h4\u003e\n\u003cblockquote\u003e\n\u003cp\u003e\u003ca href=\"https://pypi.org/project/hellopi/\"\u003ehttps://pypi.org/project/hellopi/\u003c/a\u003e\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003ch4 style=\"text-align: left;\"\u003e\n\u003cem\u003eHello Pi\u003c/em\u003e on Github:\u003c/h4\u003e\n\u003cblockquote\u003e\n\u003cp\u003e\u003ca title=\"Github: Hello Pi\" href=\"https://github.com/300bps/hellopi\" target=\"_blank\"\u003ehttps://github.com/300bps/hellopi\u003c/a\u003e\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003e \u003c/p\u003e\n      \n","metadata":{}}]