Noscere Vivere Est

To Learn is to Live


Leave a comment

Installing Raspberry Pi OS Lite

Raspberry Pi:

Install Raspberry Pi OS Lite (64-bit) using the Raspberry Pi Imager.

  1. Start the Raspberry Pi Imager.
  2. Select the Raspberry Pi Modell: Raspberry Pi Zero 2 W.
  3. Select the operating system to be installed: Raspberry Pi OS (other) -> Raspberry Pi OS Lite (64-bit).
  4. Plugin the SD card.
  5. Select the SD card.
  6. Confirm to use the previously configured settings, i.e., username, password, wifi, language settings, and the ssh service are preconfigured in the Raspberry Pi Imager .
  7. Confirm to remove the contents of the SD card. Wait until the writing is complete.
  8. Now the Raspberry Pi OS is flashed on the SD card.
  9. Remove the SD card from your laptop.
  10. Plug the SD card into your Raspberry Pi Zero.
  11. Boot the raspberry pi.
  12. In cyqwin: update the host key in known_hosts:
    $ ssh-keygen -R hawaii02
  13. Connect to the Raspberry Pi Zero:
    $ ssh wolfgang@hawaii02
  14. create the folder .ssh
    $ mkdir .ssh
  15. logoff
  16. Copy the public key to the raspberry pi Zero:
    $ scp id_rsa.pub ws@hawaii02:/home/ws/.ssh/authorized_keys
  17. Connect to the Raspberry Pi Zero:
    $ ssh wolfgang@hawaii02
  18. Install the Pi OS Updates:
    $ sudo apt update
    $ sudo apt full-upgrade

References


Leave a comment

Installing Raspberry Pi and ev3dev

Raspberry Pi:

Install Raspberry Pi OS Lite (64-bit) using the Raspberry Pi Imager.

  1. Start the Raspberry Pi Imager.
  2. Select the Raspberry Pi Modell, e.g., Raspberry Pi 3.
  3. Select the operating system to be installed, e.g., Raspberry Pi OS Lite (64-bit).
  4. Plugin the SD card.
  5. Select the SD card.
  6. Confirm to use the previously configured settings, i.e., username, password, wifi, language settings, and the ssh service are preconfigured in the Raspberry Pi Imager .
  7. Confirm to remove the contents of the SD card. Wait until the writing is complete.
  8. Now the Raspberry Pi OS is flashed on the SD card.
  9. Remove the SD card and insert it again. Now the SD card drive can be opened.
  10. Preconfigure your networking:
    • (mostly not necessary) Edit config.txt on the boot partition (if e: is the drive of your SD card, then in cygwin it is accessible by: /cygdrive/e), append the following:
      dtoverlay=dwc2
      Save and exit.
    • Edit cmdline.txt. Look for rootwait, and add modules-load=dwc2,g_ether immediately after.
      Note the formatting of cmdline.txt is very strict. Commands are separated by spaces, and newlines are not allowed.
      Save and exit.
  11. Remove the SD card from your laptop.
  12. Plug the SD card into your Raspberry Pi.
  13. Boot the raspberry pi.
  14. In cyqwin: update the host key in known_hosts:
    $ ssh-keygen -R raspberrypi
  15. Connect to the Raspberry Pi:
    $ ssh wolfgang@raspberrypi
  16. Install Updates:
    $ sudo apt update
    $ sudo apt full-upgrade
  17. Copy the public key from local ~/.ssh/id_rsa.pub to the raspberry pi ~/.ssh/authorized_keys.

EV3dev:

Flash the current ev3dev version on a MicroSD Card and boot the EV3 Brick with it.

  1. Download the latest ev3dev image file: https://www.ev3dev.org/downloads.
  2. Flash the SD card (use Etcher and follow the instructions Getting Started with ev3dev).
  3. Plug the newly flashed SD card into the EV3 Brick.
  4. Follow the instructions in: Connecting EV3 Brick (EV3dev) and Raspberry
  5. Replace the file /etc/apt/source.list by:
    deb http://archive.debian.org/debian stretch main contrib non-free
    #deb-src http://archive.debian.org/debian stretch main contrib non-free
    
    deb http://archive.ev3dev.org/debian stretch main
    #deb-src http://archive.ev3dev.org/debian stretch main
    
  6. Install Updates:
    sudo apt update
    sudo apt upgrade

References


1 Comment

