Silicon ChipD1 Mini LCD BackPack with WiFi - October 2020 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: The balance between historical and forward-looking articles
  4. Feature: Satellite Navigation in Space by Dr David Maddison
  5. Project: D1 Mini LCD BackPack with WiFi by Tim Blythman
  6. Feature: Improved ADS-B Reception on a Computer by Jim Rowe
  7. Project: Flexible Digital Lighting Controller, part 1 by Tim Blythman
  8. PartShop
  9. Serviceman's Log: Decisions, decisions, decisions... by Dave Thompson
  10. Review: The CAE SoundCam by Allan Linton-Smith
  11. Project: USB SuperCodec – part three by Phil Prosser
  12. Vintage Radio: AWA model 501 console radio by Associate Professor Graham Parslow
  13. Project: High Power Ultrasonic Cleaner – part two by John Clarke
  14. Product Showcase
  15. Feature: The Matrox ALT-256 Graphics Card by Hugo Holden
  16. Market Centre
  17. Notes & Errata: Four USB power supplies for laptop charger, Circuit Notebook, August 2020; Velco 1937 radio chassis restoration, August 2020; Infrared Remote Control Assistant, July 2020
  18. Advertising Index
  19. Outer Back Cover

This is only a preview of the October 2020 issue of Silicon Chip.

You can view 40 of the 112 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "D1 Mini LCD BackPack with WiFi":
  • Mini WiFi LCD BackPack PCB [24106201] (AUD $5.00)
  • 3.5-inch TFT Touchscreen LCD module with SD card socket (Component, AUD $35.00)
  • Mini WiFi LCD BackPack kit (Component, AUD $70.00)
  • Matte/Gloss Black UB3 Lid for Micromite LCD BackPack V3 or Pico BackPack using 3.5in screen (PCB, AUD $5.00)
  • Arduino sketch for the Mini WiFi LCD BackPack (Software, Free)
  • Mini WiFi LCD BackPack PCB pattern (PDF download) [24106201] (Free)
