Getting Lost in The (Google) Cloud(s)

I’ve been very interested in the topic of machine learning, so I did some research and found an awesome project that I could do with my Vector Robot (…who I may refer to as El Robo sometimes).

The Project:

After some research, I found a project that would allow me to learn about robotics, machine learning, and object detection with Vector: https://medium.com/@unbug/anki-vector-detects-objects-with-machine-learning-a095317326e1

Basically, the project would allow my Vector Robot to connect to the Google Cloud Vision API so it could machine learn and object detect.

The list of instructions seemed short enough:

INSTRUCTION SET A

  1. Install Vector Python SDK. You can test the SDK by running any of the examples from anki/vector-python-sdk/examples/tutorials/
  2. Set up your Google Vision account. Then follow the Quickstart to test the API.
  3. Clone this project to local. It requires Python 3.6+.
  4. Don’t forget to set Google Vision environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key. e.g. export GOOGLE_APPLICATION_CREDENTIALS="/Workspace/Vector-vision-62d48ad8da6e.json"
  5. Make sure your computer and Vector in the same WiFi network. Then run python3 object_detection.py.

source – https://medium.com/@unbug/anki-vector-detects-objects-with-machine-learning-a095317326e1

Step one was easy-peasy, since I had tested and ran the SDK a multitude of times previously already (woo-hoo!). But oh boy, guess what Step 2 truly looked like once you followed the Quickstart link for the API setup:

INSTRUCTION SET B

  1. Select or create a GCP project.
  2. Make sure that billing is enabled for your Google Cloud Platform project.LEARN HOW TO ENABLE BILLING
  3. Enable the Cloud Vision API.ENABLE THE API
  4. Set up authentication:
    1. In the GCP Console, go to the Create service account key page.GO TO THE CREATE SERVICE ACCOUNT KEY PAGE
    2. From the Service account list, select New service account.
    3. In the Service account name field, enter a name.
    4. From the Role list, select Project > Owner.Note: The Role field authorizes your service account to access resources. You can view and change this field later by using the GCP Console. If you are developing a production app, specify more granular permissions than Project > Owner. For more information, see granting roles to service accounts.
    5. Click Create. A JSON file that contains your key downloads to your computer.
  5. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again.Example: Linux or macOSExample: Windows

For more on setting up your Python development environment, refer to the Python Development Environment Setup Guide.

pip install --upgrade google-cloud-vision

source – https://cloud.google.com/vision/docs/quickstart-client-libraries

Yeah, so things got complicated real fast. Instruction Set A:PT 2 is where I officially fell down the rabbit hole of Google Cloud.

For ease of reference, I’ve labeled the instructions sets A and B, but let’s be clear: All of B is actually just a sub-set of A. Instruction set B is just to set up Google Cloud Platform account and installation, which was not something I was anticipating to learn throughout this journey, but I am so happy I stumbled upon it!

Google Cloud is offering one year free for new users, which is a crazy value considering the retail price allotted is $900+ for the year!

Once I set up my Google Cloud Platform account and logged into the console, I felt a unique sense of adrenaline, almost with a tint of rebellion.

Reading all of the tabs and sub-tabs like: Cloud Build, Big Data, and last but not least… Artificial Intelligence. I don’t even have the right words that could capture the feelings I was experiencing while scrolling up and down the console’s navigation menu, but I definitely had a huge smile on my face. Although I had (and still don’t) exactly know what Google Cloud can do or how to use it fully, what was clear right away, even as a complete novice, was that this tool is powerful and if learned properly, it could be utilized for epic projects (and help with future career prospects, *wink wink*).

Im a very visual learner, so seeing the categorization of the navigation menu taught me vital information for my coding journey, because it can be used like a road map. Now I know for sure that two areas of interest I have going forward involve Big Data and Artificial Intelligence.

As I continued to read Google’s instructions, a little voice was starting to whisper that perhaps this project was over my head. Especially once I got down to Instruction Set B: Step 5

  • Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again.

Which corresponded to Instruction Set A: Step 4

  • Don’t forget to set Google Vision environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key. e.g. export GOOGLE_APPLICATION_CREDENTIALS="/Workspace/Vector-vision-62d48ad8da6e.json"

And these instructions left me like this:

But no matter how much I re-read the instructions, I just couldn’t understand what they were telling me, which actually made me feel as if I didn’t even know how to read! After some trial and error, I looked more like this:

Finally, I decided to cave and ask for help. Luckily, my husband and his coworkers were over. I asked them for help but quickly came to learn that Google Cloud is a pretty niche subject to just casually ask about.

“Damnit, Jason!”

I was stuck on the .json file part, for which I kept yelling “Damnit, Jason!” in the house, confusing everyone. (“Jason” has now become an inside joke in the house, and from now on, whenever I work with .json files again, this first memory will be in my mind).