Connecting EV3 Brick (ev3dev) and Raspberry Pi via USB

  1. Boot your Raspberry PI.
  2. Boot the EV3 brick.
  3. Connect Raspberry PI and EV3 brick with the USB cable.
  4. Navigate on the Brickman UI:
    Wireless and Networks -> All Network Connections… -> Wired -> IPv4 -> Change… and select Load Linux defaults.
    Go back to Wired and select Connect. On the screen the new IP Address (default: 10.42.0.3) is displayed and the state is set to Connected.
    Select the menu item Connect automatically and go back to the main menu.
  5. Open a terminal window and enter:
    $ sudo ip ad add 10.42.0.1/24 dev usb0
    Now you can open a ssh session:
    $ ssh [email protected]
    Enter the default password maker.
    Close the ssh session again.
  6. In order to set a static ip address with the NetworkManager, list all interface information:
    $ nmcli device status
    DEVICE	TYPE		STATE			CONNECTION
    wlan0	wifi		connected		preconfigured 
    usb0	ethernet	connected		Wired connection 2
    lo	loopback	connected (externally)	lo
    eth0	ethernet	unavailable

    Edit the usb0 connection using the terminal UI (nmtui):
    $ sudo nmtui edit "Wired connection 2" Change the IPv4 CONFIGURATION from <Automatic> to <Manual>, and then use <Show> to show all the settings.
    Now simply add the IPv4 address, i.e., 10.42.0.1/24.
    Then go down to the bottom and select ‘OK’. To apply the changes, you need to restart the NetworkManager:
    $ sudo systemctl restart NetworkManager

  7. In raspberrypi add the name of the brick to the hosts
    $ sudo vi /etc/hosts
    and add the following line:
    10.42.0.3 ev3dev
  8. Creating the Wi-Fi to Ethernet Bridge on your Raspberry Pi.
    Create the Wi-Fi bridge with the NetworkManager:
    $ sudo nmcli c add con-name wifibridge type ethernet ifname usb0 ipv4.method shared ipv6.method ignore
    Turn on the connection:
    $ sudo nmcli con up wifibridge
    Check whether the connection is active:
    $ nmcli con show
    Redirect the traffic from our usb0 connection to the tunnel.

    $ sudo apt install iptables
    $ sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
    $ sudo iptables -A FORWARD -i tun0 -o usb0 -m state --state RELATED,ESTABLISHED -j ACCEPT
    $ sudo iptables -A FORWARD -i usb0 -o tun0 -j ACCEPT
  9. Restart your Raspberry PI.
  10. In EV3 add the name of the brick to the hosts
    $ sudo vi /etc/hosts
    and add the following line:
    10.42.0.1  raspberrypi

References


Leave a comment

Clone your SD Card

Clone your SD card using Win32 Disk Imager (Windows)

  • Download and install Win32 Disk Imager.
  • Open Win32 Disk Imager.
  • Create an image file:
    • Click on the file icon next to the “Image File” field. Select the destination folder where you want to place the image file and ensure you add a name with a “.img” extension.
    • In the Device section, select the SD card that you want to clone.
    • click the “Read” button. Win32DiskImager will immediately start creating a disk image out of the SD card. This process might take a few minutes.
  • Write the cloned image to an SD card:
    • In the image file section, use the “file” icon to select the image you just created. In the “Device” dropdown menu, select your new SD card.
    • Click “Write” to get started.

References


Leave a comment

Using Visual Studio Code

  1. Install Cygwin on your computer.
  2. Install Visual Studio Code on your computer.
  3. Start Raspberry Pi and EV3.
  4. Create the development users on Raspberry Pi:
    $ sudo adduser client
    $ sudo adduser server
  5. Copy the SSH key from youtcomputer to the newly created users:
    $ scp /cygdrive/c/Users/<username>/.ssh/id_rsa.pub client@raspberrypi:/home/client/.ssh/authorized_keys
    $ scp /cygdrive/c/Users/<username>/.ssh/id_rsa.pub server@raspberrypi:/home/server/.ssh/authorized_keys
  6. Edit VS Code remote configuration file /cygdrive/c/Users/<username>/.ssh/config:
    Host raspiClient
    HostName raspberrypi
    User client
    IdentityFile C:\Users\<username>\.ssh\id_rsa

    Host ev3Server
    HostName raspberrypi
    User server
    IdentityFile C:\Users\<username>\.ssh\id_rsa
  7. Create the SSH keys on the Raspberry Pi for the new users:
    $ ssh-keygen
  8. Copy the public key of each user to robot@ev3dev:
    $ ssh-copy-id robot@ev3dev
  9. Create the project folders in each of the users home folder:
    client@raspberrypi:~ $ mkdir raspi-client
    server@raspberrypi:~ $ mkdir ev3-server
  10. Open Visual Studio Code.
  11. In the Remote Explorer select “Connect in Current Window…” to “raspiClient” and open the folder raspi-client.
    In Extensions press Install in SSH: raspiClient for the extensions Python and Python Debugger.
  12. In the Remote Explorer select “Connect in Current Window…” to “ev3Server” and open the folder ev3-server.
    In Extensions press Install in SSH: ev3Server for the extensions Python, Python Debugger, and ev3dev-browser.

References


Leave a comment

Install the Raspi Cam

Prepare the Raspberry Pi

  1. On the Raspbian desktop select the menu item Menu/Preferences/Raspberry Pi Configuration and go the tab Interfaces.
  2. Activate the interface camera. Confirm your changes and press the OK button.
  3. Reboot your Raspberry Pi.
  4. Update and upgrade Raspbian:
    $ sudo apt-get update
    $ sudo apt-get upgrade
  5. Install Motion:
    $ sudo apt install libcamera-tools libcamera-v4l2 motion -y
  6. Configure Motion:
    $ sudo vi /etc/motion/motion.conf
    Update the following parameters:
    webcontrol_localhost off
    stream_localhost off
    rotate 180
  7. Start Motion:
    $ sudo libcamerify motion
    Now you can have a look at the output of the camera at: http://raspberrypi:8081
  8. Start Motion on every system start, edit:
    $ sudo vi /lib/systemd/system/motion.service
    Replace the line ExecStart by:
    ExecStart=/usr/bin/libcamerify /usr/bin/motion
    Adjust user rights to access the different files:
    $ sudo find /var/log/motion -delete
    $ sudo mkdir /var/log/motion
    $ sudo chown motion:motion /var/log/motion
    $ sudo systemctl enable motion.service
    $ sudo systemctl start motion.service
  9. Check the service motion:
    $ systemctl status motion
  10. Stop the service motion:
    $ sudo systemctl stop motion.service
  11. Disable the red LED on the camera:
    Edit the file /boot/config.txt and add the following entry:
    disable_camera_led=1
  12. Reboot your Raspberry Pi.
  13. Watch the camera:
    Raspberry Pi (Livestream)

References

Design a site like this with WordPress.com
Get started