04 July, 2020

Getting the first layer right

Over the past few days, I have made several attempts to level the bed of my Ender 5 Plus. I have read the manual that came with the printer, read several forums, and watched several YouTube videos. 

What I have learned
  • The first layer is very important to get right. This is the foundation that the rest of the print is built on. 
  • If a print has trouble sticking to the bed. Check the bed level is a good first step.
  • The OctoPrint plugin Bed Visualizer can help understand where there are high spots and low spots on the build plate.
  • There is the "right" amount of squish. See 'Bed Leveling Guide' image. 

I am using the model 'Bed Leveling Calibration Test Object (Parametric)' by pgreendland. The first couple of attempts turned out poorly. This caused me to relevel the bed. In looking closer at the results, I could clearly see each line the printer laid down. This got me to thinking that maybe under extrusion was the problem. I did switch some part on the extruder motor. I wanted metal parts instead of plastic. 

I performed the standard extrusion test. The hot end was heated to 200 C, I marked the filament at the 100 and 110 mm points, and extruded 100 mm. Only 94 mm of the filament was pulled in. 

To update the extruder steps, I made a back of the configuration using the OctoPrint plugin 'EEPROM Marlin Plugin'.  For my printer, the Extruder steps were 94. Using the formula (expected amount of filament * Current E-Steps) / Actual extrusion amount, I was able to calculate a new step value. 

(100 X 93) / 94 = 98.9

I set and saved the new value to the EEPROM then reran the extrusion test. This time the test hit the mark. 

Reprinting of the 'Bed Leveling Calibration Test Object' turned out better. The print stuck to the bed. The print was not as solid as I expected. I also think that the hot end may be a little high. 

For the next test, I am going with a more complex model. I am not changing any settings. I want to see if the current settings can produce a nice print. I am going with the 'CHEP Calibration Cube' for the model. 



Setting up Octoprint

When I was running my old 3D printer, I found using OctoPrint to be helpful. I think it would be good to set up a new instance of OctoPrint.

Steps
  • From the OctoPrint web site, I download OctoPi 0.17.0. 
  • Using Etcher, burned the image to a 16GB SD card. 
  • Updated the file octopi-wpa-supplicant.txt with my network credentials. 
  • ssh to the pi
  • ran raspi-config
    • changed the user password
    • change timezone
    • rebooted the pi
  • Using a browser, I navigated to the IP of the OctoPi and followed the prompts to set up the first user
At this point, I paused to explore the interface. While I was exploring, OctoPrint went ahead with checking for updates. Updates were discovered and I went ahead with installing them.

Plugins
  • Bed Visualizer
    • Displays 3D mesh of bed topography report
    • Settings
      • General
        • GCODE Commands for Mesh Update Process
          • G28
          • G29 T
  • EEPROM Marlin Editor
  • Floating Navbar
  • Heater Timeout
    • Settings
      • Enable
  • Navbar Temperature
    • Display temperatures on navbar
  • Octolaspe
    • Creates a stabilized timelapse
  • Octoslack
    • monitoring your printer and prints via Slack, Mattermost, Pushbullet, Pushover, Rocket.Chat, Discord, Riot/Matrix, or Microsoft Teams
  • Simple Emergency Stop
  • Themeify


21 June, 2020

Restarting my 3D Printing hobby

Recently, I decided that I missed playing with, working with, and modifying my 3D printer. After a bit of research, I settled on purchasing the Ender 5 Plus.

While I was waiting for the printer to arrive I spent time watching YouTube videos on how to assembly the printer. I picked up several helpful tips and tricks. The Assembly of the printer was quick and easy. 

My first challenge came in leveling the bed. The blame for the challenge is all my fault. I didn't read the documentation carefully. I am made a bad assumption about how the software worked and what steps I needed to perform. Once I did read the documentation and watched a couple of videos, it took about 20 minutes to level the bed. I went through the AUX leveling steps twice just to make sure the bed as fairly level. For leveling, I had the build plate heated to 70 C and the hot-end to 190 C. The Auto-leveling sequence was run.

