Displaying Text Message on Dot Matrix Using Blynk App and Raspberry Pi

Besides Telegram, you can use Blynk to send your text and display on dot matrix!

INTRODUCTION

We have share a tutorial on how to display Telegram text message on dot matrix before. Now, the objectives still same, but we will send the text to Raspberry Pi through Blynk app.

You may need to refer following tutorial first:

  1. Displaying on MAX7219 Dot Matrix Using Raspberry Pi
  2. Controlling LED on Maker pHAT Using Raspberry Pi and Blynk

VIDEO

This video shows how to display text message on dot matrix using Blynk App and Raspberry Pi

Untuk bahasa Melayu, sila rujuk video dibawah.

HARDWARE PREPARATION

Sample Code

This sample code will read the text sent from Blynk app and display to MAX7219 dot matrix.

from gpiozero import LED, Button, Buzzer
import BlynkLib
from time import time, sleep, strftime
from datetime import datetime
import sys
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
from luma.core.virtual import viewport
from luma.led_matrix.device import max7219
from luma.core.legacy import text, show_message
from luma.core.legacy.font import proportional, CP437_FONT, LCD_FONT
led1 = LED(17)
led2 = LED(18)
led3 = LED(27)
led4 = LED(22)
led5 = LED(25)
led6 = LED(12)
led7 = LED(13)
led8 = LED(19)
sw1 = Button(21)
buzzer = Buzzer(26)
BLYNK_AUTH = 'YourAuthToken'
# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
# Register Virtual Pins
@blynk.VIRTUAL_WRITE(0)
def my_write_handler(value):
global counter
global BlynkText
buzzer.beep(0.1, 0.1, 1)
BlynkText = format(value[0])
print('Blynk Text: {}'.format(BlynkText))
counter = 1
serial = spi(port=0, device=0, gpio=noop())
device = max7219(serial, width=32, height=8, block_orientation=-90)
device.contrast(5)
virtual = viewport(device, width=32, height=8)
def millis():
return time() * 1000
def my_user_task():
global counter
global BlynkText
print('Counter = {}'.format(counter))
if counter == 0:
buzzer.beep(0.1, 0.1, 2)
show_message(device, 'Blynk Ready', fill="white", font=proportional(LCD_FONT), scroll_delay=0.05)
counter = 3
elif counter < 4:
if len(BlynkText) > 0:
show_message(device, BlynkText, fill="white", font=proportional(LCD_FONT), scroll_delay=0.08)
else:
counter = 3
else:
if counter == 10:
counter = 0
with canvas(virtual) as draw:
text(draw, (0, 1), datetime.now().strftime('%I:%M'), fill="white", font=proportional(CP437_FONT))
counter = counter + 1
counter = 0
BlynkText = ''
currentMillis = 0
previousMillis = 0
interval = 5000
try:
while True:
blynk.run()
currentMillis = millis()
if currentMillis - previousMillis > interval:
my_user_task()
previousMillis = currentMillis
except KeyboardInterrupt:
sys.exit(0)

Thank You

References

  1. blynk-library-python from vshymanskyy
  2. Luma.LED_Matrix, credit to Richard Hull.

Thanks for reading this tutorial. If you have any technical inquiry, please post at Cytron Technical Forum.

4 thoughts on “Displaying Text Message on Dot Matrix Using Blynk App and Raspberry Pi”

  1. Hi meek424424, thanks for the feedback. It seems like Blynk already update their library, so the sample code here also need to be updated. However, it will take some times for us to update the code. While waiting, maybe you can try to alter the code. Please refer the example code provided by Blynkhere. Thanks.

  2. I am having issues. When I run the python script, Line 66 is kicking up an error. Does the script need updated? It just doesn’t like the line “blynk.set_user_task(my_user_task, 5000)” Please let me know what I am doing wrong. Thanks! 🙂

  3. DIANA ANN AGASTIN

    thank you very much . I learn something new in this vidoe. And it will help for my final year project.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

DIY Digital Alarm Clock Using REKA:BIT With Micro:bit
Display Internet Time (NTP) on micro:bit
DIY Interactive Robot Using REKA:BIT With Micro:bit
BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
Tutorials of Cytron Technologies Scroll to Top