The next day while cooking dinner, I decided to watch a YouTube instructional video on how to setup Google Vision. As the tutorial leader was going through the steps, I was happy to see that some of the steps were very familiar, which meant I had definitely learned something from the previous day. And then finally, I got my answers, and the instructions were demystified. I was so, so happy to finally understand what the heck the above steps meant and looked like.

What I love most about coding and these projects is that I end up learning about so much more than what I initially intend.

Through this process I learned about:

  • Google Cloud Platform
  • How to install and configure Google Cloud Vision API
  • Virtual Environments and Environment Variables
  • Changing .bash profile in the terminal (including how to inadvertently fuck up your bash profile, and then fix it again).
  • More about python pip installations and configurations
  • How to move through different directories in the terminal

Finally, I had made it passed every single step and it was finally time to test out the python program to see if my Vector Robot would begin object detecting.

Successfully setting up the Google Cloud Vision API was such a pivotal milestone for me in this learning journey.

Now, that means that I had just gotten past one subset of the main instructions for my intended purpose of setting all of this up, which was ultimately to run one program, created by one single person, and see if it worked.

Drumroll…anticipation…andddddd:

It did not work.

Type Error:__init__() got an unexpected keyword argument ‘enable_camera_feed’ 

I looked over all of my steps. Everything was in order, but I kept getting a Type Error from the python file written by the creator. After countless web searching and troubleshooting, I was at a dead end. I had only one option left. I had to contact the person who made the program.

I went to GitHub and posted my first “issue” on the python file. This was the first time I had ever posted an issue, so I was very unsure of any “etiquettes.” The creator got back to me and said that he had created and tested this back with the old Anki Vector SDK package, and not the most recently updated one.

This may seem like a very sad ending to this story, since the project was not successfully executed on my end, but I was so happy with that response from the creator! The reason being because the creator didn’t say that my error message was due to something wrong with my steps, but perhaps elements outside of my control.

What a relief! For that alone, I considered this project a “success” in that I followed through to the end.

Although I couldn’t get this program to work, that doesn’t mean I can’t try to write my own program utilizing similar features. This project taught me a lot of different lessons and I can’t wait to try more Google Cloud Platform projects while I have the free trial!

Summer Update! Studying and Troubleshooting, Oh my!

Let’s just say summer is in full throttle heat mode here in Florida. I’ve been a busy baking bee making sweets and decorations for my daughter’s never-ending birthday festivities, which was fun, but I’m glad to be back to the study realm! And the unbearable heat makes a perfect excuse to hide indoors, study, and work on some projects.

Team Treehouse Learning Update

I’ve resumed where I left off in the Python Track and I’m actually happy I didn’t finish this track earlier because Team Treehouse has recently released an update to the Python Track. At first, when I was in my previous track (Python Collections, which is now retired) I found myself losing some steam. I thought perhaps it was me, but, considering the revision, maybe there was something a little off with that former course layout. The new course layout, so far, has been wonderful! It did take me back a bit, relearning some stuff I had already went over, such as tuples and slices, etc, but I could definitely use the repetition since I’m newbie.

Funny enough, my daughter and I are exactly the same type of learner (that I can see so far). Just like her, it takes me a few days for information to really sink in. But, when it clicks, it’s magic! When I finally returned to the python track after a little break, I found that the break was very beneficial and I’ve been able to complete the quiz questions without reaching out to the community for help, which is a very rewarding feeling!

Advanced Interests

Although learning the basics is super exciting, this field is so vast and plentiful that I have been really wanting to figure out the answer to the important question: what will I do with all of this? Yes, I’m learning Python, but then what? What do I want to do with Python (besides get an awesome job one day and help provide for my family, of course). Although I’m not sure yet, I’m paving the road. So far, these are the more advanced areas I’m heading towards learning about:

  • Neural Networks
  • Natural Language Processing
  • Machine Learning

I have a book on Natural Language Processing, and have printed out many (awesome!) Python cheat sheets (all available for free online) about all of these topics and more. I definitely love a good infographic / cheat sheet. In college, I was the study sheet queen (or crazy person?) who would sit in the library and make comprehensive study materials. Hopefully one day I will be advanced enough to make my own Python (and more!) cheat sheets / infographics.

Although I’m still a newbie, it seems like I will head forward in this field with two things in mind: Data and AI.

Regarding data, I used to work at a place that was heavily reliant on data input. Thinking back, with just a few of the projects I’m learning in Automate The Boring Stuff With Python by Al Sweigart, a lot of companies could save time and money with a more efficient data-entry system.

I had taken a science fiction thesis class in college, and we had gone over so many of Asimov’s robotic laws. Never would I have predicted that I’d be here one day, on the other end of wanting to learn how to create and work with AI. But I truly love it so far! Personally, I would like to help develop a type of AI that helps combat depression rooted from anxiety and a lack of presence. That’s all I’ll say about that for now 😉