For the slicing program, I am using Cura 4.6.1. For my first print, the calibration cube was used. I took the defaults that Cura has for the Ender 5 Plus and send the gcode to the SD card. 

Here is where my second challenge appeared. When I put the card into the SD slot the printer didn't find the file. Turns out that the gcode needs to placed at the root level on the SD card and the file name can't be longer than 15 characters. 

Once the file was renamed, the printer recognized the existence of the file. I was then able to get the print started. When the hot-end starting moving from the home position to the starting point of the priming line the extruder sent filament to the hot-end. The priming line printed without issue. The skirt and cube printed without issue. 

I noticed during the print that the heated build got turned off or set to 0. I didn't manually adjust the bed's temperature settings. I also noted a strange noise when the infill was being printed. 



Took several measurements on the X, Y, and Z faces. I got a reading of +/- of .05 mm for most of the cube. The exception was the first two layers which were - .2 mm in the X and Y direction. 

This seems like a reasonable first print. 



ToDo
  • Examine the gcode for purge/prime sequence, to determine if I can get rid of the line the prints from the home position to the start of the purge/prime line.
  • Examine the gcode for changes to the bed temperature to determine if the gcode is turning off the bed or if the firmware is turning off the bed. 

16 February, 2020

Rebuild my docker lab setup

Background

Over the last few weeks, I have rebuilt my Docker lab and Home Assistant set up a few times.  The heart of the setup is a Raspberry 4. Finally, all the hardware I ordered has arrived and I have a bit of time to rebuild my setup. Hopefully, I won't need to rebuild for a while.

Plan

This time I want to set up a Rasberry Pi 4 Model B (2GB) with Raspbain Buster then configure the Pi to use a 1 TB SSD. Since the Rasberry Pi 4 doesn't currently support booting from an SSD, I will use the workaround from James Chambers. Once the Rasberry Pi is set up and a basic configuration is done, I will then install IOTstack from Graham Garner. This will help me set up Docker, HASS.io, Portainer, Mosquitto, and Tasmoadmin.

What I am hoping to get out of this is a stable platform for learning and experimenting with Docker,  Home Automation, Internet of Things, and electronics.

Notes

Setting up the Raspberry Pi

  • Used balenaEtcher to flash Raspbian Buster with desktop to an 8 Gig SD Card
  • Used balenaEtcher to flash Raspbian Buster with desktop to a 1 TB SSD
  • Plugged in a monitor, keyboard, mouse, network cable and applied power
    • I waited for about 5 minutes for the system to run through its first-time power-up.
  • created an empty file named ssh and placed it the boot folder for both SD and SSD
    • created the file wpa_supplicant.conf and placed it in the boot folder for both SD and SSD
    • Set basic config values for keyboard
    • changed the pi default password
    • skipped the update
  • sudo fdisk /dev/sda
    • set the SSD PARTUUID to d34db33f
  • sudo blkid
  • made backup of /boot/cmdline.txt
  • edited /boot/cmdline.txt to use the PARTUUID that was set earlier
  • sudo reboot
  • verified the SSD is being used
    • findmnt -n -o SOURCE /
  • updated /etc/fstab 
    • changed the PARTUUID to d34db33f
  • sudo reboot
  • resizing filesystem
    • delete the partition /dev/sda2
    • create a new partition with a first sector at 532480
    • sudo resize2fs /dev/sda2
      • This takes a while
    • df -h 
      • verify /dev/root shows a size value close to the size of the drive
  • sudo reboot

Configuring the Raspberry Pi

  • set Hostname
  • boot to CLI
  • auto login: uncheck mark
  • sudo reboot
  • verified Raspberry Pi configuration
  • verified that I can ssh into the raspberry pi
  • sudo apt update
  • sudo apt upgrade

Install IOTstack

  • ensure git is installed
    • sudo apt install git
  • clone IOTstack
    • git clone https://github.com/gcgarner/IOTstack.git ~/IOTstack
  • run menu
    • cd IOTstack
    • ./menu.sh
      • installed docker
      • installed Hass.io
      • installed Portainer
      • installed Mosquitto
      • installed tasmoadmin
  • docker-compose up -d




