Monday, September 2, 2024

Baofeng UV5R Simplex Repeater (VOX)

Let's start off with the list of it items that we'll need:


 Materials:

  • Computer:
    • Laptop/Desktop Running Windows
  • Radio Piece:
    • 1X Baofeng UV5R 
      • Technically any radio that will do VOX
    • 1X 2.5mm-to-3.5mm Audio Cable ( or adapter)
      • 3ft is good
    • 1X 3.5mm Audio Cable
      • 3ft is good
    • 1X Ground Loop Isolator
      • https://www.amazon.com/Packs-Ground-Isolator-Stereo-System/dp/B0B2JSN8NR/ref=asc_df_B0B2JSN8NR/
      • Mine is labeled 'Jabinco' But these will do. 
    • 1X USB Sound Card
      • https://www.amazon.com/gp/aw/d/B00IRVQ0F8
  • Software:
    • http://f6dqm.free.fr/soft/simplex/en/simplex.htm

Steps:

1- Configure VOX on UV5R ( I have it on Level2)

2- Install The Simplex Software. 
Familiarize yourself with it. While there are many options we'll only be using the repeater function. 

3- Plug in your USB Sound card and test it. 
I'm sure you have some headphones and microphones lying around. 

4- Plug stuff in.
2.5mm Baofeng Plug --> 2.5 to 3.5 MM Coupler --> Microphone In on USB Sound Card
3.5mm Baofeng Plug --> Ground Loop Isolator--> Speaker Connection on USB Sound Card

Troubleshooting:
- Make sure that the audio output and input are correct
- Try out different volume settings on both your computer and the Baofeng radio
-- One thing that I decided to do was to mark the location of the volume sweet spot. 
- Hit Auto On. 

Wednesday, August 28, 2024

Web Scraping With Python ( To display on LED Matrix)

 I had the opportunity to (semi) work with LED matrices at my place of employment, which led me to tackle this project here. I have set up this page here: https://techtucson.com/learning/scrape which we'll use as a real-world example. 

  • Download the page as an HTML file and save it to your computer as scrape.htm.
Our first task is to separate the first ROW and display how many spots are available. 


///
import pandas as pd

url = 'file:///C:/Users/mariouribe/Downloads/scrape.htm'
tables = pd.read_html(url)
df = tables[0]
first = (str(df.loc[0, 'Spots Available']))
new_string = first.replace("spots available.", " ")
new_string2 = new_string.replace("/", " ")
firstnumber, secondnumber = new_string2.split()
subtract = int(secondnumber) - int(firstnumber)
print(subtract,  "Spots Available")
///

Great , we have a working POC, but there's only one problem. The Microcontroller are not as powerful as my machine. While they have access to the internet are running MicroPython which means I won't have access to Pandas or better yet BeautifulSoup. I'll need to use built in libraries as much as possible. Back to the drawing board. 

///
import requests
import re

url = 'file:///C:/Users/mariouribe/Downloads/scrape.htm'
response = requests.get(url)
html = response.text

pattern = r'<td>(.*?)</td>'
regex = re.compile(pattern)
results = regex.findall(html, re.IGNORECASE | re.DOTALL)
garage = results[0]
numbers = results[1]

numbers_new = numbers.replace("spots available.", " ")
print(numbers_new)
numbers_new2 = numbers_new.replace("/", " ")
print(numbers_new2)
firstnumber, secondnumber, thirdthing = numbers_new2.split()
print(firstnumber ,  "Spots Available at ", garage)
\\\

So I got this working with the requests and regularExpressions library. But know there are a couple of more issues, some of the functions of the re library don't seem to exist in MicroPython :( , and I ran out of space while getting the reponse.text output. 

That's when I reached out to the developer and asked for a handout. An API was built where I can call a specific garage and get 20 lines of text which I can now parse without issues. 

More to Come Soon. 

Saturday, August 17, 2024

Raspberry Pi Pico RP2040-ETH

