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. 

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...