References

Github gcgarner / IOTstack







26 January, 2020

Setting up Home Assistant on Raspberry Pi using generic Linux host method



Recently my installation of Home Assistant died. It appears that I burned up the SD card. I can no longer read the SD Card. When I run gparted against the SD card, the card mounts in read-only mode. After a bit of research, I came up with a plan.

Rough Plan


  • Install the latest Raspbian Buster image
  • Reconfigure the Pi to run from a hard drive
  • Install Home Assistant using the generic Linux host method

Steps

  • Downloaded Raspbian Buster with desktop from the Raspberry Pi website
  • Using balenaEtcher to flash Buster to an SD card (8GB)
  • Booted the Pi for the first time
  • Setup the language, keyboard, and timezone. 
    • Changed the pi user's password
    • Selected the WiFi network
    • Updated the software
  • Updated the packages
    • sudo apt update
    • sudo apt upgrade
    • sudo reboot
  • Followed the directions from the blog post 'Quick SD to SSD on the pi 4'
    • use the utility 'SD Card Copier' to copy the SD card to the hard drive
    • run 'sudo blkid' to get the UUID of the SD sard and the hard drive
    • backup the file /boot/cmdline.txt
    • edit the file /boot/cmdline.txt. Change the partuuid from using the SD card to the hard drive
    • reboot
    • Note: must leave the SD card in the Raspberry Pi
  • Changed the hostname of the Pi
  • Enabled SSH on the Pi
  • Setup ssh key on my main PC
    • ssh-keygen
    • ssh-copy -i ~/.ssh/key-name pi@ip.address
    • ssh-add
  • Disable Password Authentication on the Pi
    • sudo nano /etc/ssh/sshd_config
      • Uncommented the line 'PasswordAuthentication yes'
      • changed yes to no
  • Set a static IP for the Pi
    • edit /etc/dhcpcd.conf
      • added
        • interface wlan0
        • static ip_address=XXX.XXX.XXX.XXX
        • static routers=XXX.XXX.XXX.XXX
        • static domain_name_servers=XXX.XXX.XXX.XXX
    • reboot
  • Changed Pi Configuration to boot to cli
  • Followed the directions from the blog post 'Install Docker and Docker Compose on Raspberry pi 4(Raspbian Buster)'
    • curl -sSL get.docker.com | sh
    • sudo usermod -aG docker pi
    • sudo apt-get install libffi-dev libssl-dev
    • sudo apt install python3-dev
    • sudo apt-get install -y python3 python3-pip
    • sudo pip3 install docker-compose
  • Followed installer for a generic Linux system
    • sudo apt install bash
    • sudo apt install jq
    • sudo apt install curl
    • sudo apt install avahi-daemon
    • sudo apt install dbus
    • sudo apt install apparmor-utils
  • curl -sL https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh | bash -s -- -m raspberrypi4-64
  • Setup Home Assistant
There was an issue with Home Assistant connecting to the internet. I removed the changes to /etc/dhcpcd.config. This seems to have helped. 

23 December, 2019

Third stop on the Docker learning train - Quickstart: Compose and ASP.NET Core with SQL Server

The third stop on my Docker learning train is a recommendation from the Docker Samples. The tutorial is titled 'Quickstart: Compose and ASP.NET Core with SQL Server'. This is going to be a whistle-stop.

This tutorial shows using the Docker Engine running on Linux to set up and run an ASP.NET Core application using a .NET Cor SKD image and SQL Server on Linux image. The tutorial makes use of Docker Compose for defining and running multiple container applications.

The tutorial references an older version (2.1) of the .NET Core libraries. My computer is running a newer (3.1) version of the .NET Core libraries. I wanted to see what error messages and problems running this setup would be.

The first change I made was to the docker-compose.yml file. I changed the port from 8000 to 9090 because I already had a different container using port 8000 and 9000. The second change made was in the "startup.cs" file. I commented out the setting up the connection variable. I moved the value of the connection to the "DefaultConnection" in the "appsettings.json" file. I needed to make a few more changes to the rest of the "ConfigureServices" method.


