PicoDVI Adafruit IO Feed Dashboard (2024)

Code the Dashboard

Save Subscribe

New Subscription

Please sign in to subscribe to this guide.

You will be redirected back to this guide once you sign in, and can then subscribe to this guide.

The Pico W has a relatively small amount of memory and DVI output and WiFi need a lot of it. As a result, this project is coded up using Arduino. You'll need to install the necessary libraries and add your WiFi and Adafruit IO credentials to the config.h file before uploading the code to your Pico W with the Arduino IDE.

Install the Libraries

You can install the libraries for this project using the Library Manager in the Arduino IDE.

Click the Manage Libraries... menu item, search for Adafruit PicoDVI, and select the PicoDVI - Adafruit Fork library:

If asked about dependencies, click "Install all".

Then install the Adafruit IO Arduino library. Click the Manage Libraries... menu item again, search for Adafruit IO, and select the Adafruit IO Arduino library:

If asked about dependencies, click "Install all".

Code Prep

The code consists of a main .ino program file and two header files. config.h configures your WiFi and Adafruit IO connection. sprites.h stores the graphics for the project. You'll need all three of these files to properly compile and run the project. These files are available in the .ZIP folder below or on GitHub.

PicoW_DVI_AIO_Display.zip

Download File

Copy Code

// SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries//// SPDX-License-Identifier: MIT/************************** Configuration ***********************************/// edit the config.h tab and enter your Adafruit IO credentials// and any additional configuration needed for WiFi, cellular,// or ethernet clients.#include "config.h"#include "sprites.h"#include <PicoDVI.h> // Core display & graphics library#include <Fonts/FreeSansBold18pt7b.h> // A custom font#include <Fonts/FreeSans9pt7b.h> // A custom font// put your four feed names here!AdafruitIO_Feed *temp = io.feed("temperature-feed");AdafruitIO_Feed *humid = io.feed("humidity-feed");AdafruitIO_Feed *bat = io.feed("battery-feed");AdafruitIO_Feed *aqi = io.feed("aqi-feed");#define IO_LOOP_DELAY 5000unsigned long lastUpdate = 0;float temp_data;float humid_data;int bat_data;int aqi_data;struct outline { int16_t x, y; // Top-left corner};outline greenOutline = {159, 35};outline yellowOutline = {204, 35};outline redOutline = {250, 35};DVIGFX8 display(DVI_RES_320x240p60, false, adafruit_dvibell_cfg);void setup() { // start the serial connection Serial.begin(115200); // wait for serial monitor to open //while ( !Serial ) delay(10); Serial.print("Connecting to Adafruit IO"); // start connection to io.adafruit.com io.connect(); // set up a message handler for the count feed. // the handleMessage function (defined below) // will be called whenever a message is // received from adafruit io. temp->onMessage(tempMessage); humid->onMessage(humidMessage); bat->onMessage(batMessage); aqi->onMessage(aqiMessage); // wait for a connection while(io.status() < AIO_CONNECTED) { Serial.print("."); delay(500); } // we are connected Serial.println(); Serial.println(io.statusText()); // Because Adafruit IO doesn't support the MQTT retain flag, we can use the // get() function to ask IO to resend the last value for this feed to just // this MQTT client after the io client is connected. temp->get(); humid->get(); bat->get(); aqi->get(); Serial.println("starting picodvi.."); if (!display.begin()) { // Blink LED if insufficient RAM pinMode(LED_BUILTIN, OUTPUT); for (;;) digitalWrite(LED_BUILTIN, (millis() / 500) & 1); } Serial.println("picodvi good to go"); // Set up color palette display.setColor(0, 0x0000); // black display.setColor(1, 0x057D); // blue display.setColor(2, 0xB77F); // light blue display.setColor(3, 0xE8E4); // red display.setColor(4, 0x3DA9); // green display.setColor(5, 0xFF80); // yellow display.setColor(6, 0xFFFF); // white }void loop() { // io.run(); is required for all sketches. // it should always be present at the top of your loop // function. it keeps the client connected to // io.adafruit.com, and processes any incoming data. io.run(); if (millis() > (lastUpdate + IO_LOOP_DELAY)) { display.fillScreen(0); display.drawBitmap(38, 35, airBitmap, airWidth, airHeight, 2); display.drawBitmap(47, 132, tempBitmap, tempWidth, tempHeight, 3); display.drawBitmap(145, 132, waterBitmap, waterWidth, waterHeight, 1); display.drawBitmap(248, 132, batBitmap, batWidth, batHeight, 6); drawBatterySquare(bat_data); displayAQI(aqi_data); display.setFont(&FreeSansBold18pt7b); display.setTextColor(6); display.setCursor(38 + airWidth + 15, 38 + airHeight - 10); display.println(aqi_data); display.setFont(&FreeSans9pt7b); display.setCursor(47 - 9, 130 + tempHeight + 25); display.print(temp_data, 2); display.println(" F"); display.setCursor(145 - 9, 130 + tempHeight + 25); display.print(humid_data, 2); display.println("%"); display.setCursor(248 - 5, 130 + tempHeight + 25); display.print(bat_data); display.println("%"); // store the current time lastUpdate = millis(); }}void humidMessage(AdafruitIO_Data *data) { //Serial.print("received <- "); Serial.println(data->value()); String h = data->value(); humid_data = h.toFloat();}void tempMessage(AdafruitIO_Data *data) { //Serial.print("received <- "); Serial.println(data->value()); String d = data->value(); temp_data = d.toFloat();}void batMessage(AdafruitIO_Data *data) { //Serial.print("received <- "); Serial.println(data->value()); String b = data->value(); bat_data = b.toInt();}void aqiMessage(AdafruitIO_Data *data) { //Serial.print("received <- "); Serial.println(data->value()); String a = data->value(); aqi_data = a.toInt();}void displayAQI(int data) { display.fillRoundRect(164, 40, 30, 30, 4, 4); display.fillRoundRect(209, 40, 30, 30, 4, 5); display.fillRoundRect(255, 40, 30, 30, 4, 3); if (data <= 12) { // Good display.drawRoundRect(greenOutline.x, greenOutline.y, 40, 40, 4, 6); } else if (data <= 35) { // Bad display.drawRoundRect(yellowOutline.x, yellowOutline.y, 40, 40, 4, 6); } else { // Dangerous display.drawRoundRect(redOutline.x, redOutline.y, 40, 40, 4, 6); }}void drawBatterySquare(int data) { int BASE_SQUARE_X = 252; // Base X position int BASE_SQUARE_Y = 140; // Base Y position int SQUARE_WIDTH = 21; // Width is constant int MAX_SQUARE_HEIGHT = 35; // Maximum height for 100% charge // Map battery percentage to square height int height = map(data, 0, 100, 0, MAX_SQUARE_HEIGHT); // Choose color based on battery percentage uint16_t color; if (data >= 70) { color = 4; } else if (data >= 40) { color = 5; } else { color = 3; } // Calculate Y position based on height to draw from bottom up int yPos = BASE_SQUARE_Y + (MAX_SQUARE_HEIGHT - height); // Draw the battery square display.fillRect(BASE_SQUARE_X, yPos, SQUARE_WIDTH, height, color);}