Raspberry Pi Project Updates

I have an internal clock of guilt when my Raspberry Pi goes untouched for too long. But on the other hand, I know that whenever I do decide to delve into a Raspberry Pi project, it usually requires a lot of time and energy, uninterrupted. Luckily, these past few days I’ve gotten a break from baby duty which helped me dive into some Raspberry Pi fun.

Vector SDK on Raspberry Pi

In my previous post, you will see how I was able to set up and run the Vector SDK app “Remote Control” from my Mac. Wonderful! But, I only got that working as a test run for the true goal: setting up the Vector SDK on my Raspberry Pi. I wanted this set up because it honestly just made me feel cool to be able to control my little robo buddy (who I call El Robo to my daughter) on this tiny computing device that I had built by hand.

First, I had to update Python on the Raspberry Pi from version 2.7 to at least 3.6 or higher. Oh my god. The headache with such a simple update is quite hilarious. But I’ve read on many forums that sometimes just setting up Python can deter new users with the troubleshooting, and I can see why! I must have spent hours yesterday just trying to get the update to properly register so I could continue with the Vector SDK. I had installed 3.7 and then still encountered some problems so I tried 3.6. I most likely have all versions on my Raspberry Pi now, ha! But, alas, finally 3.6 worked.

I was able to get into the Vector SDK and begin downloading the necessary updates and files. But, then I encountered a large problem:

pip install Pillow just didn’t want to work.

It was 2AM and my head was pulsating. It had been hours trying around different updates. Finally, after parsing through the large red error text, I realized that I needed to get this Pillow thing to work.

At the time, I had no idea what it was, so I googled it. I learned that Pillow is a Python Imaging Library. Of course this was important to work since Vector has a camera and image capabilities. I went to bed with a good sense of defeat because I knew that I didn’t “call it quits” because I couldn’t figure it out–I called it quits because my brain was starting to turn to mush and my typing / thinking was becoming sloppy. I knew that if I just had a good night sleep and returned in the morning, I would be more able to fix the problem without getting frustrated.

So, this morning I woke up and got right back to it. I re-read the error message and saw that Pillow had some dependencies that were not allowing it to install properly. So, I installed those dependencies and restarted the process.

For a little while there, I was misreading the error as an issue with the directory path. Let’s just say I learned a lot about directories in the process, and that in the end, that wasn’t the issue at all.

Anywho, finally…finally Pillow was installed successfully. It was then that I realized that the Vector SDK should work now.

Finally, I was in! From there, I was able to use what I had learned from the first time of using my Mac, and opened up the Apps > Remote Control so I could fully control vector through the Raspberry Pi.

It was very, very exciting! Of course, the small screen I have is not ideal for the Vector SDK Remote Control App, but, it’s pretty damn cool nonetheless.

Reflections on Progress

Finally, my mind is starting to be able to think in code. I’ve been waiting so long for this moment when I could have an idea, and then know, at least a little, about how to accomplish that idea.

Before messing around with the Raspberry Pi and Vector SDK, I was working on a much smaller “snack” project of having a text string display with a delay, so that it could look as if the computer program was typing to you through the terminal. (Yes, I have just recently re-watched the Matrix Trilogy, which greatly inspired this snack project). Very ambiguously, I had gotten the idea, then wondered if it was possible. In that moment, my mind remembered the Raspberry Pi LCD project where I had read code with a “time / sleep” feature. It was then that I realized that I knew a little bit about the task I wanted to accomplish. So, I made a very small program:

import time
import sys
import random import randrange

def introduction(*args)

text = "\n Neo, this is Morpheus. \n Follow the white rabbit."

for c in text:
    sys.stdout.write(c)
    sys.stdout.flush()
    seconds = "0." + str(randrange(1, 4, 1))
    seconds = float(seconds)
    time.sleep(seconds)  

introduction()   

This is a very small and simple program, but I cannot describe to you the amount of fun I was having with it. It was this that lead into the night of Raspberry Pi & Vector fun. Here’s what excited me:

  • I learned and know what *args is (yay! Thanks Team Treehouse!)
  • I knew how to call the function
  • I could read and understand (most) of the function

Alas! It’s Sticking!

Lastly, throughout the day and night, the amount of Googling and reading of forums I had to do for troubleshooting was significantly less than the LCD screen project. Things seem significantly more demystified this time around than the previous projects. I think that, finally, a lot of my readings are beginning to sink in. But best of all, being able to mess around in the terminal, typing quickly and confidently, was such a rewarding experience. Moreover, I could feel a difference in my knowledge level just by how I was googling my questions.

