Difference between revisions of "4.2inch e-Paper Cloud Module"

From Waveshare Wiki
Jump to: navigation, search
(2 intermediate revisions by the same user not shown)
Line 16: Line 16:
 
You can connect to the device via wifi with port number 6868, and update display with commands.<br />
 
You can connect to the device via wifi with port number 6868, and update display with commands.<br />
 
You can configure the devices via wifi or Bluetooth, if you are the first time configure the deivce, only the Bluetooth is avaialble.<br />
 
You can configure the devices via wifi or Bluetooth, if you are the first time configure the deivce, only the Bluetooth is avaialble.<br />
<font color=red>'''You need to wakeup the device by button'''</font>
+
<font color=red><big>'''Note:<br />
 +
The firmware of the 4,2inch cannot be reprogrammed by used because the flash is locked.<br />
 +
You need to wakeup the device by button'''</big></font>
  
 
===Features===
 
===Features===
Line 42: Line 44:
  
 
</div>
 
</div>
<!--
 
 
<div class="tabbertab" title="RPI User Guides">
 
<div class="tabbertab" title="RPI User Guides">
 +
{{RPi User Guides for 4.2inch e-Paper Cloud}}
  
=安装库=
+
</div>
<pre>
+
<div class="tabbertab" title="Windows User Guides">
#python3
+
{{Windows User Guides for 4.2inch e-Paper Cloud}}
sudo apt-get update
 
sudo apt-get install python3-pip
 
sudo apt-get install python3-pil
 
sudo apt-get install python3-tqdm
 
sudo apt-get install python3-numpy
 
sudo apt-get install python3-progressbar
 
</pre>
 
 
 
=下载测试程序=
 
打开树莓派终端,执行:<br />
 
<pre>
 
sudo apt-get install p7zip-full
 
sudo wget https://www.waveshare.net/w/upload/2/2e/Cloud_RPI.7z
 
7z x Cloud_RPI.7z
 
cd Cloud_RPI
 
</pre>
 
 
 
=python=
 
*本例程仅可使用python3
 
*请务必在Cloud_RPI 文件,再运行一下命令
 
<pre>
 
#该程序会自动从微雪官网爬取图片并发送给从机显示
 
sudo python3 ./examples/display_WS.py
 
#该程序会根据程序生成图形并发送给从机显示
 
sudo python3 ./examples/display_EPD.py
 
</pre>
 
 
 
=API详解=
 
在lib目录下有三个文件夹分别为http_get、tcp_server和waveshare_epd,分别对应抓取http图片、TCP服务器、墨水屏相关的函数
 
[[File:Cloud_ESP32_e-Paper_Board_manual_10.png|800px]]
 
 
 
==tcp_sver.py==
 
目录:Cloud_RPI/lib/tcp_server <br />
 
在tcp_sver.py中创建了一个tcp_sver类,使用过程中需要对其进行继承,并重构它的handle函数
 
<pre>
 
def handle(self)
 
</pre>
 
每次有新客户端连接到服务器都会调用handle函数进行处理
 
 
 
==='''接收信息函数'''===
 
*其会自动解析返回格式,并返回原信息,具体可以参考用户手册第二章的返回格式部分
 
<pre>
 
def Get_msg(self)
 
</pre>
 
{| class="wikitable"
 
|-
 
! 接收信息 !!返回信息
 
|-
 
|&#39;$&#39;+数据+&#39;#&#39;||数据
 
|}
 
 
 
==='''指令发送函数'''===
 
*其会自动生成帧头、帧尾和校验发送并校验返回值,具体可以参考用户手册第二章的指令格式部分
 
<pre>
 
def Send_cmd(self,cmd)
 
</pre>
 
参数cmd为需要发送的字符串<br />
 
{| class="wikitable"
 
|-
 
! 需要发送内容!!实际发送内容
 
|-
 
|cmd||‘;’+cmd+&#39;/&#39;+校验
 
|}
 
==='''数据发送函数'''===
 
*其会自动生成帧头、帧尾和校验发送并校验返回值,具体可以参考用户手册第二章的数据格式部分
 
<pre>
 
def Send_data(self,data)
 
</pre>
 
参数data为需要发送的队列信息(包含地址长度等信息),具体可以参考用户手册第二章的数据格式部分,建议使用下方的flush_buffer函数<br />
 
{| class="wikitable"
 
|-
 
! 需要发送内容!!实际发送内容
 
|-
 
|data|| 0x57+data+校验
 
|}
 
可以将Send_cmd和Send_data这两函数理解为两种封包模式
 
==='''设置画面大小函数'''===
 
<pre>
 
def set_size(self,w,h)
 
</pre>
 
参数w为图像宽度,参数h为图像高度,用于确定需要发送的数据长度<br />
 
因为我们以黑白墨水屏为例,一个像素点的数据长度为1bit,不难推出一下公式<br />
 