I've always been interested in Arduinos, Microcontrollers, and SOCs. I recently went on AliExpress, purchased some new devices, and rounded up the things I had previously purchased. This article will focus on the WaveShare RP2040-ETH (https://www.waveshare.com/wiki/RP2040-ETH) which is a "RP2040-ETH is a mini RP2040-ETH development board, which integrates TCP/IP protocol stack for network communication." 

I found this Github Repo: https://raw.githubusercontent.com/nichokap/RP2040-ETH which I will use as a starting point, and grow from there. Let's get started with setting up the device, I won't bore you with instructions and firmware that is used as you can take a look at the WaveShare site and the above Github for that portion. 

1:
Now that everything is set up, let's do something with the board. Let's go into Thonny and start with the "Hello World" right of passage. 


2:
Well, that was fun, can we make the board do something? We can use an RGB LED on the board. 


from machine import Pin
from neopixel import NeoPixel


#Configure the built-in WS2812 LED pins of RP2040-ETH and set the number of LEDs to 1
strip = NeoPixel(Pin(25), 1)

#Set the color of the first and only LED
strip[0] = (0,150,0) # color codes in GRB (Green=0, Red=150, Blue=0)

#command to write the color to the LED
strip.write()

This code is from nichokap mentioned above, we see it's importing the PIN and NeoPixel (modules or libraries) items. The 'strip' variable is defined using pin 25 which is the LED, and the notes in the code mention that we are letting NeoPixel know it's only 1 LED. strip[0] I believe is referencing the 1st LED as index starts at 0. The first time you run the code, you'll see the LED turn red. Now try to change the Number combinations, (150,150,150) will give you a white LED.

But I didn't buy this because it has 1 LED, I bought it because it had a Network Port, and I can use MicroPython. That's where I think I chewed more than I could swallow. Before I go off on a tangent, let's move on to the next sample code. 

3:

Monday, August 12, 2024

Meshtastic LORA

In early 2022, I ordered three (3) Lilygo LoRa32 V2.1 1.6.1 modules. Then I flashed them with Meshtastic sent messages between the nodes and called it a day. Fast forward a couple of years, and the local community around Meshtastic has grown. While this post is currently a placeholder here are some of my current projects around Lora:

  • https://techtucson.com/mesh
  • https://github.com/TechTucson/TC2-BBS-mesh
    • I have really enjoyed working on this project and I may just turn this into it's own post. 

Local sites and resources:

  • https://meshtucson.systm32.xyz/
    • Tucson Meshtastic Site
    • Discord
      • https://discord.com/invite/ruAQEVpUV4
  • http://azmsh.com/
    • Redirects to Discord Invite
  • 32Mesh.net
    • Saw this driving around 
Keep Tuned for More. 

Saturday, August 10, 2024

AWS Certified AI Practitioner

When I heard that AWS was about to release their "Certified AI Practitioner" Exam, I told myself I was going to jump on the bandwagon. There is a lot of hype around AI, Machine Learning, Foundation Mdels, LLM's. It's difficult to view through the smoke or discern who is peddling snake oil, what is easy to tell is that AI continues to make a deep impact in the Information Technology realm. Below are my 'personal' notes while studying for the Exam.  
  •  What is GenAI
  • Amazon Bedrock
    • Foundation Models
    • Foundation Model Evaluation
    • Retrieval Augmented Generation(RAG) & Knowledge Base
    • GardRails
    • AI Stylist
  • Prompt Engineering
    • What is It
    • Performance Optimization
    • Techniques
  • Amazon Q
    • Business
    • Apps
    • Developer
      • Kinda like Co-Pilot.
  • AI and Machine Learning
    • AI, ML, Depp Learning and GenAI
    • Training Data
    • Supervised Learning
      • Tagged Input
    • Unsupervised Learning
      • Mix of Tagged and Untagged, mostly Untagged
    • Reinforcement Learning
      • Kinda like a pet, rewards good behavior, reinforces good behavior
    • Model Fit, Bias, and Variance
    • Inferencing
      • Infer , things like in DB .. when you don't have all of the access but you can infer data points. 
    • Phases of a Project
  • Managed AWS Services
    • Comprehend
      • Comprehends the written text, Natural Language Processing Exracts insight about the contents of documents. 
    • Translate
      • Translate from languages. 
    • Transcribe
      • Speech to Text
    • Polly
      • Text to Speech
    • Rekognition
      • Recognize things in Images and Video. 
    • Forecast
    • Lex 
      • Can make Bots with this. 
        • Connect
          • This is a Call Center type of service where you can have agents take calls, you can connect this to services like Lex and Polly. 
    • Personalize
    • Textract
      • Extract Text from documents
    • Kendra
      • Can take documents and data to create an enterprise search engine.
    • Mechanical Turk
      • This service connects real humans to do tasks for training models or double-checking AI work. 
    • Augmented AI
      • Double Check the work of AI 
    • DeepRacer
      • You actually race a car with a reinforcement model, you get to train your model to see what is faster at learning/getting past the finish line. 
    • Comprehend Medical
      • Transcribe Medical
    • Hardware For AI
      • Tranium
      • Other Chip
  • SageMaker
    • Complete solution for ML, can train, a model , tailor it. 