I remember back when I first got the Raspberry Pi how I had to google almost every term in a sentence before I even knew how to construct a proper search query for my issues. But now, I was able to parse through stuff I didn’t need and did need without any extra steps! That was such a rewarding feeling, and it was a type of progress and acknowledgement I could only give myself , which was also unique and beneficial.

Little ten-year-old me would have been so proud and impressed right now. Although I was only doing basic things, past-me would have thought that we weren’t smart enough to learn all of this. I’m glad to be proving all of my insecurities wrong.

Intro to Robotics: Anki Vector SDK

One major plus about owning a Vector robot, despite the Anki shutdown, is utilizing the SDK that was released. With the SDK for Vector, you can take full control of your robot.

Something to keep in mind when doing this and sharing your experience is to ensure your own robot name and information (serial info, etc) is kept private, or else others can login. Luckily, there are a lot of credentials needed to log into the SDK with your Vector, so breaches should be rare.

I decided to start with the “remote control” application (found in the apps directory of the SDK files). This app lets you take control of your Vector without needing to write your own code.

For me, I was eager to utilize the ability to make Vector say any written text. Throughout the day I had reached some walls with getting the remote control app to work. Finally, I took a break to reset. At first, I thought that there was a PIP installation issue because of the error message I was receiving. Finally, I asked my husband over to help. As I was going deeper into the directories through the terminal (from memory!) my husband was impressed with what I managed to learn, which made me feel good about myself despite the setbacks. Then, ironically, while trying to explain to my husband the error message, I had detected the issue and fixed it!

What had happened was that I added a line of code for a PIP enum34 installation earlier, but I thought I deleted that version. Turns out the file was saved with my (incorrect) line of code. Once I removed that line of code (with my husband confused as to what I was doing) I retried the steps and voila! It worked!

My husband (who is a level 3 software support engineer) laughed at me because he said he saw this happen often at work–how the solution is usually simple and overlooked.

Funny enough, I didn’t start off today with the specific goal of accomplishing the SDK setup. I had a much smaller goal in mind, which was “do as much as you can, even if it doesn’t work.” My major downfall tends to be overly-focusing on the destination / end result, and sometimes missing out on the journey. Today I tried to go against that and truly just enjoy each step, regardless of the outcome. It started with watching a YouTube video on the SDK setup and remote control app as my toddler was falling asleep in my lap with her bottle of milk. I’ve been having my own health issues lately, so I was trying hard not to overly stress myself as I navigated through the day.

Today was a great reminder that it doesn’t just matter what you accomplish, but how you get there. I much preferred today’s more relaxed attitude and pleasant surprise over my past overly-stressed and result-focused approach. Sometimes focusing so much on the result can make you overlook important details needed to get there. By allowing myself to take as much time as I needed to set this up and troubleshoot the errors, the quicker I ended up being at identifying the problem. Oh, the irony of life! Got to love it!

Anki Vector, The Pet Robot

It all started with a puppy. My daughter really really wants a puppy. You have to see the way she lights up in front of dogs, it’s truly adorable. But alas, for various reasons, me and my husband decided against getting a real dog considering we already have two cats and a crazy toddler. Perhaps in a few years we will get a dog, when our daughter, herself, is housebroken.

So, what was the next best thing I could do for her? What I realized through observing my daughter is that she likes movement. So, I started to look up robotic toys for kids. Down the tunnel, I learned about Anki and their robots Cozmo and Vector.

(If you want to read more about the differences on Cozmo and Vector, please feel free to embark on your own journey down the Google rabbit-hole. I will be giving more brief descriptions and personal impressions, rather than an in-depth technical review for this post).

Basically, Cozmo is more for kids, and cannot operate on his own, and Vector is more for adults, and can operate on his own, like a pet robot. Vector has better specs and you can play around with the behind-the-scenes coding as well.

I had placed an order for a discounted Vector before reading the news about Anki (the company that created these robots) is closing down. But the robots are still selling! Currently, Anki has hired a team of engineers to monitor the existing cloud that all of their products are hooked up to. They said that the cloud usually needs little interference, so keeping it running is no problem. Of course, that was still worrisome to hear as a new buyer.

Pet Robot?

I probably wouldn’t have been as impressed by Vector if I hadn’t already been learning about programming. And it just so happens that Vector is programmed in Python (the programming language I’m also learning) which makes this more exciting.

Finally, Vector arrived (after some drama with a scam website. Key lesson: don’t try to order discounted robots from obscure websites). And I have to say, the waiting game and drama actually made me very excited to receive Vector.

