P10 display part 2

This is the part 2 of previous tutorial on P10 display which if you don’t have seen, read that first.

So what will be new in this part. First we are gonna use two displays and we will display temperature of room using DHT22 sensor on it. We will also scroll news along with it.

So lets gets started.

 

Things you need:

 

Arduino UNO
P10 driver Arduino shield
P10 display
5v wall adapter
DHT22 Digital Temperature and Humidity Sensor

There some other things like headers and cables which you need, for more details keep reading.

 

Building:

Hardware:

I have already shown you how to make arduino shield for displays so in this part i will show you how to connect two displays together. Its very simple you just have to connect power of both displays together. Make sure you have at-least 2 amps power adapter. And then connect the data lines of two displays using 8*2 parallel connector and you are done.

 

Just make sure you connected them in right direction. The flow of data can be seen from the arrows marked behind displays.

Now we are done with hardware side,so let move on to the software side.

 

Software:

In arduino first we are going to add some libraries which are used to read temperature and humidity from DHT22 sensor. Include “Adafruit_Sensor-master” and “DHT_sensor_library-1.3.0” . Both can be found on git hub. After that open arduino IDE and include all the libraries we need.

Also include fonts libraries.

#include “DHT.h”
#include <SPI.h>
#include <DMD2.h>
#include <fonts/SystemFont5x7.h> #include <fonts/Arial14.h>

 

After that define the data pin to which DHT22 is connected and also define which temperature
sensor are you using. In our case we are using DHT22. Then define the number of display panels
you are using. Also declare the strings in which we will use to store temperature and text.

 

#define DHTPIN 5
#define DHTTYPE DHT22
const int WIDTH = 2; // Set Width to the number of displays wide you have
String string;
String tempstring;

 

I am creating a box 9 pixels down in which my message will scroll.

 

DMD_TextBox box(dmd,0,9,0,0); // “box” provides a text box to automatically write to/scroll the display

 

After that i will create a message which will be scrolling on these panels. This i a random news from BCC. You can scroll text whatever you want.

 

const char *MESSAGE = “The 18-year-old was returning from his successful driving test when of cers in the town of Hemer checked his car with a laser speed gun. He was clocked travelling almost twice the speed limit – at 95km/h (60mph) in a 50km/h (30mph) zone. ‘Some things last forever – others not for an hour,’ German police wrote in their statement. The young man had four friends in the car with him, regional police in Märkischer Kreis said – and speculated that perhaps he was trying to impress with his driving skills. Tiny town catches 58k speeders in two weeks Austrian caught speeding 42 times in a row Instead, he now faces a hefty punishment. He has been formally banned for four weeks, but police said he would only get his licence back after ‘expensive retraining’. He is also facing a €200 ne, two points on his licence once it is restored, and his probationary period as a new driver has been lengthened from two years to four. “;

 

After that create object for DMD panels and DHT sensors.

 

SoftDMD dmd(WIDTH,1); // DMD controls the entire display DHT dht(DHTPIN, DHTTYPE);

 

In your setup section you have to begin the DHT sensor and DMD2 panels. You can also set the brightness and font of your panels.

 

void setup() {

dmd.setBrightness(255); dmd.selectFont(SystemFont5x7); dmd.begin();

dht.begin();

}

 

In your loop section you rst have to send your message to display panels. After that you have to read temperature data from sensors and after converting it to string also send it to panels. As we used libraries so the code is quite simple.

 

void loop() {

const char *next = MESSAGE; while(*next) {

box.print(*next);  //Sending the text to display panels delay(100);

next++;

 float t = dht.readTemperature();   // Reading data from sensor tempstring = String(t);

string = “Temp:” + tempstring ;

dmd.drawString(0,0,string);    // Sending the temperature value to display

}

}

Leave a Reply

Your email address will not be published. Required fields are marked *