Tuesday, April 24, 2018

Setting up a headless Raspberry Pi

At the end of my previous post on reading my Smart Meter, I said I wanted to move the monitoring hardware and software off of the PC and onto a dedicated Raspberry Pi. Since I wasn't getting to this task at home, I thought I would try to do it during lunch at the office. Unfortunately, I don't have access to as much equipment there, but then that's part of the challenge.

In the office I just have my laptop, with keyboard and monitors tethered to other systems.  I was planning on following the steps in this post on configuring the RPi without those devices, and only using a PuTTY SSH to establish a serial terminal connection:


However, I also do not have open access to the corporate network or router and am running Windows instead of Linux. There were some more tips here for a direct ethernet cable connection:


but the problem is I do not have a good way to determine the IP address that the RPi self-assigns when it boots. Then I remembered that I run the Wireshark protocol analyzer on my Linux systems, and there is also a Windows version available!


So here's the steps:
  • On the Windows laptop, download the latest version of Raspian and burn the image to a microSD card.
  • From a Windows command prompt, create a dummy file named 'ssh' and place it in the Linux boot directory located on the card (in this case, the card reader has assigned drive E to it).
    • copy /b NUL ssh
    • move ssh e:
  • Eject the the microSD card and install it into the RPi.
  • Connect the laptop and the RPi together with a standard ethernet cable.
  • Power up the RPi and wait a couple of minutes for it to self-assign an IP address.
  • On your laptop, start Wireshark and select the Ethernet interface to analyze:


  • Examine the first few lines of the analysis to see what IP address the RPi is broadcasting from (in this case 169.254.12.109):

  • Now that I know the IP address, I can log into the RPi using PuTTY:

  • And we are in!!

    Next steps:
    •  Configure the RPi's network settings (e.g., set a static IP address)
    •  Set up internet connection sharing on my laptop so I can update the RPi with the RTLSDR software:


      3 comments:

      1. Instead of Wireshark, I am now using 'Advanced IP Scanner' to find the IP address of the RPi on first install boot.

        App is a free download from https://www.advanced-ip-scanner.com and can be set to look for devices on '192.168.137.1-254' .

        ReplyDelete
      2. Note to self: if the microSD card has already been used in an RPi and you need to install a new version of Raspbian, the partition visible to Windows will be too small for Etcher to write to (for example 41 MB on a 16 GB card)

        First you will need to use the Windows CMD prompt to run DISKPART where you can 'select' and 'clean' the SD card boot partition.

        Eject the SD card and reinsert into you Windows computer.
        The full card will then be available to Etcher.

        ReplyDelete
      3. Steps for running DISKPART:
        - Insert SD card into the PC's card reader
        - Start a Windows command prompt
        - Run DISKPART to open the console.
        - List all of your disks by typing LIST DISK
        - Select the proper disk with SELECT DISK # (where # is the SD card).
        - Type CLEAN to clear the partition table on the card
        (effectively blanking it)
        - Exit the console
        - Exit the command prompt
        - Eject the SD card

        ReplyDelete