{| class="wikitable"
 
|-
 
! 数据总长=图像宽度(w)*图像高度(h)/8
 
|}
 
[https://www.waveshare.net/wiki/4.2inch_e-Paper_Module 参考4.2inch e-Paper Module]
 
 
 
==='''刷新画面函数(仅指令模式下使用)'''===
 
*其会将图像队列拆分成指定长度,并发送给从机显示
 
<pre>
 
#ID含有中文时,可能导致进度条出现错位现象
 
def flush_buffer(self,DATA)
 
</pre>
 
参数DATA为需要为图像队列,图像队列可以由image对象经过下文中的getbuffer函数转化而来<br />
 
{| class="wikitable"
 
|-
 
! 发送数据!!发送次数!! 单帧数据长度(len) !! 发送内容
 
|-
 
| DATA(图像队列) || 数据总长/单帧数据长度(len)|| 1024 Byte(用户可定义) || 0x57+4 Byte addr+ 4 Byte len +1 Byte num + len Byte data+校验
 
|}
 
<font color="red">'''每次传输数据长度不应超过1100Byte,否则将会导致数据丢失.'''</font><br />
 
 
 
具体请参考用户手册第二章通讯协议
 
 
 
==='''电池电压检测函数'''===
 
*返回当前电压值
 
<pre>
 
def check_batter(self)
 
</pre>
 
 
 
==http_get.py==
 
目录:Cloud_RPI/lib/http_get<br />
 
*下载图片函数
 
<pre>
 
def Get_PNG(Url,Name)
 
</pre>
 
该函数会从Url参数对应的网址下载图片,将其以Name参数为文件名,存储到当前目录下。
 
 
 
==epd4in2.py==
 
目录:Cloud_RPI/lib/waveshare_epd<br />
 
 
 
*将图片信息转为队列
 
<pre>
 
def getbuffer(self, image):
 
</pre>
 
  
 
</div>
 
</div>
 
 
 
 
-->
 
 
<div class="tabbertab" title="Resources">
 
<div class="tabbertab" title="Resources">
 
===Related Guides===
 
===Related Guides===

Revision as of 07:44, 15 January 2021

4.2inch e-Paper Cloud Module
4.2inch-e-Paper-Cloud-Module-1.jpg

4.2inch E-Paper Cloud Module, 400×300 Pixels, WiFi Connectivity
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

You can connect to the device via wifi with port number 6868, and update display with commands.
You can configure the devices via wifi or Bluetooth, if you are the first time configure the deivce, only the Bluetooth is avaialble.
Note:
The firmware of the 4,2inch cannot be reprogrammed by used because the flash is locked.
You need to wakeup the device by button

Features

  • Integrates SW6106 chip, supports multiple quick charge protocols including PD / QC / FCP / PE / SFCP, etc.
  • Allows the user to control the display content via a remote server, convenient and flexible
  • ID support, make it easy to centrally manage and track the modules
  • Provides Android APP for configuring and managing the modules
  • No backlight, keeps displaying last content for a long time even when power down
  • Long battery life, basically power consumption is only required for refreshing

Specification

  • Power supply:Battery
  • Resolution:400 x 300
  • Pixel pitch:0.212 × 0.212
  • Display color:Black, White
  • Refresh time:4s
  • Viewing Angle:>170°
  • Outline Dimensions:96.5mm × 85mm
  • Display Size:84.8mm × 63.6mm

You can download and install the APP by scanning the QR codes
Cloud APP.png

Lead Information

Every time the device start, it will do partial refresh and display status icons.
Hereby provide the refrence of icons.

Cloud ESP32 e-Paper Board wait.png Cloud ESP32 e-Paper Board set.png Cloud ESP32 e-Paper Board batter.png Cloud ESP32 e-Paper Board wifi.png Cloud ESP32 e-Paper Board wifi connect.png
Waiting Setting Low Voltage WIFI Host
  • Waiting: The device is waiting for commands.
  • Setting: Setting is finished.
  • Low Voltage: The voltage of battareis is lower than warnning value.
  • WIFI: The wifi is connected.
  • Host: The devices is connected to target host by IP address.
  • Generally, you should press the button to wake up the device and check the icons. The warnning voltage is 3600mv, once the voltage is 150mv lower than warnning voltage (3450mv), the devices will shutdown automatically to protect the stable of the whole system.

Configure Device

First Setup

If you didn't configure the device before, you should configure the device by APP after pressing the Wakeup button to update the display①. Please refer to #1.4 Configure Device by APP to configure the device.②
Note:
①If the device isn't configured, Waiting icon is displaed in the top-right area. If the Low Voltage icon is displayed without Waiting, it means that the batteris is less than 3450mv and it is going to shutdown.
②If the device doesn't connect to Bluetooth, it will shutdown after 90s after booting and refreshing the display.

Reconfiguration

If the device was configured, the device will update and display Setted icon in the top-right area① after pressing wakeup button. The Bluetooth is disabled by default, if required, you should hold the wakeup button for 5s at least to enable the Bluetooth②. The updating process of device will not be interrupted③ while enabling the Bluetooth. After enabling the Bluetooth, you can re-configure the device by referring to #1.4 Configure Device by APP ④.
Note:
①The update time of the device is determined by the speed of WIFI, It should less than 30s as we test.。
②You can hold the wake-up button until your phone scan the device via Bluetooth. Otherwise, the device auto-shutdown if the Bluetooth is disconnected.。
③If you enable the Bluetooth of the device, it will try to connect to master (phone) in 30s if the shutdown command is received via wifi. If the device is connected to the phone by Bluetooth, it will keep waking, otherwise, it will be turned off after 30s.
④You should reboot the device after configuration to make the configuration effect. Please do not reboot the device when transmitting data via WIFI, it will cost data loss.

APP Description

Cloud Epd app 1.png
Bluetooth Connection Button and the information
Cloud Epd app 2.png
Device ID: for distinguish devices
Cloud Epd app 3.png
WIFI_SSID
Cloud Epd app 4.png
Check the current SSID connected
Cloud Epd app 5.png
WIFI_Password
Cloud Epd app 6.png
Host_IP, The IP of host, for example, the IP of Raspberry Pi.
Cloud Epd app 8.png
Device_IP: This is used to set the static IP. If you enable DHCP, the static IP is unavailable
Cloud Epd app 7.png
Device_Password, you should input the device password to vertify if the device is locked.

Note: The default device password of the Raspberry Pi example is 123456. If you lock the device you have to unlock it with password 123456, otherwise, the device cannot work.

Cloud Epd app 9.png

Warning_voltage: If the voltage of batteries is less than the warning voltage, the device will display the warning icon. If the battery is 150mV lower than the warning voltage, the device will shutdown automatically.

Cloud Epd app 10.png
Load the configuration saved
Cloud Epd app 11.png
Save the current configuration, you can save up to four sets of configuration
Cloud Epd app 12.png
Upload the current configuration to device.
Cloud Epd app 13.png
Formating: Clean the current configuration

Configure Device by APP

Ⅰ. Open APP(APP will auto-save the last configuration information)
Cloud ESP32 e-Paper Board manual 1.png
Ⅱ. Click the Bluetooth CONNECTION button, the default Bluetooth device is WaveShare_EPD or the Device ID configured.
Unpaired
Unparied
Paried
Paried
Ⅲ. Choose the device, for example, connect the WaveShare_EPD. If you are the first time to connect the WaveShare_EPD device, it should be paired first.
Cloud ESP32 e-Paper Board manual 4.png
Ⅳ. Modify the configuration information and Upload(If you have configured the password, you need to input the password as well.)
Cloud ESP32 e-Paper Board manual 5.png
Ⅴ. The APP will disconnect and reboot the device if the configuration is uploaded successfully.
Cloud ESP32 e-Paper Board manual 6.png
Note: We recommend you set static IP for the device.

Communicating Protocol

Communicating is divided into two modes: Command mode and the data mode. Command mode is used for sending commands. data Mode is used for sending image data to e-Paper.

Command Format

‘;’+Command(+Data)+'/'+Parity

Data Format

0x57+4Byte addr+ 4Byte len +1Byte num + len Byte data +Verify

Return Format

'$'+Data+'#' The format of the response of Command and Data is the same

Note: The Verity is the XOR result of data which is marked in red.

Command Mode:

Command Format

‘;’+Comamnd(+Data)+'/'+Verify

Commands (locked)

Comamnd Desctiption Return
'C' Check if the device is locked Parity bit + Flag bit 0 or 1, 0: unclocked, 1: locked.
‘N' + Device password Unclocked the device Parity bit + Flag bit 0 or 1, 0: failed to lock; 1: lock the device successfully.
'G' Get the ID of device ID
'r' + Sleep time (<9999) Set the device to sleep mode Parity bit

PS: The sleep command is only available in 2.13inch e-Paper Cloud Module.

These commands can be used if the device is locked.

Comamnds (unlocked)

Command Description Return
'0' + name Modify the ID Parity bit
'1' + IP address Modify the IP address of Host Parity bit
‘2’+SSID Modify the WIFI SSID Parity bit
‘3’+password Modify the WIFI password Parity bit
‘P’+userpassword Modify the device password Parity bit
'L' +'0' / 'L' + '1' Set the device lock; 1 to lock and 0 to unlock Parity bit
's' + '0' /'s' + '1' Set the flag bit, 0 to disable and 1 to enable Parity bit
'F' Enter data mode Parity bit
'B' Open Bluetooth Parity bit
'b' Check the current voltage of battery Parity bit + voltage of battery (mv)
'S' Shutdown Parity bit
'R' Restart Parity bit
These commands can be used when the device is unlocked.

Data Mode:

Data Format

0x57+4Byte addr+ 4Byte len +1Byte num + len Byte data +Verify
Data Lebs Content
addr 4byte Address of data
len 4byte Length os data
num 1byte The frame number of current sector
data len byte The data transmitted

Note:

  1. Recommend you transmit the frames with the same length.
  2. The size of frame transmitted should not larger than 1100Byte, otherwise it cause data lose.
  3. num should be a static variable because it may be invalid because of version updates.
  4. The data frame doesn't have a stop bit, you need to wait for the verity data before sending the next frame, otherwise, it causes failure.
  5. The e-Paper will update automatically and exit from update mode when the addr and len are 0.

For more details, please refer to the python3 examples provided.

Using Guides for RPI

Install Libraries

#python3
sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-pil
sudo apt-get install python3-tqdm
sudo apt-get install python3-numpy
sudo apt-get install python3-progressbar

Download the demo codes

Open a terminal and runthe following commands:

sudo apt-get install p7zip-full
sudo wget https://files.waveshare.com/upload/2/2e/Cloud_RPI.7z
7z x Cloud_RPI.7z
cd Cloud_RPI 

python

  • The demo codes can only support python3.
  • Please go to the directory of Cloud_RPI and run the command:
#This code is used to climb the picture of the Waveshare website and transmit the image data to the slave device.
sudo python3 ./examples/display_WS.py 
#The codes will draw figures and send the image data to the slave device.
sudo python3 ./examples/display_EPD.py 

API Description

There are three directories in lib,http_get, tcp_server和waveshare_epd, They are used to climb HTTP pictures, TCP service, and the functions of e-Paper.
Cloud ESP32 e-Paper Board manual 10.png

tcp_sver.py

Path: Cloud_RPI/lib/tcp_server
Create a tcp_server class in the tcp_sver.py file. You need to inherit the class and refactor the handle function when using.

def handle(self)

Every time a new client is connected, it should call the handle function.

Receive Message

def Get_msg(self)
Command Return
'$'+Data+'#' Data

Send Command

def Send_cmd(self,cmd)

Parameter cmd is the command sent.

Command
cmd ‘;’+cmd+'/'+Parity

Sent data

def Send_data(self,data)

The parameter data is a message transmitted (including address and lenghta nd so on) data.

Command
data 0x57+data+ Parity

Set size

def set_size(self,w,h)

w: The width of the image; h: The height of the image.
Take bicolor e-Paper as an example, 1 bit stands for one pixel, then you get.

Len of data=Width of image(w)*Height of image(h)/8

Refer to 4.2inch e-Paper Module

Update function

def flush_buffer(self,DATA)

DATA; The image data. the image data can be get by the getbuffer function.

Parameter Send times Length of every frame(len) Content DATA(Image data) Total length of image data/length of singal frame(len) 1024 Byte(Configurable) 0x57+4 Byte addr+ 4 Byte len +1 Byte num + len Byte data+Parity

The length of signal transmission should less than 1100 Byte, or it will cause data loss.

Check voltage of battery

  • Get the current voltage.
def check_batter(self)

Power Off Function

  • Power off or low power state.
def Shutdown(self)

http_get.py

Path:Cloud_RPI/lib/http_get

  • Download picture
def Get_PNG(Url,Name)

This function is used to download the picture from Url and save it to the current directory with Name

epd4in2.py

Path:Cloud_RPI/lib/waveshare_epd

  • Convert the picture to image data.
def getbuffer(self, image):

waveshare_epd.py

Directory: Cloud_RPI/lib/waveshare_epd
Convert image information to queue

def getbuffer(self, image):

Configure Windows

This guide is made in Windows 10

  • Note:
  1. Please make sure that you have installed python3 on your Windows PC and the default version is python3 if you installed multiple versions.
  2. You may need to close the firewall to make the python work.

Install libraries

Open a CMD or Powershell to install libraries with the following commands:

#python3
python -m pip install tqdm
python -m pip install pillow
python -m pip install numpy
python -m pip install pypiwin32
python -m pip install progressbar

Download demo codes

Download the Windows demo, unzip, and enter the Cloud_WIN directory.

python

Note that you need to run the CMD or PowerShell under the Cloud_WIN direcoty and turn the following command.

python ./examples/***inch_display_EPD

For example:

#If you have 4.2inch e-Paper Cloud Module
python ./examples/4.2inch_display_EPD
#If you have2.13inch e-Paper Cloud Module
python ./examples/2.13inch_display_EPD

Related Guides

Androdi app

Cloud APP.png

Raspberry Pi Examples




Support

If you require technical support, please go to the Support page and open a ticket.