After downloading the files and opening them in the Arduino IDE, navigate to the config.h file. At the top replace the following variables with your connection information:

  • IO_USERNAME with your Adafruit IO username
  • IO_KEY with your Adafruit IO key
  • WIFI_SSID with your WiFi SSID name
  • WIFI_PASS with your WiFi SSID password

If you don't put your information in the config.h file, you won't be able to connect to WiFi or Adafruit IO!

The main code file connects to four different Adafruit IO feeds to pull data to display. You can update the feed names at the top of the file:

After updating the files with your information, you can upload the code to your Pico W. It takes a few seconds to establish the connection with Adafruit IO, but after that you should see the data and graphics displayed thru the DVI output on the PiCowbell.

Overview 3D Printing

This guide was first published on Apr 16, 2024. It was lastupdated on Apr 16, 2024.

This page (Code the Dashboard) was last updated on Apr 16, 2024.

Text editor powered by tinymce.

PicoDVI Adafruit IO Feed Dashboard (2024)

FAQs

What is the data limit for Adafruit io? ›

If you have a free Adafruit IO Account, the rate limit is 30 data points per minute. If you have upgraded to an Adafruit IO Plus account, the base rate limit is 60 data points per minute. If you exceed this limit, a notice will be sent to the {username}/throttle MQTT topic.

How do I get data from Adafruit io? ›

Receive Data

from Adafruit_IO import Client aio = Client('YOUR ADAFRUIT IO USERNAME', 'YOUR ADAFRUIT IO KEY') # Get the last value of the temperature feed. data = aio. receive('Test') # Print the value and a message if it's over 100.

How much data can an Arduino hold? ›

Arduino Boards Memory Allocation
BoardMicrocontrollerSRAM
LeonardoATmega32u42.5kB
Mega 2560 Rev3ATmega25608kB
MicroATmega32u42.5kB
ZeroATSAMD21G1832kB
20 more rows
Dec 29, 2023

How much data can be stored in Arduino? ›

The microcontroller on the Arduino boards have 512 bytes of EEPROM: memory whose values are kept when the board is turned off (like a tiny hard drive).

Is Adafruit IO open-source? ›

This open source code is licensed under the MIT license (see LICENSE for details). Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

Is Adafruit an IoT platform? ›

What about all this Internet-of-Things (IoT) stuff? Adafruit IO is a platform designed (by us!) to display, respond, and interact with your project's data. We also keep your data private (data feeds are private by default) and secure (we will never sell or give this data away to another company) for you.

Is Adafruit code open-source? ›

Adafruit Industries is an open-source hardware company based in New York, United States. It was founded by Limor Fried in 2005.

How does Adafruit work? ›

Adafruit IO Feeds

Data on IO is kept in time-series databases called feeds. Each feed contains time-stamped data points. The data points don't have to be numbers, they can be any type of data. For example, you can store numbers - say for environmental data like temperature or humidity.

How do I download Adafruit library? ›

Install Adafruit_NeoPixel via Library Manager

From the Sketch menu, > Include Library > Manage Libraries... In the text input box type in "NeoPixel". Look for "Adafruit NeoPixel by Adafruit" and select the latest version by clicking on the popup menu next to the Install button. Then click on the Install button.

References

Top Articles
Latest Posts
Article information

Author: Zonia Mosciski DO

Last Updated:

Views: 5866

Rating: 4 / 5 (71 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Zonia Mosciski DO

Birthday: 1996-05-16

Address: Suite 228 919 Deana Ford, Lake Meridithberg, NE 60017-4257

Phone: +2613987384138

Job: Chief Retail Officer

Hobby: Tai chi, Dowsing, Poi, Letterboxing, Watching movies, Video gaming, Singing

Introduction: My name is Zonia Mosciski DO, I am a enchanting, joyous, lovely, successful, hilarious, tender, outstanding person who loves writing and wants to share my knowledge and understanding with you.