Hello community,
i’m not that good with python and normally using c on esp8266, but today i want to create an e-paper level indicator for the coffee pad dispenser at our office. the blynk server is running local on an rpi and i would like to use the same rpi for the e-paper display hat from waveshare. it works so far, but when i send the value “1” on virtual pin 1 an error occures
This is my code
import BlynkLib
import sys
import os
picdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'pic')
print(picdir)
libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib')
print(libdir)
if os.path.exists(libdir):
sys.path.append(libdir)
import logging
from waveshare_epd import epd2in7
import time
from PIL import Image,ImageDraw,ImageFont
import traceback
logging.basicConfig(level=logging.DEBUG)
logging.info("Starting Coffee Dispenser Display")
epd = epd2in7.EPD()
epd.init()
epd.Clear(0xFF)
font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24)
font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18)
font32 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 32)
# Initialize Blynk
blynk = BlynkLib.Blynk('xxxxxxxxx', server = "127.0.0.1", port = 8080)
Limage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame 264x176
draw = ImageDraw.Draw(Limage)
draw.text((2, 0), 'Coffee Dispenser', font = font32, fill = 0)
draw.text((2, 37), 'Senseo Strong ', font = font24, fill = 0)
bmp = Image.open(os.path.join(picdir, 'bean.bmp'))
Limage.paste(bmp, (190,105))
epd.display(epd.getbuffer(Limage))
epd.sleep()
# Register Virtual Pins
@blynk.VIRTUAL_WRITE(1)
def my_write_handler(value):
print('Current V1 value: {}'.format(value))
if value == 1:
bmp = Image.open(os.path.join(picdir, 'battery_high.bmp'))
else:
bmp = Image.open(os.path.join(picdir, 'battery_empty.bmp'))
Limage.paste(bmp, (2, 87))
epd.display(epd.getbuffer(Limage))
epd.sleep()
while True:
blynk.run()
And this is my error message:
Traceback (most recent call last):
File "coffee02.py", line 53, in <module>
blynk.run()
File "/home/pi/.local/lib/python3.7/site-packages/BlynkLib.py", line 252, in run
self.process(data)
File "/home/pi/.local/lib/python3.7/site-packages/BlynkLib.py", line 207, in process
self.emit("V"+args[1], args[2:])
File "/home/pi/.local/lib/python3.7/site-packages/BlynkLib.py", line 95, in emit
self.callbacks[evt](*a, **kv)
File "coffee02.py", line 49, in my_write_handler
epd.display(epd.getbuffer(Limage))
File "/home/pi/coffee/lib/waveshare_epd/epd2in7.py", line 421, in display
self.send_command(0x10)
File "/home/pi/coffee/lib/waveshare_epd/epd2in7.py", line 162, in send_command
epdconfig.digital_write(self.dc_pin, 0)
File "/home/pi/coffee/lib/waveshare_epd/epdconfig.py", line 53, in digital_write
self.GPIO.output(pin, value)
RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
I’ve searched the internet but it seems i am the only one with that problem.
I also tried to set GPIO mode to GPIO.BCM, but it didn’t made any difference.
Thanks for your help!