Items relevant to "Flexible Digital Lighting Controller, part 1":
  • Flexible Digital Lighting Controller main PCB [16110202] (AUD $20.00)
  • Flexible Digital Lighting Controller Micromite Master PCB [16110201] (AUD $5.00)
  • Flexible Digital Lighting Controller CP2102 Adaptor PCB [16110204] (AUD $2.50)
  • Flexible Digital Lighting Controller LED slave PCB [16110205] (AUD $5.00)
  • PIC16F1705-I/P programmed for the Flexible Digital Lighting Controller [1611020A.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC32MX170F256B-50I/SP programmed for the Flexible Digital Lighting Controller Micromite master [1611020B.hex] (Programmed Microcontroller, AUD $15.00)
  • PIC16F1455-I/P programmed for the Flexible Digital Lighting Controller WS2812 Slave [16110205.HEX] (Programmed Microcontroller, AUD $10.00)
  • Si8751AB 2.5kV isolated Mosfet driver with integral power supply (Component, AUD $10.00)
  • Micromite LCD BackPack V3 complete kit (Component, AUD $75.00)
  • Hard-to-get parts for the Flexible Digital Lighting Controller (Component, AUD $100.00)
  • Flexible Digital Lighting Controller front panel PCB [16110203] (AUD $20.00)
  • Firmware and software for the Fiexible Digital Lighting Controller (Free)
  • Firmware and PC software for the Digital Lighting Controller [1611010A.HEX] (Free)
  • Flexible Digital Lighting Controller mains slave PCB patterns (PDF download) [16110202-3] (Free)
  • Flexible Digital Lighting Controller Master PCB patterns (PDF download) [16110201, 16110204] (Free)
  • Flexible Digital Lighting Controller LED slave PCB pattern (PDF download) [16110205] (Free)
  • Drilling and cutting diagrams for the Flexible Digital Lighting Controller Micromite master (PDF download) (Panel Artwork, Free)
  • Cutting diagram for the Flexible Digital Lighting Controller mains slave rear panel (PDF download) (Panel Artwork, Free)
  • Cutting diagrams and front panel artwork for the Flexible Digital Lighting Controller LED slave (PDF download) (Free)
Articles in this series:
  • Flexible Digital Lighting Controller, part 1 (October 2020)
  • Flexible Digital Lighting Controller, part 1 (October 2020)
  • Flexible Digital Lighting Controller, part 2 (November 2020)
  • Flexible Digital Lighting Controller, part 2 (November 2020)
  • Flexible Digital Lighting Controller, part 3 (December 2020)
  • Flexible Digital Lighting Controller, part 3 (December 2020)
  • Digital Lighting Controller Translator (December 2021)
  • Digital Lighting Controller Translator (December 2021)
Items relevant to "USB SuperCodec – part three":
  • USB SuperCodec PCB [01106201] (AUD $12.50)
  • USB SuperCodec Balanced Input Attenuator add-on PCB [01106202] (AUD $7.50)
  • Parts source grid for the USB SuperCodec (Software, Free)
  • USB SuperCodec PCB pattern (PDF download) [01106201] (Free)
  • USB SuperCodec Balanced Input Attenuator add-on PCB pattern (PDF download) [01106202] (Free)
  • USB SuperCodec front panel artwork (PDF download) (Free)
  • Drilling and cutting diagrams for the USB SuperCodec Balanced Input Attenuator (PDF download) (Panel Artwork, Free)
Articles in this series:
  • USB SuperCodec (August 2020)
  • USB SuperCodec (August 2020)
  • USB SuperCodec – part two (September 2020)
  • USB SuperCodec – part two (September 2020)
  • USB SuperCodec – part three (October 2020)
  • USB SuperCodec – part three (October 2020)
  • Balanced Input Attenuator for the USB SuperCodec (November 2020)
  • Balanced Input Attenuator for the USB SuperCodec (November 2020)
  • Balanced Input Attenuator for the USB SuperCodec, Part 2 (December 2020)
  • Balanced Input Attenuator for the USB SuperCodec, Part 2 (December 2020)
Items relevant to "High Power Ultrasonic Cleaner – part two":
  • High Power Ultrasonic Cleaner main PCB [04105201] (AUD $7.50)
  • High Power Ultrasonic Cleaner front panel PCB [04105202] (AUD $5.00)
  • PIC16F1459-I/P programmed for the High Power Ultrasonic Cleaner [0410520A.HEX] (Programmed Microcontroller, AUD $10.00)
  • One 40kHz 50W ultrasonic transducer (Component, AUD $55.00)
  • ETD29 transformer components (AUD $15.00)
  • Hard-to-get parts for the High Power Ultrasonic Cleaner (Component, AUD $35.00)
  • High Power Ultrasonic Cleaner main PCB patterns (PDF download) [04105201-2] (Free)
  • High Power Ultrasonic Cleaner lid panel artwork & drilling diagram (PDF download) (Free)
Articles in this series:
  • High Power Ultrasonic Cleaner (September 2020)
  • High Power Ultrasonic Cleaner (September 2020)
  • High Power Ultrasonic Cleaner – part two (October 2020)
  • High Power Ultrasonic Cleaner – part two (October 2020)
Articles in this series:
  • The Matrox ALT-256 Graphics Card (October 2020)
  • The Matrox ALT-256 Graphics Card (October 2020)
  • The Vintage Matrox ALT-512 Graphics Card (November 2020)
  • The Vintage Matrox ALT-512 Graphics Card (November 2020)

Purchase a printed copy of this issue for $10.00.

Mini LCD BackPack Besides a colour touchscreen, another very handy feature to have in a microcontroller module is wireless communications. WiFi is probably the most versatile method, as most homes and offices have WiFi networks. Once the micro has Internet access, the list of things you can do with it explodes! This low-cost project uses an ESP8266-based module which is both powerful and inexpensive. By Tim Blythman W hile this BackPack has a so it’s perfect for connecting to 12V vices to access the Internet also puts a plethora of potential uses, lights or a small motor to raise and vast array of useful information within easy reach. some of the most promising lower a blind, for example. But unless you run some extensive are in the area of home automation. This is a rapidly growing field, and wiring through wall cavities or pre- The D1 Mini The D1 Mini is one of the smallest it’s getting much easier to implement. installed conduits, they have little Systems that can be built onto exist- chance of working beyond their im- fully-contained Arduino-compatible microcontroller boards. And being ing WiFi networks are common, and mediate vicinity. Unless you’re installing it in a build- based on the 32-bit ESP8266 microlittle wiring is required. Our D1 Minibased LCD BackPack makes adding a ing under construction, depending on controller, it has a 2.4GHz WiFi radio custom WiFi-enabled touchscreen in- how it was built, running that wiring built-in. can be a trying exercise. The ESP8266 has very quickly beterface quite easy. With WiFi-enabled devices being come a favourite of both hobbyists and For a bit of background, last October, we reviewed Altronics’ range of In- readily available and getting cheaper, manufacturers. It appears in many commercial venta Maker Plates (siliconchip.com. it makes sense to have a panel with a WiFi products, including those used au/Article/12023). These are standard- WiFi interface instead. You could have the user interface in in home automation, such as smart size wallplates that incorporate an Arduino-compatible microcontroller a convenient location and another hid- WiFi globes and smart mains switches. Of the handful of commercial wirealong with user controls and a display. den, WiFi-enabled box near the device They’re great for adding custom fea- to be controlled. The only wiring you less home automation products we’ve need to run then is for power, which tried recently, almost all of them were tures to a home automation system. Being compatible with existing Ar- is usually available in many locations ESP8266-based. This is one of the reasons for the duino boards means that they are easy throughout the premises. The ability for the WiFi-enabled de- continued popularity of the Arduino to program, while the display (either platform, as we note in our a text-based or colour LCD) Arduino Retrospective in and user controls (tactile Features & specifications March (siliconchip.com.au/ switches or touch panel) Display: ...............3.5in 480x320 colour LCD Article/12575). mean that they are intuitive Processor: ...........ESP8266, 160MHz 32-bit The D1 Mini is based on to use. But what these units Flash memory: ....4MB the ESP-12 module, which lack is connectivity. contains an ESP8266 microIt’s intended that they be RAM: ...................80kB controller and a 4MB flash directly wired to some exInterface: .............Touch panel IC. It also incorporates a ternal hardware. The LCD Other features: ....WiFi, remote (OTA) reprogramming, CH340 USB-serial converter, Shield Maker Plate has two prototyping space, 12V power supply a 3.3V regulator and a handbuilt-in (low-voltage) relays, 22 Silicon Chip Australia’s electronics magazine siliconchip.com.au ful of passives. Twelve I/O pins are broken out for external use. We used the D1 Mini in our Clayton’s GPS Time Source (siliconchip. com.au/Article/11039). This connects to the Internet via WiFi to simulate a GPS time source by retrieving accurate time from an NTP (Network Time Protocol) server. This is an example of a simple and useful data source that can be accessed via WiFi. The ESP8266 includes a 32-bit micro running at 80MHz and has 80kB of user-accessible RAM, so it is much more capable than many AVR-based Arduino boards. All the ESP8266 boards we have seen have at least 512kB of flash memory; many have much more. They are perfect for adding both WiFi and a graphical user interface to a small project. In particular, the ample flash memory allows colourful graphics to be embedded and displayed. To help you turn the D1 Mini LCD BackPack into something useful, we’ve created a demonstration program for it which shows off its WiFi, graphical and touch features. The program fetches time and weather data from the Internet; the time comes from an NTP server, while the weather data comes from https:// openweathermap.org/ This data is displayed as a combisiliconchip.com.au nation of text and images. The touch interface supplies a small number of user functions, such as setting the weather location and WiFi network settings. Circuit details The Micromite and its various BackPack incarnations have been extremely popular, not just in their own right, but as a basis for numerous projects. We also published an adaptor in the May 2019 issue to allow Arduino R3-compatible boards to drive 3.5in or 2.8in touchscreen LCDs (siliconchip.com. au/Article/11629) (see above). So we thought it would make sense to use the same principle in designing a board to allow these types of touchscreen to be driven by a D1 Mini. Our demonstration software is designed for the 3.5in display, but the hardware also supports the slightly cheaper 2.8in displays. Given the small difference in price, unless your application can’t fit the 3.5in screen, that is the best option. Fig.1 shows the circuit of our new D1 Mini BackPack. As you might imagine, there isn’t a lot to it. It routes the necessary SPI control signals from the D1 Mini (MOD1) to headers for either type of LCD panel, connected to CON1 and CON1a (mounting pads for CON1a are provided in two different Australia’s electronics magazine locations, to support the two different screen sizes). The hardware SPI signals on the D1 Mini are at pins D5 (SCK), D6 (MISO) and D7 (MOSI). Due to the way that the pins are mapped, these actually correspond to general-purpose I/O (GPIO) pins numbered 14, 12 and 13 respectively. We’ve used the numbers with the ‘D’ prefixes as this is how the D1 Mini is labelled. See Table1 for more information about the curious and slightly confusing numbering used on this board. The CS pin for the LCD is wired to pin D8, and D/C (data/command) is wired to pin D4. Due to the low number of pins available, the RST pin for the LCD is wired to RST pin on the D1 Mini; this works well and saves a pin. The separate CS pin for the touch controller is connected to pin D3. Although the panel includes an SD card socket, we’ve also opted to add a micro SD card socket to our board. There are two reasons for this: the PCB traces to the SD socket on the LCD panel are quite circuitous, which makes the card more susceptible to interference. Also, when the SD card is fitted, it protrudes quite a bit. The micro SD card is smaller, and being attached to the board, is less likely to interfere with the display and October 2020  23 Fig.1: the circuit diagram of the D1 Mini BackPack primarily involves connecting the pins of the D1 Mini module to a 2.8in or 3.5in SPI colour touchscreen via headers CON1 & CON1a. The remainder of the circuit is a basic power supply, a backlight control section, some jumper options, a convenient micro SD card socket and a header which gives you access to the few remaining free pins of the micro. mounting hardware. The CS pins of both the SD and micro SD card sockets are connected to the D1 Mini’s D2 I/O pin. Since the card sockets are nothing more than direct connections, these pins can be shared, as long as there isn’t a card in both sockets at the same time. Indeed, if you don’t need the micro SD card feature, I/O pin (D2) can be reused. We’ve also added a DC jack and a 7805 5V linear regulator. Thus, if 12V is needed for operating lights, motors or relays, a single 12V supply (such as a DC plugpack) can be provided. 24 Silicon Chip The regulator will work with input voltages down to around 7V. When running off a 12V supply, the regulator dissipates around 2W and gets quite warm. You might like to substitute our Switchmode 78xx Replacement from the August 2020 issue (siliconchip. com.au/Article/14533) if you need to draw more current from the 5V rail, or just to reduce the heat output. There are four bypass capacitors on the PCB; two for the 5V regulator and two for the micro SD card socket. We’ve provided PCB pads that suit both 3216 (1206 imperial) SMD or Australia’s electronics magazine 0.2in-pitch through-hole parts. Four sets of jumpers are provided. These can be left off if a feature is not needed, for example, if the I/O pins are needed for another application. JP1 can be used to connect the MISO pin for the LCD (which is not usually needed) to the SPI bus. We have found that some 3.5in displays do not behave correctly; hence, we have not connected these two lines directly. For our demo application, and indeed most applications, it can be simply left open. JP2 can be used to connect the LCD backlight to the 5V rail or I/O pin D0. siliconchip.com.au Construction options There are a few options for you to consider during assembly. MOD1 can be permanently mounted to the PCB siliconchip.com.au 1k 19 18 1 Antenna TX A0 RX D0 D5 LCDMISO D6 D7 MOD1 D1 Mini D1 SPI: D5 D6 D7 LCD CS: D8 D4 D8 LCD D/C: D4 3V3 TOUCH CS: D3 124106201 0260142 RST SD CS: D2 D2 17 16 15 14 13 12 11 10 9 7 6 5 10 F 100nF 10 F D3 G 5V 8 10 F 8 76 5 43 2 1 CON2 3 2 1 12V REG1 7805 No Track Area! USB 4 24106201 RevB JP1 RST CON3 Q1 1 CON1A 1k D1 Mini LCD BackPack D1 CD Q2 D0 5V 3.3V GND TX RX D0 D1 A0 FREE: D0=GPIO16 D1=GPIO5 TX=GPIO 1 47k 1 10k 5V LED TIRQ SDCD 1 JP2 JP3 JP4 CON1 CON4 TIRQ MI MO TS CK MI LD CK MO DC We imagine that most applications will be powered from fixed wiring, so the necessity to turn off the backlight using D0, to save power, is reduced. The centre pin of JP2 goes to a pair of Mosfets and two pull-up/pulldown resistors which provide the high-current drive needed for the backlight LEDs. On the 3.5in display, this can be up to 250mA. An identical arrangement is used on the Micromite BackPacks. For our sample application, JP2 is set to the 5V position. JP3 and JP4 are the remaining connections and go to the touch interrupt pin (TIRQ) and SD card detect switch (SDCD). These can be set to connect either signal to pin D0 or D1. The connection to D0 is brought through a series 1kΩ resistor, as this pin is actively driven high at powerup. This prevents excessive current flowing if the pin D0 is used for the SD card detect function, as the pin is simply shorted to ground by a switch inside the card socket. To help the card-detect function, a 47kΩ pull-up resistor is also provided, as pin D0 does not have an internal pull-up. These two resistors can be changed if you require a different role for this I/O pin. To fill out the substantial space that is left on the PCB that’s sized to suit the touchscreens, we’ve provided a large prototyping area that isn’t shown on the circuit diagram. This consists of 17 rows of eight pads which are arranged to fit a 0.3in DIL packaged device, although it can be used for other types of components. An adjacent row of headers breaks out the spare signals from D1, D0, TX, RX (UART) and the single analog input A0, along with strips of pads to connect to ground (GND), 5V and 3.3V. The PCB itself follows the theme used for both the Micromite BackPack V3 and the 3.5-inch Touchscreen Arduino Adaptor. The PCB can be slightly shortened if using a 2.8in LCD panel. Two sets of mounting holes allow either size of panel to be securely mounted with 3mm machine screws and tapped spacers. Fig.2: use this PCB overlay diagram and the matching photo below as a guide during assembly. There aren’t all that many components, so as long as you take care with the SMDs, you should have it up and running in no time. Pretty much all the components are obscured by the touchscreen once it is fitted. For that reason, you might want to mount external I/O header CON4 on the reverse side. by soldering it directly, or you may like to make it removable by using suitable header sockets. In the latter case, you will probably need to increase the space between the PCB and LCD panel, to give the extra height required when using these headers. We created some spacers for the LCD by soldering a row of male headers to female headers. Of course, you may also be restricted by the space available for mounting if you are planning to fit the unit in a wall cavity or similar. In that case, soldering MOD1 in place is a good idea. We’ll describe the assembly with MOD1 fixed in place, although it will be the last step. If you don’t need a micro SD card socket then CON2 and its two associated capacitors can be left off. But note that they will be much trickier to install later, so it’s best to fit them anyway if there’s any chance you’ll be needing the socket. If you are planning only to use the 2.8in display, then you can cut or snap Australia’s electronics magazine off the right-hand portion of the PCB before starting assembly. But there’s no harm in leaving the PCB whole if you have space. To avoid inhaling fibreglass dust, trim the PCB outdoors and wear a face mask. Carefully score the four PCB traces to prevent them from tearing. With flat-nosed pliers, flex the PCB at the three places it’s joined; it should snap at the naturally weak points. You should also file or sand any rough edges left after snapping; again, be careful to avoid inhaling the dust. Fitting the components The D1 Mini BackPack is built on a double-sided PCB coded 24106201, measuring 99 x 54.5mm. Refer to the photos and PCB overlay diagram (Fig.2) during assembly. There are a few surface-mounted parts to install; we recommend using a fine-tipped, temperature-adjustable soldering iron, solder flux, tweezers, solder braid (wick) and a magnifier of some sort. Fit the micro SD card socket first, as October 2020  25 The completed PCB (left) and married with the Micromite BackPack display (right). The prebuilt WiFi module is the blue PCB at lower left of the main board. it has the closest pins. It has a pair of locating pins, so it is straightforward to get it into position. Apply flux to its pads and place the part, checking that the pins line up. Turn up the iron a little and solder one of the larger mechanical pads to fix it in place. Solder the electrical pins by adding a small amount of solder to the iron, then touch the tip of the iron to each pin. The flux should induce the solder to run off and form a clean fillet. If you make a solder bridge, leave it for now and ensure that the remaining pins are connected. Now go back and remove any bridges using the solder braid (wick). Apply more flux to the bridged pads, then push the braid against the excess solder with the iron. Once it melts, slowly draw the braid away from the pads. With the electrical pins complete, the remaining mechanical pads can be finished. Leaving these until last will make it easier to completely remove the part if this is necessary. Apply more flux if necessary, and don’t forget to turn the iron down to a setting for regular components afterwards. The two SOT-23 package transistors are the smallest parts but have more space around their leads, so fit them next. Check the markings to ensure that Q1 and Q2 are not mixed up. Q1 should be marked with a code that starts with an “X” while Q2 may be marked 72, 702 or possibly something else depending on the manufacturer (these codes are tiny, so you will need a magnifier to read them). A good process for surface mounted components is to apply flux to the PCB pads and load the tip of the iron with a small amount of excess solder. Hold the part in place with tweezers and apply the iron to one lead only. If it is not flat and square, adjust it until it is. Then solder the other leads. Now that the part is secure, the solder fillets can be tidied up. This can be as simple as applying some extra flux to the solder, then touching it with the iron. There are four resistors to be fitted; install these next, ensuring the correct values are used, as per the silkscreen and Fig.2. If you are using through-hole capacitors, then solder and trim as per standard through-hole procedure. Follow the above process for surfacemounted parts. Place the 100nF capacitor first; it will possibly be smaller than the other capacitors and is closest to the micro SD card socket. Repeat with the re- Another view of the way the PCB mates with the Micromite BackPack – it simply plugs into the 14-pin header socket (CON1) at extreme left and the four-pin socket (CON1A) at right. Power is supplied via the DC socket (CON3); alongside is the microSD card socket (CON2) with the USB socket under the WiFi module. 26 Silicon Chip Australia’s electronics magazine maining capacitors, ensuring they are flat and square. Bend the leads on REG1 down 90° about 6mm from the body and place them in the PCB pads. Fit the machine screw and affix the washer and nut; if this is done before soldering, then you can be sure that the regulator is situated correctly. Now solder the leads of REG1 and trim the excess. Jumpers and headers It is easier to fit JP1-JP4 before CON1 and CON1A. Slot JP1 in place and solder one pin. If it is not square, then you can hold the header by the other pin and adjust it while remelting the solder. When you are satisfied that it is flat and flush, solder the other pin. To keep JP2-JP4 aligned, push them all into the female headers that will be used for CON1 and CON1A. As for JP1, solder one pin of the group, then adjust to be level and square before soldering the remaining pins. Then unplug the female headers. If you are planning to use the SD card socket on the LCD, then you will need to fit CON1A, at a location depending on whether you plan to use the 2.8in or 3.5in display. Or you can fit both. Even if you don’t plan to use this SD card socket, the extra headers help to secure the boards mechanically and align them. So it’s a good idea to fit them. Many LCD panels do not have the four-pin header fitted, so this will need to soldered too. The best way we’ve found to fit all the LCD headers is to plug the four-pin (male and female) headers together, then attach the 14way female header to the LCD panel. Rest the LCD panel face-down and place the four-way headers in their pads, with the male pins facing down (matching the orientation of the 14-way header). Then rest the PCB on top and siliconchip.com.au line up the pins with their holes. Solder the pins to the BackPack PCB, then flip the assembly over and solder the male pins into the LCD panel. This process ensures that all the pin headers and sockets are as square as possible, making it easier to change out the LCD panel if necessary; say, if you are swapping from the 3.5in to the 2.8in variant. By the way, you might notice that we’re mounting the touchscreen rotated by 180° in comparison to our previous Micromite BackPack projects. As the LCD and touch drivers are capable of rotating the display in increments of 90°, this does not cause any problems later. Next, solder the DC jack. This may need some extra heat on the iron, and the large pads will need a fair amount of solder. Like the other parts, you can solder one lead, check that the part is orientated correctly, then solder the remaining pins. The final component is MOD1, the Di Mini. Many of these (such as Jaycar’s XC3802) come with an assortment of loose headers. We are assuming that the D1 Mini is fitted with male header pins underneath (in a fashion that would allow it to be used in a breadboard), so if you have different headers fitted, you may need to change them. If you wish to remove the D1 Mini in the future, this will mean that the PCB should be fitted with header sockets. As noted earlier, you may need to find a way to space the LCD panel to account for the space these headers take up. We’ll assume you’re soldering the D1 Mini directly to the PCB, as we have done. Sandwich the male header pins between the MOD1 and the PCB and tack a few pins from the top, then flip over and tack a few pins on the bottom. Check that everything is square and correct. You may also like to check that a USB cable can be plugged in. Even if you don’t plan to power the unit from USB, it’s a good idea to leave it accessible for programming. Once you are happy with this, solder the remaining pins and trim them. For the demonstration software we have written, only one jumper is needed, for JP2, on the 5V side. See the photos and overlay to check the position to fit it. The final step to a functional unit is to fit the LCD panel. Plug the 3.5in LCD into CON1 and CON1A. Installation in, siliconchip.com.au Parts list – Mini WiFi LCD BackPack 1 double-sided PCB coded 24106201, 99 x 54.5mm 1 UB3 Jiffy Box 1 laser-cut lid to suit UB3 Jiffy box for 3.5in screen (optional) [SILICON CHIP Cat SC5083] 1 D1 Mini development board (MOD1) [Jaycar XC3802 or similar] 1 14-way female header socket (CON1) 1 4-way female header socket (CON1A) 2 8-way female header sockets (to make MOD1 pluggable; optional) 1 3.5in SPI LCD touchscreen with ILI9488 controller [eg, SILICON CHIP Cat SC5062] 1 4-way male header (usually comes with the touchscreen) 1 2-way male header (JP1) 3 3-way male headers (JP2,JP3,JP4) 4 jumper shunts (JP1-JP4) 1 SMD micro SD card socket (CON2) 1 PCB-mount DC jack socket, ID to suit plugpack (usually 2.1 or 2.5mm) (CON3) 1 M3 x 10mm panhead machine screw, hex nut and washer (for REG1) 8 M3 x 6mm panhead machine screws 4 12mm-long M3 tapped spacers (or longer if mounting MOD1 on sockets) Semiconductors 1 7805 5V 1A linear voltage regulator, TO-220 (REG1) A complete kit of parts (as 1 IRLML2244TRPBF P-channel Mosfet, SOT-23 (Q1) specified here) is available from the SILICON CHIP ONLINE 1 2N7002 N-channel MOSFET, SOT-23 (Q2) SHOP – Cat SC5503 <at> $70.00 Capacitors 3 10µF 16V X7R SMD ceramic, 3216 (1206) size or through-hole equivalent 1 100nF 50V X7R SMD ceramic, 3216 (1206) size or through-hole equivalent Resistors (all SMD 3216/1206 size, 1%) 1 47kW (Code 473/4702 ) 1 10kW (Code 103/1002) say, a wall cavity, will require further steps, but these will be specific to your circumstances. We’ll look at mounting options once the unit is operational. To secure the LCD panel, attach the tapped spacers to the front of the PCB with machine screws from behind, then slot the LCD panel into the headers and secure it with the four remaining machine screws from the front. Software To make use of our software, you’ll need the Arduino IDE and the ESP8266 Board file; we’ll assume you’re familiar with the IDE (Integrated Development Environment). It can be downloaded from siliconchip.com.au/link/aatq We’re using version 1.8.5; you should use this or a later version. Installing the ESP8266 add-on for the Arduino IDE requires adding the URL http://arduino.esp8266.com/stable/ package_esp8266com_index.json to the Additional Board Manager list (found under File > Preferences). With the URL added, the ESP8266 add-on can be installed by opening the Boards Manager (Tools > Board > Board Manager), searching for ESP8266 and clicking “Install”. This Australia’s electronics magazine 2 1kW (Code 102/1001) can take a while as it is a complete toolchain and board support files. You may also need USB-serial drivers for the CH340 used on the D1 Mini. We used drivers from siliconchip. com.au/link/ab2g for our WeatherDuino in 2015 (siliconchip.com.au/ Article/8457). The D1 Mini corresponds to the “LOLIN (WEMOS) D1 R2 & Mini” in the Arduino Tools > Board Menu. Ensure that you have selected this and also selected the correct serial port. Unzip our sketch to your Arduino sketch folder and open it with the IDE. There are no external libraries needed; the WiFi libraries used are included with the ESP8266 board download. There are some LCD-specific library files that we have included in the sketch folder. As with any project which uses WiFi, there needs to be a means to select a WiFi network and enter the network password. Many ESP8266 projects simply hard-code this into the sketch itself, but that’s a bit crude. Our sketch is a bit smarter. If it detects that no WiFi network has been set, it scans for nearby networks and presents a list for the user to choose October 2020  27 Details of this are provided at https:// openweathermap.org/price In any case, the free account and API key are sufficient for us to get a modest amount of data updated at a useful rate. This needs to be set in the sketch before upload. Look for the line defining the OWM_API_KEY in the main sketch file and change it to the key you’ve been given. It should be surrounded by quote marks. Now we can upload the sketch to the D1 Mini, by pressing the Upload button on the IDE. The compilation and upload process may take a minute or two, after which the LCD should clear. The sketch Fig.3: if all goes well with registration, you will get an email from openweathermap. org with your API key (we’ve redacted ours so you can’t steal it!). Copy this into the Arduino sketch at the OWM_API_KEY define between the quote marks. Keep your API key secret, as anyone that has it can use your allowance. from. The user can then enter the password; the settings are saved to nonvolatile storage. The result is a much friendlier end-product. Thus, no WiFi settings in the sketch need to be changed before uploading; these can all be set later. your OpenWeatherMap account. The free API key allows a limited number of accesses per day, with paid accounts allowing more frequent access to more detailed data. A lot of the sketch is dedicated to providing control of the LCD and providing a useful user interface, including a GUI routine which displays and monitors things such as the buttons and on-screen keyboard. The sketch uses two sources of Internet data to update its display. The first of these is NTP (Network Time Protocol) data for the current time. Since NTP only provides the time as UTC (similar to GMT), a timezone offset is needed to calculate and display the actual local time. Fortunately, the OpenWeatherMap data includes timezone information. It is also used to show things such as the current and forecast temperatures and graphics representing these. Sunrise and sunset times are shown too. The time is pulled from the NTP OpenWeatherMap One feature of our demo program is to retrieve weather information and display it on the LCD screen. This data comes from the openweathermap.org website. Although it is free to use this data, an account is required. This is used to limit free access, and also to provide access to more data for paid accounts. An email address is needed to set up an account; open siliconchip.com. au/link/ab2h in a web browser and enter your details. An email will be sent with a confirmation link; after clicking this, you’ll receive a second email. This second email contains an API key, which is a hexadecimal code our sketch needs to access OpenWeatherMap data (see Fig.3). There is an option to generate further API keys from 28 Silicon Chip Screen1: the main page of our demo application shows a swathe of information from OpenWeatherMap. We tried to use a PNG decoding library to display the icons, but it still had a fairly high dynamic memory requirement and did not work. So instead, the icons are stored in the flash memory. Australia’s electronics magazine siliconchip.com.au server hourly, with the D1 Mini’s internal timer being used to keep track of time in between. The weather data is updated every 10 minutes. Operation After the sketch is uploaded, you can open the serial monitor to get debugging information. On the LCD, a message “Scanning...” will appear, after which a list of WiFi network names (SSIDs) will appear. Tapping on one will result in a prompt to enter the password using an onscreen keyboard. This will be followed by a prompt to enter a location. This is the location used by the sketch to query OpenWeatherMap. We found a simple “Sydney” was sufficient to get accurate data for our location in Australia, but if, say, you lived in Sydney, Nova Scotia, you might need to be more specific. Entering “Melbourne” displayed data more consistent with Melbourne, Florida than Melbourne, Victoria. “Melbourne,AU” appeared to provide the correct data. If you aren’t sure, open the Serial Monitor and watch the displayed info; a lot of data is output for debugging. The data retrieved from OpenWeatherMap will appear as a single, long line. Information such as the latitude, longitude or country can be used to check that you have the correct location. User information (such as WiFi network and location) is saved in nonvolatile storage. The ESP8266 doesn’t D1 Pin Comments pin name number D0 16 Initially high D1 5 Default Arduino I2C SCL D2 4 Default Arduino I2C SDA D3 0 Has pull-up resistor to set the run mode at reset. D4 2 Has pull-up resistor to set the run mode at reset. D5 14 Hardware SPI SCK D6 12 Hardware SPI MISO D7 13 Hardware SPI MOSI D8 15 Has pull-down resistor to set the run mode at reset. TX 1 Can be used as GPIO RX 3 Can be used as GPIO. A0 - Analog input with a nominal full-scale value of 3.2V Table 1: D1 Mini pin numbering have dedicated EEPROM, but the Arduino IDE provides EEPROM emulation by using a small amount of flash storage. Thus these settings are retained during power-down and are loaded at power-up. Once set up, the screen usually displays complete information within around ten seconds of power being applied. Mounting If you simply wish to use the unit in a freestanding enclosure, then mounting is much the same as for the Micromite LCD BackPack V3, and you can use the lid designed for that project to mount it into a UB3 Jiffy box. You may like to provide a DC input jack on flying leads to be mounted on the case, if the existing cable entry doesn’t suit your application. Like the Altronics Inventa Plates, we expect some people will install these into a wall cavity. This could be as simple as using the acrylic piece noted above as a bezel. Another simple way to do this is to make a square cutout in a blank wall plate, as well as four round 3mm holes for the screws. The D1 Mini BackPack can then mount similarly to other BackPacks, using a screw in each corner to secure it. You could use the blank PCB as a template for the holes; this may be easier than a populated PCB or the LCD with its protruding headers. If you are mounting it to a wall which has mains wiring behind, consider adding a spacer block to keep it separate. This will also reduce the size of the hole which needs to be made in the wall. Beyond the demo Screen2: the WiFi setup page provides a similar interface to many ‘smart’ devices. Nearby networks are scanned and listed; the user simply has to enter the appropriate password. siliconchip.com.au Australia’s electronics magazine Our software provides a useful function, but it really shows only a tiny fraction of what can be done with this hardware. Many other useful features can be added relatively easily. With the popularity of the Arduino IDE and ESP8266, there are numerous examples of what can be done online. This includes tapping into online resources to display data, plus protocols to interact with other devices within your LAN, or even via a VPN. Table 1 shows the D1 Mini’s pin configuration, which should be very helpful if you plan to modify the code. Unlike AVR based boards, many of the pins on the D1 Mini have individual characteristics, meaning they are not entirely interchangeable. October 2020  29 Screen3: the benefits of a large touchscreen come to the fore on the password page. Here we can use the ample space to implement a full QWERTY keyboard that allows all ASCII characters to be entered. Most keys are at familiar locations; some have been moved for compactness. A similar screen is used to enter the weather location. We have therefore carefully chosen the pins used for the D1 Mini LCD BackPack. Over-the-air programming One of the libraries within the Arduino ESP8266 board profile provides a very useful feature, especially if you plan to mount the unit in a wall permanently. ‘Over The Air’ (OTA) programming means that sketches can be uploaded to the unit via WiFi. The sketch needs to have the OTA library included, so the first sketch upload must be done through the serial port, but as long as subsequent code uploads include the OTA library, OTA can continue to be used. Some limitations exist; for example, the ESP8266 must have enough space to hold the currently running sketch alongside the new sketch. This effectively cuts the available sketch flash space in half. The mechanism means that the ESP8266 must be connected to the same WiFi network as the user; if it has lost its WiFi credentials, then OTA will not work. Being programmable over WiFi also means that someone else with WiFi access could reprogram the unit, although a basic password feature is provided. Still, it’s a handy feature to have, especially if you need to test the unit in situ, or if it’s difficult to connect a USB cable. 30 Silicon Chip There are example sketches (under the ArduinoOTA heading) and more information can be found at siliconchip.com.au/link/ab2i Summary While the demonstration program shown here is quite useful in its own right, it’s intended to be a starting point for other projects. For example, many public transport operators make their data available. So it would be possible to display when the next bus is scheduled to leave your nearest stop, or even when it is coming down to the minute if realtime data is available. While many of these services re- quire user registration, there is a freely available service for Melbourne tram information. It is documented at siliconchip.com.au/link/ab2j This project also provides the perfect means of controlling other devices. An increasing number of home automation devices are becoming available, and many of them are suitable for integration in such a system. Even in the case that this can’t be done directly, there are alternative open-source firmwares which make this possible. In particular, many of the ESP8266based smart globes and switches can be modified by loading the open-source Tasmota firmware (https://tasmota. github.io/docs/). This software and many others use the MQTT protocol; there are numerous MQTT libraries for the ESP8266, so interfacing to this protocol is not hard. Because it uses a publish/subscribe model, multiple devices can act on the same information. There are also mobile phone applications which can be set up to provide an MQTT dashboard, for example, allowing MQTT data to be displayed or MQTT messages to be sent at the push of a button. The big opportunity here is to automate actions based on the information that the D1 Mini can access. For example, turning on lights at sunset or turning off the heater if the outside temperature increases. While the D1 Mini BackPack would only be a very small part of such a project, it is clearly a useful device in its SC own right. Fitting into a UB3 Jiffy box: because it uses the same LCD panel as the 3.5in Micromite BackPack, it can be mounted in a UB3 Jiffy Box using the same laser-cut acrylic lid (our Cat SC5083). This is the perfect way to mount and protect the unit if it needs to be installed in a wall cavity. Australia’s electronics magazine siliconchip.com.au