public void ConfigureServices (IServiceCollection services) {
    // Database connection string.
    // Make sure to update the Password value below from "Your_password123" to your actual password.
    // var connection = @"Server=db;Database=master;User=sa;Password=Your_password123;";

    services.Configure (options => {
    // This lambda determines whether user consent for non-essential cookies is needed for a given request.
        options.CheckConsentNeeded = context => true;
        options.MinimumSameSitePolicy = SameSiteMode.None;
        });

    services.AddDbContext (options =>
        options.UseSqlServer (
            Configuration.GetConnectionString ("DefaultConnection")));
    services.AddDefaultIdentity ()
        .AddEntityFrameworkStores ();

    services.AddMvc ().SetCompatibilityVersion (CompatibilityVersion.Version_2_1);
}

On my computer, I encountered an issue with running 'docker-compose build'. The error message was
"ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable."
After a bit of research, I came to find out that this is a fairly generic and common message that could have several possible causes. For me, it turned out the I needed to change the permissions on the "docker.sock" file. I fixed the issue be running
sudo chmod 666 /var/run/docker.sock

The running of the command 'docker-compose up' wrote many messages to the console that gives the appearance of that the application and database are running. I can also have a couple of active containers. When I navigate to localhost:9090, the browser displays a "This site can't be reached" message. I am not going to take the time to figure out the problem at this time.



References 

Docker Compose - "Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration."

The article on Medium "If you faced an issue like 'Couldn't connect to Docker daemon at http+docker://localunixsocket -- is it running?'..." was helpful in dealing with an error from running 'docker-compose build'





19 December, 2019

Second stop on the Docker learning train - Dockerize an ASP.NET Core application

The second stop on my Docker learning train is a recommendation from the Docker Samples. The tutorial is titled 'Dockerize an ASP.NET Core application'.

When I first read through the tutorial, I figured this was going to be quick and easy. Due to making a few mistakes in creating the Dockerfile, I ended up with a few lessons learned.

The first lesson I learned was to read the output from running the docker build command carefully. It was interesting to see that the Docker daemon creates and removes intermediate containers.

The next lesson was when a container reports an error code 145 carefully double-check the Dockerfile. Pay close attention to what is being used for the DotNet Core runtime. The 'SDK' should be used for the restore and publish command while 'ASPNET' should be used for the runtime.

Another lesson learned is to use '.dockerignore' file to keep from unnecessary files from being included in the image.

The last lesson was to use interactive mode. The tutorial did not go through the steps I needed to do a bit of research to figure it out. The Alpine image does not include bash. I modified the Dockerfile to pull in bash and a few other tools. Rebuilt the image. The used the interactive mode switches to get a command prompt.

Dockerfile:
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
WORKDIR /app/aspnetapp

# copy csproj and restore as distinct layers
COPY myWebApp/*.csproj ./
RUN dotnet restore

# copy everything else and build app
COPY myWebApp/. ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS runtime
WORKDIR /app
COPY --from=build /app/aspnetapp/out .

# Uncomment the following line to install bash and other tools useful for debugging
RUN apk add --no-cache bash coreutils grep sed

ENTRYPOINT ["dotnet", "myWebApp.dll"]

Command to build the image.

docker build -t {image name} .

Command to start the container in interactive mode and to override the default entry point

docker run -it --entrypoint /bin/bash {image name}

Reference

.dockerignore file
"Before the docker CLI sends the context to the docker daemon, it looks for a file named .dockerignore in the root directory of the context. If this file exists, the CLI modifies the context to exclude files and directories that match patterns in it. This helps to avoid unnecessarily sending large or sensitive files and directories to the daemon and potentially adding them to images using ADD or COPY." - https://docs.docker.com/engine/reference/#dockerignore-file

Challenging myself to learn something new

I have recently set a big challenge for myself. I want to know about Machine Learning . To add to the challenge, I am trying out usin...