$USD
  • EUR€
  • £GBP
  • $USD
PROJECTS Arduino

Arduino UNO Project: How to DIY a RGB Clock

DFRobot Dec 27 2017 335

Even if I knew my place,
Should I leave it there?
Should I give up?
Or should I just keep chasin' pavements Even if it leads nowhere?
I build myself up~
When I went shopping in the Christmas Day, I walked through the beautiful Chunxi in Chengdu, the large screen was playing Chasing Pavements. Getting lost in the face of Adele, I was totally sank into the video.
I even wanted to take this screen to my home (if I could)!
Back to home, happy to find that my roommate made a beautiful RGB clock, thinking about the big shopping mall screen, I cannot stop borrow the RGB clock (to DIY my own RGB clock)! 

In the first day, I have taken it apart to check the constructions (⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄,thank god I haven’t screwed it up). 

Hardware

32x16 RGB LED Matrix Panel (6mm pitch)
DFRduino UNO R3 - Arduino Compatible
Gravity IO Expansion Shield for Arduino V7.1
Gravity: I2C SD2405 RTC Module

Air Quality Monitor (PM 2.5, Formaldehyde, Temperature & Humidity Sensor)



Why should I chose Gravity IO Expansion Shield for Arduino V7.1 as the expansion shield?

1.Free from complicated wiring and troubleshooting.
2.External expansion power supply, the terminal in the corner supplies the main controller and the expansion board, the other terminal in the middle supplies the servo connected to any Digital interface(avoid exceptional external power supply to RGB matrix screen, the wiring shown as below).

Wiring Diagram

NOTE: Please connect wires to the DFRduino UNO R3 - Arduino Compatible correctly, Green wires to Digital interfaces (2~9), Blue wires to Analog interfaces (0~3), Black wire to GND.

Wiring Real Time module to Air Quality Monitor

I was planned to make the UNO R3 wiring more convenient, unfortunately, I failed to change the wire except the upgraded adapter wiring. Then I found the parking list of the RGB matrix panel in the DFRobot, it contains 16pin IDC to IDC wire, which realizes my plan!  

