LED Stock Ticker With Adafruit IO Functionality
by gammam in Circuits > Gadgets
7 Views, 0 Favorites, 0 Comments
LED Stock Ticker With Adafruit IO Functionality

I decided to build a stock ticker due to my strong interest in the stock market and a will to have cooler desk trinkets than my friends. I learned how to code alongside my early interest in the equities markets as I started making simple predictive algorithms in my first years of coding. Lately, I've been branching out into other forms of coding like machine learning for image recognition, and circuitpython through school. Therefore, this project was a way for me to get back to my roots a little bit and combine my new skills with my old ones. However, I will warn all who attempt this build that the MatrixPortal M4 is a deceptively tricky board to work with. It claims to have wifi capabilities, but there is very little documentation on how to use it. Many imported libraries simply don't work on it, and I had to buy three of them over the course of two weeks because the code.py files kept getting corrupted. I am, strangely, glad that I overcame these challenges because I learned a TON in the process of working around its faults.
You'll notice that there is a Raspberry Pi Pico W in this build. Through my tribulations, I figured out that instead of using the MatrixPortal for wifi and connecting to Adafruit IO, I could use the Pico, which has far more documentation and I have experience with it in class. To connect them, I used the UART protocol so that the MatrixPortal could interact with the Pico and display the tickers on the screen.
Supplies

Required
- MatrixPortal M4 >:(
- Breadboard
- Raspberry Pi Pico :)
- 64x32 LED Matrix - With Included Power Cable
- USB Data Cable
- Three Breadboard Jumper Wires
- Laser Cutter With - 1/8 Baltic Birch
Optional
- Portable Charger
- Patience
Set Up Boards
Both the MatrixPortal and the Pico will be run on CircuitPython accessed through the .uf2 file on the CircuitPython website, ensuring to use the 9.x.x file. I also used Circup to install libraries earlier, but in either case, make sure that you have the Adafruit-Circuitpython-Bundle downloaded. Next, to make things easier, I used jumper wires for the wiring:
- Pico RX -> M4 TX
- Pico TX -> M4 RX
- Pico GND -> M4 GND
You can solder the connections if you'd like but because I am reusing the M4 for a different project, I just curled the jumper wires around the connection points on the M4.
Next, you want to connect the M4 to the LED matrix, which plugs in to the VCC GND connections on the back, and the M4 gets pushed into the HUB75-D port. Next connect the VCC wire to the 5V on the M4 and GND goes to GND; they need to be screwed on with the screws that came with the M4.
Set Up Adafruit IO, WiFi, and AlphaVantage
.png)
.png)
Setting up Adafruit IO requires a free account, once you have one you want to create a dashboard. Once the dashboard is created, go to the gear icon and click "create new block." You want to add 5 momentary buttons under a new feed called move_feed. You want the press values to be 1, 2, 3, 4, and 5 with no release values. Respectively, they should be named Change (%), Price ($), Port. Chg. (%), Port. Stdev, and Volume. You also need to make sure that your Pico is registered for WiFi. AlphaVantage has a free API where we will get stock information.
Adding the Code
My code is attached below with the matrixportal code going on the M4 and the pico code on the Pico, both on code.py files. I know it's an odd setup but I think it can be resourceful if done in a way to maximize space. You'll notice the UART connections, and os.getenv() which accesses your settings.toml, which should look like this:
#settings.toml
CIRCUITPY_WIFI_SSID = "YourSSID"
CIRCUITPY_WIFI_PASSWORD = "YourPassword"
ADAFRUIT_AIO_USERNAME = "YourAIOusername"
ADAFRUIT_AIO_KEY = "YourAIOkey"
BROKER = "io.adafruit.com"
PORT = 1883
ALPHAVANTAGE_API_KEY = "YourAlphaVantageApiKey"
You'll also notice some try blocks due to the nature of how APIs can be buggy which is a problem that I've noticed is worse with small boards like the ones we're using. It's very easy to flip an error with these kinds of things so it's better to be safe than sorry. I would also recommend not changing anything on the MatrixPortal code due to the file corruption problems.
Cut and Final Assembly

My box cutout is attached. I made it on MakerCase and threw it into Adobe Illustrator to at the hole at the side. The hole is there because the MatrixPortal sticks out of the side a bit. I made the hole pretty large to make it easier to unplug. I used hot glue to seal it, and I used some tape to make sure the LED screen was secure.
Downloads
$Stocks$
In the code is a list of stocks with the variable name mag7 standing for the magnificent seven stocks that have been performing rather well for the past few years. I encourage you to add your own portfolio to the project so you can see the ticker tape rolling. Use the IO dashboard to see prices, volume, portfolio change, and the daily standard deviation of your returns. Also feel free to add more functionality to the dashboard. Despite the setbacks, this really has been an enjoyable project and I'm glad that I had the opportunity to do it. Sometimes the best way to learn something is breaking down the problem one obstacle or error at a time until you're happy with what you've made.