Preparing my Raspberry Pi
Tags: raspberrypi
Published: 2019-08-12 09:45:11

---
title: Preparing my Raspberry Pi
published: true
series: Building a chatbot with the RaMP stack (RaspberryPi, MySQL, Python)
cover_image: https://thepracticaldev.s3.amazonaws.com/i/idk8wg8wkbhmrviqe1e8.JPG
description: RaspberryPi, MySQL, Python chatbot
tags: RaspberryPi
---
What is a RaMP stack, you might ask? It's my parody of the LAMP stack, where RaMP = RaspberryPi, MySQL, Python.

Why a RaMP stack? Because I am looking for a <u>low-cost, low-space, low-weight</u> alternative for my personal laptop, and because I want to keep the bot experiments completely separate from the stuff I have on either my work laptop or my personal laptop, and because, at some point of time, I dream of building my own Alexa-like voice bot...Also because I know basic Python and can pick up SQL.

Here's a picture to show you how tiny a barebones RaspberryPi can be. <img src = "https://thepracticaldev.s3.amazonaws.com/i/idk8wg8wkbhmrviqe1e8.JPG"/>

These are my tentative steps:
<ol>
<li>Set up my RaspberryPi.</li>
<li>Design and create the databases.</li>
<li>Design and create the bot app.</li>
</ol>

I am neither a geek nor a coder; this journey will not be easy. This post is the first of a series where I share my learning, failures, and successes with you all. In these posts, I plan to focus more on the design considerations (the WHYs)  of the chatbot rather than the code aspects (the HOWs). 

This post is about making a RaspberryPi ready for my experiments.

A RaspberryPi is just a CPU (a motherboard). To work with it, one needs a power source (a power cable), an input device (keyboard), and an output device (display monitor? TV?). One also needs to load the operating system on to the CPU, so one needs an external storage device (a microSD card) that contains the OS.

I bought a <a href = "https://www.amazon.in/gp/product/B07C6SN8PL/ref=ppx_yo_dt_b_asin_title_o09_s00">starter kit</a>, followed a YouTube video to guide me on how to put the RaspberryPi into its official case, and then looked around to plug stuff into the ports and get started.

Rookie mistake.

The starter kit did not have a VGA to HDMI adapter (and my monitors don't have HDMI ports, only VGA).

Starter kits such as the one I bought are well-meaning but can contain stuff I don't need (and not contain stuff I need). Googling tells me it's cheaper to go for combo-boxes or starter kits than buying individual components, but I disagree. The very minimum things that I needed were these: the motherboard, a power source, and a microSD card loaded with the Raspbian OS. Had I bought <i>just</i> these, and a VGA-to-HDMI connector, I would've saved about eight hundred rupees.


<blockquote>So, here's a buying guide for you (I'm assuming you already have a monitor, a USB keyboard, and a USB mouse).
<ol>
<li>Buy these 2 items: RaspberryPi 3B+ motherboard and a 2.4Amp power adapter with microUSB plug. I bought model 3 B+; there's a model 4 out too if you want that.</li>
<li>If you already have a spare microSD card that you can dedicate to your RaspberryPi, go to the next step. If not, buy one, preferably one pre-loaded with the Raspbian OS. Or, you can load the card with the Raspbian OS from <a href = "https://www.raspberrypi.org/downloads/raspbian/">raspberrypi.org</a>.</li>
<li>See what port your TV or monitor has, and buy either a VGA-to-HDMI connector or an HDMI-to-HDMI connector (RaspberryPi has an HDMI port).</li>
</ol></blockquote>

I bought the correct display connector and plugged in the keyboard, mouse, and display. Then, I looked around for a port to plug in the microSD card.

Another rookie mistake. 

The microSD port is on the reverse side of the motherboard; to get to it, one needs to turn the motherboard over. <img src = "https://thepracticaldev.s3.amazonaws.com/i/fqwxyk7q36ys9y8pr5xw.jpg"/>
Which means, I had to unplug all of what I had earlier plugged in (because, I was scared of snagging one of those pins with a wire or something).

<blockquote>So, here's the correct order of plugging the components in:
<ol>
<li>Turn the motherboard over and plug in the microSD card very slowly into the slot.</li>
<li>Plug the keyboard and the mouse into USB ports.</li>
<li>Connect the display to the HDMI port.</li>
<li>If you're going to use wired internet, plug the LAN cable into the ethernet port (I was going to use WiFi).</li>
<li>Plug the power adapter into the microUSB port.</li>
<li>Switch the display on. Then, switch the power adapter on (googling told me the power adapter should be plugged in last and switched on last).</li>
</ol>
</blockquote>

And voila! My tiny nano micro computer blinked red and started up. On the screen, I selected the Raspbian OS, clicked <b>Install</b>, followed the onscreen instructions, and then waited for the installation to be over (it took almost 15 minutes).

Googling also told me to update the packages after they're installed, so after the installation was over, I ran the following commands:
<code>sudo apt-get update</code>, which took about 10 minutes to complete.
<code>sudo apt-get upgrade</code>, which took about 15 minutes to complete.

Looks like I'm done setting up the computer. Next post, I'll talk about the chatbot back-end (which will be a MySQL database).  

<hr/>
Meanwhile, since this is supposed to be my ultra-portable computer, I'll buy it an LCD touchscreen display.

Also, since the RaspberryPi official case cuts off all access to the GPIO connector pins, I'll buy it a case that keeps the pins accessible. The pins are needed to plug the LCD display in, and also for all of the IoT stuff (assuming I go that way later).

And, since I don't like the idea of having to turn the motherboard over every time I need to use a microSD card, I'll also buy it a USB microSD card reader.
<hr/>