After the assembly, power on and the colorful RGB can be seen (support both battery supply and USB.

There are 3 colors in the RGB clock, Time is set to be green, date/temperature/humidity/PM2.5 are set to be Red or Blue randomly. You can also modify the parameters and change colors.

Humidity Display

Temperature Display



Date Display


The RGB clock is bright and penetrating. You can put it into the obvious place to remind yourself time. After all, the missing cattle and sheep can be found; but can't find the lost time. The RGB matrix panel connected to external power supply is so bright that can be seen far away. If it is too dazzling, you can put something (e.g. black plastic paper) in the surface of the panel to protect your window of soul.   


Code

#include <SoftwareSerial.h>
#include <Adafruit_GFX.h>   // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
#include <Wire.h>
#include "GravityRtc.h"
SoftwareSerial Serial1(10, 11);
GravityRtc rtc;
#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE  9
#define A   A0
#define B   A1
#define C   A2
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
char col;
unsigned int PMSa = 0, FMHDSa = 0, TPSa = 0, HDSa = 0, PMSb = 0, FMHDSb = 0, TPSb = 0, HDSb = 0;
unsigned int PMS = 0, FMHDS = 0, TPS = 0, HDS = 0, CR1 = 0, CR2 = 0;
unsigned char buffer_RTT[40] = {}; //The serial port receives data
char tempStr[15];
char* str[] = {"error", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
int r, y, b, z;
int model = 1;
void setup()
{
  matrix.begin();
  rtc.setup();
  //rtc.initRtc(2017,9,27,3,16,20,3);//setup time
  Serial.begin(9600);
}

void loop()
{
  if (model == 3)
  {
    model = 1;
  }
  switch (model) {
    case 1: r = 0; y = 7; b = 0; break;
    case 2: r = 0; y = 0; b = 7; break;
  }
  rtc.update();
  while (Serial.available() > 0) //Check whether there is serial data
  {

    for (int i = 0; i < 40; i++) //Read serial data
    {
      col = Serial.read();
      buffer_RTT[i] = (char)col;
      delay(2);
    }

    Serial.flush();

    CR1 = (buffer_RTT[38] << 8) + buffer_RTT[39];
    CR2 = 0;
    for (int i = 0; i < 38; i++)
      CR2 += buffer_RTT[i];
    if (CR1 == CR2)              //check
    {
      PMSa = buffer_RTT[12];      //Read PM2.5 high octet data
      PMSb = buffer_RTT[13];      //Read PM2.5 low octet data
      PMS = (PMSa << 8) + PMSb;   //PM2.5 data
      FMHDSa = buffer_RTT[28];    //Read the high octet data
      FMHDSb = buffer_RTT[29];    //Read the low octet data
      FMHDS = (FMHDSa << 8) + FMHDSb; //Formaldehyde data
      TPSa = buffer_RTT[30];      //Read the high octet data
      TPSb = buffer_RTT[31];      //Read the low temperature 8-bit data
      TPS = (TPSa << 8) + TPSb;   //Temperature data
      HDSa = buffer_RTT[32];      //Read the humidity high octet data
      HDSb = buffer_RTT[33];      //Read low humidity eight bits of data
      HDS = (HDSa << 8) + HDSb;    //Humidity data
    }
  }


  matrix.fillScreen(0);
  // draw some text!
  // start at top left, with one pixel of spacing
  matrix.setTextSize(1);    // size 1 == 8 pixels high
  matrix.setCursor(0, 0);
  matrix.setTextSize(1);
  matrix.setTextColor(matrix.Color333(0, 7, 0));
  if (rtc.hour < 10)
  {
    matrix.print('0');
    matrix.print(rtc.hour);
  }
  else
    matrix.print(rtc.hour);
  matrix.print(':');
  if (rtc.minute < 10)
  {
    matrix.print('0');
    matrix.print(rtc.minute);
  }
  else
    matrix.println(rtc.minute);
  sprintf(tempStr, "%d%d.%d", TPS / 100, (TPS / 10) % 10, TPS % 10);
  matrix.setTextColor(matrix.Color333(y, r, b));
  matrix.setCursor(0, 8);
  matrix.print(tempStr);
  matrix.print("C");
  matrix.fillRect(30, 9, 30, 2, matrix.Color333(y, r, b));
  delay(5000);

  // draw some text!
  matrix.fillRect(0, 7, 32, 9, matrix.Color333(0, 0, 0));
  matrix.setCursor(12, 0);
  matrix.setTextColor(matrix.Color333(0, 0, 0));
  matrix.print(':');
  delay(300);
  matrix.setCursor(12, 0);
  matrix.setTextColor(matrix.Color333(0, 7, 0));
  matrix.print(':');
  matrix.setCursor(6, 8);
  matrix.setTextColor(matrix.Color333(0, 0, 7));
  matrix.print(str[rtc.week]);
  delay(5000);
  matrix.fillRect(0, 7, 32, 9, matrix.Color333(0, 0, 0));
  matrix.setCursor(12, 0);
  matrix.setTextColor(matrix.Color333(0, 0, 0));
  matrix.print(':');
  delay(300);
  matrix.setCursor(12, 0);
  matrix.setTextColor(matrix.Color333(0, 7, 0));
  matrix.print(':');
  matrix.setTextColor(matrix.Color333(y, r, b));
  matrix.setCursor(0, 8);
  if (rtc.month < 10)
  {
    matrix.print('0');
    matrix.print(rtc.month);
  }
  else
    matrix.print(rtc.month);
  matrix.print('-');
  if (rtc.day < 10)
  {
    matrix.print('0');
    matrix.print(rtc.day);
  }
  matrix.print(rtc.day);
  delay(5000);
  matrix.fillRect(0, 7, 32, 9, matrix.Color333(0, 0, 0));
  matrix.setCursor(12, 0);
  matrix.setTextColor(matrix.Color333(0, 0, 0));
  matrix.print(':');
  delay(300);
  matrix.setCursor(12, 0);
  matrix.setTextColor(matrix.Color333(0, 7, 0));
  matrix.print(':');
  matrix.setTextColor(matrix.Color333(b, r, y));
  matrix.setCursor(0, 8);
  matrix.print(PMS);
  matrix.print("ug");
  delay(5000);
  matrix.fillRect(0, 7, 32, 9, matrix.Color333(0, 0, 0));
  matrix.setCursor(12, 0);
  matrix.setTextColor(matrix.Color333(0, 0, 0));
  matrix.print(':');
  delay(300);
  matrix.setCursor(12, 0);
  matrix.setTextColor(matrix.Color333(0, 7, 0));
  matrix.print(':');
  sprintf(tempStr, "%d%d.%d", HDS / 100, (HDS / 10) % 10, HDS % 10);
  matrix.setTextColor(matrix.Color333(y, r, b));
  matrix.setCursor(0, 8);
  matrix.print(tempStr);
  matrix.print("%");
  delay(5000);
  model += 1;
}

3D Printing File
RGB library.zip

REVIEW