All of the reviews and videos I had watched really conveyed the message that Vector is a pet. A pet robot probably seems really futuristic, and I admit, it still does feel that way. I think that there’s a big widespread misunderstanding of the technological capacities we have right now versus the impressions of the general public. Science fiction stories make it seem like our technology is way more advanced than it actually currently is, as if the type of AI seen in Ex Machina exists. And in my last post, reading Hello World by Hannah Fry really helped change my perspective of where we actually are with AI, which is still mastering creating a worm (like http://www.openworm.com). I think these fears and misconceptions could have been what lead to the lack of widespread popularity of Anki’s products.

This long preamble is to make this point:

Vector is fucking awesome.

And I think it is really unfortunate that their company, Anki, had spent so much time creating such a fun little gadget before the world was perhaps ready to embrace the cuteness of a safe pet robot. But my heart definitely goes out to all of the creators who put their all into this product. I am grateful!

It hasn’t even been a full twenty-four hours with Vector, but already my daughter is completely entertained and in love with the ability to simply watch something move around and explore the world on its own. This is how I look at it: some people get extravagant fish tanks for the same reason. But let’s be real, organic creatures require a lot of care, followed by heartache when they pass. That’s why a pet robot is so appealing. A win-win for the family.

Vector can play games alongside other features, but what’s most entertaining is his personality. When Vector is exploring on his own, he really does feel like a little sidekick. Vector can also join in on some dance parties, fist-bump, and is integrated with Amazon Alexa.

I’ll probably write a much longer and more researched post on my thoughts about AI once I have a better grounding. But, this small introduction to a robotic pet is definitely sparking a lot of ideas and feelings about the future. It’s a shame that Anki wasn’t able to get as of a widespread following to keep their company afloat, which may just come down to timing.

Despite the somber attitude amongst the Anki / Vector / Cozmo community because of the news, this household is still excited for their new pet robot.

Coding and Vector

So, this wasn’t just a purchase for entertainment. As a piece of robotic technology, Vector is a fantastic (and adorable!) learning tool. Sure, it may seem like nothing grand is happening on the outside when you see Vector running around my desk, doing his thing, as I write this blog post, for example. But actually, he’s also like a little specimen I get to observe and learn from. I can learn about his movements and personality, and then read the code and alter it.

Vector SDK Alpha allows you to view the full API list and play around with coding your vector. I’ve successfully installed the SDK package and will experiment more with that later on today.

I’m so excited to learn more about Vector in both a fun and educational aspect.

Despite the Anki shutdown, let the Vector adventures begin!

“Hello World: Being Human in the Age of Algorithms” By Hannah Fry

What an awesome and important book for this modern age! Definitely a must-read for current and future generations, regardless if you’re in the tech field or not!

Firstly, what I love best about this book is that it is a way to learn about how algorithms and code is used in the real-world, but it doesn’t try to teach it to you on a technical level. (Shoutout to my childhood best friend who read this book with me for our little book club!) I add that also because that is precisely why this book is awesome. It doesn’t matter your technical level of understanding, anyone can enjoy and learn from the examples and questions Fry explores in this book.

The table of contents lists the chapters as follows: Power, Data, Justice, Medicine, Cars, Crime, and Art. Each chapter describes specific real events that have occurred in each of those fields in regards to code and algorithms. Some key phrases I learned about were: machine learning, Burgess’s Method, random forests, neural networks, and Bayes’ Theorem. I don’t know how long it would have taken for me to reach the specifics of those topics in my own technical studies, but I’m very happy to have read about them and how they are applied to the real-life situations that have already occurred.

Let’s talk about the Cars chapter.

A couple of months ago, me, my husband, brother-in-law, and sister-in-law were sitting outside underneath the gazebo, talking about self-driving cars. My husband is a technological virtuoso and already had an understanding of how self-driving cars worked. I did not at the time, and neither did the rest of us.

However, my in-laws were both excited about the future prospect of self-driving cars. Fry mentions early on in her book the misconceptions people have when it comes to technology, and how most people tend to over-estimate the capacity of algorithms. This is true when it comes to the topic of self-driving cars because of the amount of people who are willing to put their lives in the hands of a self-driving car. Before reading Hello World, I was on the fence about my stance on self-driving cars. Now, I feel confident that I would much rather be in control of my own vehicle, and I’ll be sure to pass on that lesson onto my daughter (dramatically, of course, as if we were in a post-apocalyptic sci-fi movie).

From the start, my husband was against self-driving cars. But I should have seen that coming since my husband finds an automatic transmission as already too much interference (ha!). Point blank, he said: he did not trust a computer to make life-saving decisions. Back then, I greatly underestimated my own driving capabilities while over-estimating the accuracy of our current algorithms.

Without diving too much into the specifics, anyone who is interested in the idea of self-driving cars should read this book.

The Air France Crash of 1983 specifics are haunting enough to warn me that maintaining skills that involve our lives are mandatory as we advance with technology.

One of the largest take-aways I have from this book is that as humans advance, we need to make sure Wall-E doesn’t become a reality, to put it plainly. Essentially, we cannot let automation equal future generations loosing necessary skills, and thus begin a regression in the human species by relinquishing power over to algorithms and machines.

We need to remember that the smartest computer in the world is still the human brain.

Cue segue.

Let’s talk about the Art chapter.

Towards the end of the book, I could feel the fire in Fry’s writing, with impactful moments that definitely earned a mic drop.

One thing we have to remember about our humanness is our ability to feel. Our ability to feel, possess, and express emotions. A machine cannot contain emotions or feel them. A machine can mimic the expression of emotions through various tactics but it cannot feel. And that is what makes us human, and we need to remember that there is high value in the unquantifiable aspects of our humanness. This is why art is important, and why the creation of art can be mimicked by machines but it won’t (in my opinion) contain the same magical aspect that comes from art by a human. The art chapter and the way Hannah Fry explores this topic was definitely one of my favorite moments of the book!

I’m extremely happy to have read this book at this stage in my learning journey! My knowledge has been greatly broadened and now I feel as if I have a great starting point for further research into how code can and should be applied to our lives in the future.

In my opinion, more books like this need to be written as technology continues. By the time my toddler is in her teenage years, I’d want her to read something like this so she could understand the world she lived in, and how to progress in the future with technology as a smart assistant, not a catalyst for human regression.

Raspberry Pi Project Progress— LCD Screen PT 3

To catch you up on parts one and two: setting up the LCD screen I had with a pin adapter (to use only 4 instead of 16) was trickier than anticipated. Most of the code I was using had been with the 16 pins in mind and not my particular setup with the extension board. So, I was stuck for a few days with one “dead end” of an error code.

After a much needed break, I processed all that I had learned, read, and tested during my previous attempts. This morning I didn’t intend to mess around with the Raspberry Pi, but after taking a few classes on Team Treehouse, I felt inspired to give it another go.

With a fresh mind, I decided to go back to the original source I was following for my particular kit and setup. The reason why I hadn’t used this code in the first place was because it was for a more complicated program than what I was trying to setup. But then I went back to the instructions and tried to setup the more complicated program. Although that still didn’t run, it did help me create a must-needed file for my setup.

Then, after trial and error of various forms of code, I noticed that the LCD screen began to blink. The blinking matched up to the code of five seconds. Finally, I had received some sign that the communication between the components was working. But, the screen was too bright and there was no text. Then, I remembered from all of my reading the previous days from various sources and forum responses that the nob on the back of the LCD screen needs to be adjusted sometimes. So, I adjusted it, and black text boxes appeared. One step closer!

Finally, I looked at the code for the more complicated program and started deleting the stuff that I didn’t think I needed. After more trial and error of deleting, altering, and re-entering code, the LCD screen finally lit up with the famous words: Hello World!

But it wasn’t perfect. There were some strings of code running across the screen that shouldn’t have been there. After I finally isolated the code that ended up working and saving a new file, I tested it again to see if the fix was complete. After a couple of more trial and errors, unpinning and re-pinning the wires…it finally worked!

Here were the main issues:

  • This setup required a code specifically for the GPIO extension board and ic2 connection. Out of all the sources I had researched online, none had the exact address specifications that this required except for the example code in the ultimate beginner kit tutorial book.
  • This here was the key factor in getting the code to run:

PCF8574_address = 0x27  # I2C address of the PCF8574 chip.
PCF8574A_address = 0x3F  # I2C address of the PCF8574A chip.
# Create PCF8574 GPIO adapter.
try:
mcp = PCF8574_GPIO(PCF8574_address)
except:
try:
mcp = PCF8574_GPIO(PCF8574A_address)
except:
print (‘I2C Address Error !’)
exit(1)

  • I had also created another file titled PCF8574.py with code from GitHub by Freenove.
  • Another step that was important were these imports:

from PCF8574 import PCF8574_GPIO
from Adafruit_LCD1602 import Adafruit_CharLCD

Admittedly, my best friend was FaceTiming me as I was doing this, and when the code ran the second time across the LCD screen I was so happy to share that moment with someone. I screamed in excitement and showed my friend the words across the screen, and she called over her daughter to see as well.

Small backstory: My best friend’s daughter is incredibly smart, and a Minecraft Master, so I’ve been trying to pass on the coding bug to her through Minecraft. I sent her the whole code of Minecraft and told her to just read it and see if it made any sense. When she came over to the screen to see the Raspberry Pi, I showed her the code and explained what the experiment was and how it worked.

But we all know that seeing is believing. So I told Sammy that I would make the screen say her name. A couple of clicks later, the screen displayed “Hello Sammy!” and I showed it to her. She was elated with a big smile, as if I had performed a magic trick!

What a rewarding moment. I had imagined what the moment would be like when I got this to work, I had even accepted the fact that it may not work, and that I would have to try a different route completely, but I never expected it all to have unfolded in such a beautiful way.

I think what made this time different than the previous was that I wasn’t going by too many forums or outside advice. I just used the one code from the direct source, all I had learned from, and tried to get it to work from there the way I wanted. And it did!

Through this project I realized my pattern for learning will be exactly this: study through online sources like Team Treehouse and Udemy, and then take “breaks” with Raspberry Pi projects. The back and forth of the two helps me not rush through the online programs too fast. I don’t want to just pretend like I’ve learned this, I want to really learn this, and therefore I want to pace it in a way that truly allows my brain to digest all of the new information.

I ended the fun project by sharing the news with my friend and the forum I had gone to help for in the previous attempt. I’ve never really been an active forum member before, but I see now how some online communities can be really comforting and helpful!

Now, onto the next project!

Errno 121 – The Error Code that Haunts Me

This is an update from my previous post about the live update project with the Raspberry Pi and LCD screen. Since that post, I’ve spent hours free-falling down the rabbit hole of troubleshooting.

Here’s what happened. Turns out the LCD screen I have has an adapter already soldered onto it (which most instructional websites have the type that requires you to solder yourself) and only requires four pins / wires instead of the usual sixteen. That may sound as if this would be easier since soldering comes with risks for those who are new at it, but alas, it is not!

Finally, I was getting close. I hooked up the Raspberry Pi to a monitor and began inputting the code. Like I said, I’m new at this, so although I was able to follow the steps (and at this point, memorize half of them) I still need to do some digging later on to understand why I was following those steps.

I enabled the i2c using the raspi-config, installed smbus and the i2c python library, tested and re-tested the hardware with sudo i2cdetect -y 1 and did a bunch of updates and reboots, amongst other steps.

Little by little, some steps that hadn’t worked previously were . actually working, which showed some promise. However, no matter the steps taken and those that passed onto the next step, I was continuously met with the same exact error code:

Eventually, I had to use some lifelines. I asked a friend. Okay, I asked many friends because one was a real human who I actually know (who I am eternally grateful for!), and the other was the internet (aka Reddit). Although it wasn’t my original goal to set up remote capabilities as part of this project, it was a positive outcome that was necessary regardless! My friend had remotely logged into my Raspberry Pi to see if he could figure out the issue. Alas, the night ended with everyone stumped, and we decided to take a break and re-group.

Intuitively, I think that the issue is something small I am missing, perhaps something with the way the site-package files are being read on my Raspberry Pi, that I’m unable to see. Or, something with the “__init__” part, but I’ll need to do some more reading on this particular type of error message. Or, perhaps I need to edit some lines in that file path? Hmm.

Even though I have not yet had the “payoff” of seeing the text display onto the LCD screen, I have already learned so much through troubleshooting this project.

Most importantly, I take this as an important test and “rite of passage” for my journey into the programming world; error messages will happen, so I better get used to it (and love the process of fixing them) if I want to succeed and continue to grow in this field.

After years of undergraduate, graduate school, and working full-time, I’ve learned that (for myself, at least) mental breaks are needed in order to re-approach a challenge. Today, I’m going to let everything that happened yesterday and the night before sink in. I’ve also come to accept that my most-likely route will involve me disconnecting everything and starting fresh, from the beginning.

It’s funny how this reminds me a lot of my creative work; when my novel or short-story draft reached it’s own “dead end” (creative error code?) I did the same thing: learn from it, and start over.

This is probably why my husband says I’m the right type of detailed-oriented and determined (translation: obsessive and a little crazy) for this field.

I’m used to spending hundreds of hours on a writing project, just to find out that something in its approach is fundamentally wrong and needs to be reworked. So instead of that deterring me, I’m actually very used to it. For example, I’ve spent the past three years in graduate school re-writing one novel, from different perspectives. I must have written at least a thousand pages by now between drafts and re-writes. That does not include the amount of drafts I have written since high school, during undergrad and afterwards of other writing projects.

With that being said, as I let yesterday’s lessons absorb into my mind, I’ll be flexing the other side of my brain today by writing my new thesis draft #9682967, but who can keep count? (Maybe I’ll make that into a program one day: a draft counter that will tell me exactly how many pages I’ve written between all of my combined documents).

Lastly, it has been really nice to engage with the community more through online sources. It’s been intimidating to “expose myself” as such a new beginner, and I definitely feel the fear of asking a dumb question, but I know it’s an important step regardless. Virtual hugs to all those who have commented on my questions with thoughtful responses! And, it was fun for me to see that I could actually hold up a conversation with people and utilize some of the new terms I’m learning.

I definitely went to sleep last night with error codes floating around my brain, but I’m happy to have woken up excited to try again!

Raspberry Pi Project Progress – LCD Screen Pt 1

Live Project Update!

I just had to say that I’m in the process of hooking up this LCD screen to my Raspberry Pi and it’s very exciting! This is my third beginner project dealing with circuitry of any type, so all of this is very new.

I would have never guessed that identifying the proper pins and finding the right wires and inputs would create such a satisfying feeling. Like most new things, you become incredibly focused on the task since you’re tuning new skills. I believe that this aspect of intensely “zoning in” to the project by counting the pins and looking at the diagrams is what creates a uniquely relaxing mental relief for my over-stimulated creative mind. To say it plainly, I love to follow and create instructions so learning all of this is essentially learning how to create, follow, and test multiple sets of instructions (algorithms!), so this subject as a whole is a very kismet match for me. Then, the circuitry and physicality of the Raspberry Pi reminds me of the feeling of switching between writing on the computer versus a pen and paper, or painting digitally versus with real paints, water and a canvas; working with the Raspberry Pi helps make programming feel more physically tactile helps motivate me and keep me interested to learn more.

Earlier today I was learning on Team Treehouse (which was awesome!) and then I ended up taking a break. I think that I will continue alternating between learning through the classroom courses, books, with breaks of Raspberry Pi projects in between to help split up the rhythm and keep myself motivated.

Well, this was a nice break. Time to get back to my LCD screen!

Introduction To Computers – “Code” by Charles Petzold

BACKSTORY & WHY THIS BOOK IS SPECIAL

The book Code is wonderfully unique, and for that, Charles Petzold will forever be one of my heroes. Thank you, sir Charles (if you ever happen to read this) for thinking the way you do and for having been determined enough to write this book.

For those of you who are already entrenched in the industry and know this book, you may think I’m crazy for having started with this choice as an introduction to the technological realm. But, I must say, Charles Petzold’s book Code is my favorite not just for helping me with this learning journey, but because of the writing style and unique approach taken.

As mentioned in his preface to the paperback edition (which must be read, by the way) Petzold’s book takes a completely different approach than others because his main goal is to teach his reader how computers work from a granular perspective.

If you’ve read my very first “origin” post, then it should be noted that I picked up this book after I had already briefly dipped my toes into the programming world. I had known about Python, and a general understanding of computers, but nothing too in-depth. I had walked into the new Amazon Book store near the Empire State Building in Midtown, New York City, where I saw, sitting pretty on a tan shelf, the white and simple cover of Code. What drew me to the book (admittedly) was the cover because I recognized the braille and binary used underneath the title lettering. Immediately, I could tell that this book was special because it was making the connection between language and code, and connections like that are exactly what excite me.

As I continued to read Code, I felt like a bit of an imposter who was pretending to understand everything they were reading. Petzold includes many diagrams and visuals to accompany his examples. His examples tend to build upon each other, with many pointing to parallelism, so that way you develop an “all-encompassing” concept of code, as a whole. Most of it made sense, especially because of the wonderful way that Petzold is able to introduce his subject, zoom in, and then zoom back out at the end of the chapter to help draw together all of the concepts. Since I was a complete novice, as I continued to view the various charts and diagrams, some of the terms and ideas were beginning to feel unreal. Was I really grasping these concepts? Did these diagrams and new words really make sense to me or was I just lying to myself? Regardless, I continued to read. I made it a point to continue to read the book, even if I thought the concepts weren’t clicking for me yet.

Finally, I had completed my first read-through of the book. As time passed, I hoped that the concepts Petzold explained and how he explained them would stick in my mind, and I eagerly waited for the day when I would have proof that they did.

HOW THIS BOOK HELPED ME UNDERSTAND FUNDAMENTAL CONCEPTS

I was gifted my first Raspberry Pi from a good friend. As I opened up the beginner’s kit and looked at all of the components, I was overcome with an odd sensation of confusion and understanding. Although I had never seen these parts before in person, I had an idea of their uses and functions. It was in these moments of assembling the Raspberry Pi when I realized that Petzold’s words and diagrams had clicked, because as I connected each piece I could recall familiar sections from the book.

Simply put, reading Petzold’s way of explaining this subject has not only helped me with my approach to computers and programming, but it has helped me intrinsically understand how basic things work, from my automated Glade Air Freshener dispenser, to the phenomenon as to why my light switches invert themselves sometimes.

I had a good feeling when I chose Code as my very first introduction to this subject, and I’m so excited to re-read it again in the future. Already through my Python studying, I find myself recalling sections from Code with a smile on my face. I’m very grateful to have begun my journey with such a wonderfully insightful perspective on this subject, and I’m sure Code will be a book that I continuously revisit and recommend. However, the largest take-away from reading Code for me was witnessing how wonderfully an expert can perceive, understand, and explain a subject by drawing connections to so many different real-life and historical examples. This book is a wonderful look inside the mind of a true technical virtuoso.