Skip to content

Commit

Permalink
Waveshare 3.7" Pi Pico and FireBeetle support
Browse files Browse the repository at this point in the history
Add support for a Waveshare Pi Pico 3.7" display connected
to a DFRobot FireBeetle.

Notable things in this example include:
 - Use u8g2 functions to get string/font sizes rather than
   display.getTextBounds, as it seems more accurate when using
   u8g2 fonts, and makes drawString[MaxWidth] easier to place.
 - Use the calibrated ESP32 adc functions to measure the battery
   voltage, and use a simpler algorithm to predict percentage.
 - For the overnight long sleep period, do a single long sleep
   rather than wake every 30 minutes to check.
 - When the battery voltage is below a dangerous level, print
   a large obvious battery warning on the screen!

Signed-off-by: Graham Whaley <[email protected]>
  • Loading branch information
grahamwhaley committed Mar 25, 2022
1 parent 8445d73 commit bd6b151
Show file tree
Hide file tree
Showing 7 changed files with 1,240 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Download the software to your Arduino's library directory.
- Waveshare_2_13
- Waveshare_2_7
- Waveshare_2_9
- Waveshare_3_7
- Waveshare_4_2
- Waveshare_7_5
- Waveshare_7_5_T7 (newer 800x480 version of the older 640x384)
Expand All @@ -38,9 +39,9 @@ Download the software to your Arduino's library directory.

5. Save your files.

NOTE: See schematic for the wiring diagram, all displays are wired the same, so wire a 7.5" the same as a 4.2", 2.9" or 1.54" display! Both 2.13" TTGO T5 and 2.7" T5S boards come pre-wired.
NOTE: See schematic for the wiring diagram, all displays are wired the same, so wire a 7.5" the same as a 4.2", 2.9" or 1.54" display! Both 2.13" TTGO T5 and 2.7" T5S boards come pre-wired. The 3.7" FireBeetle example contains wiring details.

The Battery monitor assumes the use of a Lolin D32 board which uses GPIO-35 as an ADC input, also it has an on-board 100K+100K voltage divider directly connected to the Battery terminals. On other boards, you will need to change the analogRead(35) statement to your board e.g. (39) and attach a voltage divider to the battery terminals. The TTGO T5 and T5S boards already contain the resistor divider on the correct pin.
The Battery monitor assumes the use of a Lolin D32 board which uses GPIO-35 as an ADC input, also it has an on-board 100K+100K voltage divider directly connected to the Battery terminals. On other boards, you will need to change the analogRead(35) statement to your board e.g. (39) and attach a voltage divider to the battery terminals. The TTGO T5 and T5S boards already contain the resistor divider on the correct pin. The FireBeetle has a battery monitor on GPIO-36.

Compile and upload the code - Enjoy!

Expand All @@ -56,6 +57,10 @@ Compile and upload the code - Enjoy!

![alt_text, width="400"](/Waveshare_4_2.jpg)

3.7" 480x280 E-Paper Layout

![alt_text, width="400"](/Waveshare_3_7.jpg)

2.7" 264x176 E-Paper Layout

![alt_text, width="400"](/Waveshare_2_7.jpg)
Expand Down
Binary file added Waveshare_3_7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions examples/Waveshare_3_7/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Waveshare Pi Pico 3.7" wired to FireBeetle

This example is for a
[Waveshare Pi Pico 3.7" display](https://www.waveshare.com/pico-epaper-3.7.htm) connected
to a [DFRobot FireBeetle board](https://www.dfrobot.com/product-1590.html).

The display is formally known as *SKU: 20123*, *Part Number: Pico-ePaper-3.7*.

Although the display is designed to operate directly with a
[Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/), the Pi Pico
has neither native WiFi support nor super low power modes. The FireBeetle has both.

## Wiring

The below table shows the wiring used in the example. The FireBeetle is wired to the
Pi Pico header pins on the display. These details can also be found near
the top of the code.

It should be possible to use the alternative H1 SPI connector on the display board, but I
didn't have an appropriate plug to try.

The display is wired to SPI0, but uses different pins for the extra control lines than the
normal Lolin D32 examples in this repository, as some of the normal pins are nominally already
assigned other tasks on the FireBeetle.

| Function | Display pin | Firebeetle GPIO |
| -------- | ----------- | --------------- |
| BUSY | 17 | D2 (IO25) |
| RST | 16 | D3 (IO26) |
| DC | 11 | D4 (IO27) |
| CS | 12 | D8 (IO5) |
| CLK | 14 | IO18 (SCK) |
| DIN | 15 | IO23 (MOSI) |
| GND | 13 | GND |
| VSYS | 39 (VSYS) | VCC |

## ADC and battery monitor

The FireBeetle contains a battery monitor voltage divider consisting of a pair of 1Mohm resistors
and a smoothing capacitor, but by default it is disabled by two nofit 0ohm resistors. The enable
the battery monitor function these two missing resistors need to be fitted or bridged. They
are resistors R10 and R11. Details can be found in the FireBeetle schematic, and the below picture
shows their location near the 32Khz crystal - the bridged pads are circled in red.

Note, it is much easier to bridge the pads **before** you fit any headers to the board.

![alt_text, width="200"](./firebeetle_adc_links.jpg)
Loading

0 comments on commit bd6b151

Please sign in to comment.