Wednesday, February 7, 2024

Setup PrivateGPT on a Fresh Ubuntu 22.04



TLDR; We'll set up PrivateGPT on a brand new Ubuntu 22.04 Install. 

I want to preface and warn you, that I am not a savvy user, much less an expert in Artificial Intelligence (AI) or Large Language Models ( LLMs). I am pretty sure I am going to say/type some wrong things :). 

I warned you, here's my write-up:

With all of the hype around AI and ChatGPT, I figured I'd join the bandwagon. A co-worker of sorts pointed out an interesting Github project 'PrivateGPT' that he has been using. His work is private in nature and while he could benefit from the advantages that a toolset like ChatGPT brings it is not feasible/permissible/frowned upon to give OpenAI or any other company the data you are working with( which is usually your clients' data.

That's where PrivateGPT comes to the rescue. The GitHub Repo "PrivateGPT is a production-ready AI project that allows you to ask questions about your documents using the power of Large Language Models (LLMs), even in scenarios without an Internet connection. 100% private, no data leaves your execution environment at any point." Please visit and support the repo located here: https://github.com/imartinez/privateGPT. The readme mentions that for the latest info, we should visit https://docs.privategpt.dev/.

What are my motivations? 
  • I briefly tried to set it up and failed, I gave up. Now I am back and forcing myself to get it working. 
  • AI is here to stay and what better way to learn than to play around with it. 
  • You never know if your business might be able to use it. 
Use Cases:

  • Well, I'll leave that up to your imagination. Think of PrivateGPT as a ChatGPT alternative that you can feed your documents( DOCS, TXT, PDF) and interact with them, 
    • We'll go over some test scenarios. 
We'll be using the installation instructions here: https://docs.privategpt.dev/installation. If the instructions are there, why do you need to read this? Because I failed once, I'll probably fail again as I am writing this as I go through the steps. I failed so you can learn from my mistakes, the idea is to give you a better starting point. With all of that being said let's get into the installation.

  • We'll start with a VM with a fresh install of Ubuntu 22.04. I had the Desktop Edition handy which will do the job and allow us to run a browser within the machine. 
    • I won't bore you with screenshots of this process. 
    • Make sure you update and upgrade your box. 
    • Take Snapshot before we begin, that way you can revert back to a clean slate.
  • I ran into some issues with dependencies, let's get these out of the way before we get started:
    • sudo apt install git curl gcc g++ pkg-config
    • sudo apt install build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev
      libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
  • Let's create a directory, then Clone the Repo
    • mkdir /home/MYUSER/PrivateGPT
      • cd /home/MYUSER/PrivateGPT
    • git clone https://github.com/imartinez/privateGPT 
Install pyenv and Python 3.11
  • Now we have to install Python 3.11 using a Python version manager.
    • We'll install pyenv
    • Let's use this writeup: https://medium.com/@therazmatrix/how-to-install-and-use-pyenv-in-ubuntu-22-04-fa7c28ca0b67
      • curl https://pyenv.run | bash
        • Then I added this to my /home/MYUSER/.bashrc file
        • # Pyenv
          export PYENV_ROOT="$HOME/.pyenv"
          command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
          eval "$(pyenv init -)"
          eval "$(pyenv virtualenv-init -)"
      • You'll need to restart the shell.( just close it and re-open it)
      • pyenv install 3.11
        • It worked :) 
  • Now Install Poetry
    • https://python-poetry.org/docs/#installing-with-the-official-installer
      • curl -sSL https://install.python-poetry.org | python3 -
      • That worked fine the first time, were on a roll. 
    • So I did not put the PATH for poetry in my .bashrc, because reasons but I can run it calling /home/MYUSER/.local/bin/poetry 
  • We need to create a virtual environment for our project to use the 3.11.7 Python install
  • in /home/MYUSER
    •  pyenv virtualenv 3.11.7 privategpt
  • then go to /home/MYUSER/privateGPT
    • pyenv local privategpt
    • pip install llama-cpp-python
    • poetry install --with ui
      • This will take a while
    • poetry install --with local
      • This will take another while
    • poetry run python scripts/setup
  • Finally
    • /home/MYUSER/.local/bin/poetry run python -m private_gpt
    • You'll see a message similar to:
    • You can now browse to https://127.0.0.1:8001
      • Upload a File, and ask it some questions. 

Friday, February 2, 2024

DNS: Why Can't I have a TXT Record ( Or any other record) alongside my CNAME record?

TLDR; Because that's how DNS works. https://www.ietf.org/rfc/rfc1912.txt


I've run across this issue various times in the last...we'll I won't tell you how long, but it's been a long time. Every time that I see this issue pop up I scramble and learn the same thing, in hopes that the lessons learned will stick I have decided to create a blog post. 

We are all accustomed to nice domain names (i.e. google.com, facebook.com), and as an end-user the backend inner workings are abstracted. What we do know is when I type in my domain on the browser, some magic happens. While I don't understand the complete magic I will do my best to explain why you can't have any other record alongside a CNAME record. 

What's a CNAME record, that's true let's take a step back. Let's take store.mydomain.com as an example, a DNS server is responsible for telling browsers how to traverse the internet and locate the server that is hosting your desired store. Other types of services that have dedicated records are Mail (email) servers they get their own MX record. There are various other records in the DNS scheme, we won't go through all of them but I've selected a sample to go over:


  • A Record
    • This record points store.mysite.com to an IP Address 5.5.5.5, this means that all traffic destined to your store will get forwarded to the IP address. 
  • TXT Record
    • Think of this as a text file that you can use to confirm ownership or management of a domain. This file is readable by the internet, in essence, if you can write to this file we can construe that you own the domain. 
  • CNAME Record
    • This stands for Canonical Name, the easiest way to think of this is an alias or a nickname. www.store.mysite.com can be a nickname for store.mysite.com. But let's take it a step further store.mysite.com can be a nickname to store.BIGCompany.server.hosted.com. That big company server can be Google, AWS, Oracle, or any company offering you a hosted service.
       
That's all great but why use CNAME vs A records if they both point to the same place? As an administrator, I can change records for mydomain.com at will without waiting for anyone else, on the flip side the administrators for the BIGComapny can update their records whenever they feel like it. In the A record above let's say that 5.5.5.5 needs to be updated to 7.7.7.7, if CNAMES were in use that change would be transparent to mydomain.com. Since we are using A records BIGComapny needs to let MyDomain.com know of the change and plan accordingly. For small mom-and-pop shops, it would be fine to coordinate and schedule time, but when dealing with thousands and possibly millions of domains and/or DNS Records it does not scale well. 

I figure giving a rundown on various types of records and why they are used is important to lay down the foundation. Don't get upset, but the reason you can't have CNAME records mixed with any others is that you can't :). DNS was built with this constraint in mind, why? That goes beyond the scope of this article. Taking an excerpt from https://www.ietf.org/rfc/rfc1912.txt, section 2.4 states "A CNAME record is not allowed to coexist with any other data.". 

Baofeng UV5R Simplex Repeater (VOX)

Let's start off with the list of it items that we'll need:  Materials: Computer: Laptop/Desktop Running Windows Radio Piece: 1X Baof...