Silicon ChipMini WiFi LCD BackPack - October 2021 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions: PicoLog Cloud
  5. Back Issues: PICOLOG
  6. Publisher's Letter
  7. Feature: The Fox Report by Barry Fox
  8. Feature: Techno Talk by Mark Nelson
  9. Feature: Net Work by Alan Winstanley
  10. Project: Mini WiFi LCD BackPack by Tim Blythman
  11. Project: USB Supercodec by Phil Prosser
  12. Project: Ultrasonic High Power Cleaner by John Clarke
  13. Project: Colour Maximite 2 (Generation 2) by Phil Boyce , Geoff Graham and Peter Mather
  14. Feature: AUDIO OUT by Jake Rothman
  15. Feature: Max’s Cool Beans by Max the Magnificent
  16. Feature: Circuit Surgery by Ian Bell
  17. Feature: IoT Cricket by Khairul Alam
  18. Feature: KickStart by Mike Tooley
  19. Advertising Index
  20. PCB Order Form

This is only a preview of the October 2021 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
Mini LCD BackPack As well as a colour touchscreen, another very handy feature to have in a microcontroller module is wireless communications. Wi-Fi is probably the most versatile method, as most homes and offices have Wi-Fi 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. W By Tim Blythman hile this BackPack has a plethora of potential uses, some of the most promising are in the area of home automation. This is a rapidly growing field, and it’s getting much easier to implement. Systems that can be built onto existing Wi-Fi networks are common, and little wiring is required. Our D1 Minibased LCD BackPack makes adding a custom Wi-Fi-enabled touchscreen interface quite easy. CH340 USB-serial converter, a 3.3V regulator and a handful of passives. Twelve I/O pins are broken out for external use. We used the D1 Mini in our Clayton’s GPS Time Source (PE, April 2019). This connects to the Internet via Wi-Fi 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 Wi-Fi. 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 GUI (graphical user interface) to a small project. In particular, the ample Flash memory allows colourful graphics to be embedded and displayed on the screen. To help you turn the D1 Mini LCD BackPack into something useful, we’ve created a demonstration program for it which shows off its Wi-Fi, graphical and touch features. The program fetches accurate 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 combination of text and images. The touch interface supplies a small number of user functions, such as setting the weather location and Wi-Fi network settings. The D1 Mini Circuit details The D1 Mini is one of the smallest The Micromite and its various Backfully-contained Arduino-compatible Pack incarnations have been extremely microcontroller boards. And since it popular, not just in their own right, is based on the 32-bit ESP8266 mibut as a basis for numerous projects. crocontroller, it has a 2.4GHz Wi-Fi We also published an adaptor to alradio built-in. low Arduino R3-compatible boards to The ESP8266 has very quickly drive 3.5-inch or 2.8-inch touchscreen become a favourite of both hobbyists LCDs (see PE, June 2020). and manufacturers. It appears in many We thought it would make sense to commercial Wi-Fi products, including use the same principle in designing a those used in home automation, such board to allow these types of touchas smart Wi-Fi globes (lightbulbs) and screen to be driven by a D1 Mini. Our smart mains switches. demonstration software is designed Of the handful of commercial for the 3.5-inch display, but wireless home automathe hardware also supports tion products we’ve tried Features and specifications the smaller and slightly recently, almost all of them Display ................3.5-inch 480x320 colour LCD cheaper 2.8-inch displays. were ESP8266-based. Given the small difference This is one of the reasons Processor............ESP8266, 160MHz 32-bit in price, unless your applifor the continued popularFlash memory .....4MB cation can’t fit the 3.5-inch ity of the Arduino platform. RAM ....................80kB screen, that is the best option. The D1 Mini is based on Interface ..............Touch panel Fig.1 shows the circuit of the ESP-12 module, which Other features .....Wi-Fi, remote (OTA) reprogramming, our new D1 Mini BackPack. contains an ESP8266 microprototyping space, 12V power supply As you might imagine, there controller and a 4MB Flash isn’t a lot to it. It routes the IC. It also incorporates a 16 Practical Electronics | October | 2021 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 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 that are 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 Table 1 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 when attached to the board is less likely to interfere with the display and 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. Practical Electronics | October | 2021 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. 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 2021 issue 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 0.2-inch-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.5-inch 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. 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/pull-down resistors that provide the high-current drive needed for the backlight LEDs. On the 3.5-inch 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. 17 D1 Mini BackPack Fig.1: the circuit diagram of the D1 Mini BackPack primarily involves connecting the pins of the D1 Mini module to a 2.8-inch or 3.5-inch SPI colour touchscreen via headers CON1 and CON1a. The rest 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. This consists of 17 rows of eight pads which are arranged to fit a 0.3-inch 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 analogue 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 (see PE, August 2020)and the 3.5inch 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. 18 Construction options There are a few options for you to consider during assembly. MOD1 can be permanently mounted to the PCB 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.8-inch display, then you can cut or snap 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 Practical Electronics | October | 2021 Practical Electronics | October | 2021 1k 1k 1 Antenna RX D0 D5 LCDMISO D6 D7 MOD1 D1 Mini SPI: D5 D6 D7 LCD CS: D8 D8 LCD D/C: D4 3V3 TOUCH CS: D3 124106201 0260142 SD CS: D2 USB D1 D2 17 16 15 14 13 12 11 10 9 G 5V 7 6 5 10 F 100nF 10 F D3 D4 8 10 F 8 76 5 43 2 1 3 2 1 12V REG1 7805 No Track Area! CON2 4 24106201 RevB TX A0 CON3 JP1 RST CD Q1 1 CON1A D1 5V LED TIRQ SDCD Q2 D0 FREE: D0=GPIO16 D1=GPIO5 TX=GPIO 1 5V 3.3V GND TX RX D0 D1 A0 19 18 D1 Mini LCD BackPack 1 10k 47k JP2 JP3 JP4 CON1 1 RST Fitting the components The D1 Mini BackPack is built on a double-sided PCB coded 24106201, measuring 99 x 54.5mm and available from the PE PCB Service. 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 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. CON4 TIRQ MI MO TS CK MI LD CK MO DC 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. 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. 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 remaining 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.8-inch or 3.5-inch 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 line up the pins with their holes. Solder 19 The completed PCB (left) and married with the Micromite BackPack display (right). The prebuilt Wi-Fi module is the blue PCB at lower left of the main board. 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.5-inch to the 2.8-inch 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 oriented 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 did. 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.5-inch LCD into CON1 and CON1A. Installation in, say, a box or wall cavity, will require further steps, but these will be specific to your project. 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: www.arduino.cc/en/software We’re using version 1.8.5; you should use this or a later version. 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 Wi-Fi module. 20 Installing the ESP8266 add-on for the Arduino IDE requires adding the following URL to the Additional Board Manager list (found under File > Preferences): http://arduino.esp8266.com/stable/ package_esp8266com_index.json 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 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. (Note that we used the drivers from here for a previous project: https://bit. ly/pe-oct21-ch340.) 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 Wi-Fi 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 Wi-Fi 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 Wi-Fi network has been set, it scans for nearby networks and presents a list for the user to choose from. The user can then enter the password; the settings are saved to non-volatile storage. The result is a much friendlier end-product. Thus, no Wi-Fi settings in the sketch need to be changed before uploading; these can all be set later. OpenWeatherMap One feature of our demo program is to retrieve weather information and Practical Electronics | October | 2021 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; just enter your details here: https://home.openweathermap.org/ users/sign_up and then 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 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. 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 A lot of the sketch is dedicated to providing control of the LCD and 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 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. Practical Electronics | October | 2021 Parts list – Mini Wi-Fi LCD BackPack 1 double-sided PCB coded 24106201, 99 x 54.5mm available from the PE PCB Service 1 UB3 Jiffy Box 1 laser-cut lid to suit UB3 Jiffy box for 3.5-inch screen (optional) coded MMBP-LID-35 available from the PE PCB Service 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.5-inch 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) See PE August 2020 for details of building the V3 Micromite BackPack. The V3 PCB is 4 jumper shunts (JP1-JP4) 1 SMD micro SD card socket (CON2) available from the PE PCB Sevice. 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) 1 IRLML2244TRPBF P-channel MOSFET, SOT-23 (Q1) 1 2N7002 N-channel MOSFET, SOT-23 (Q2) 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 47kΩ (Code 473/4702 ) 1 10kΩ (Code 103/1002) On the LCD, a message ‘Scanning...’ will appear, after which a list of Wi-Fi 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, 2 1kΩ (Code 102/1001) 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 Wi-Fi network and location) is saved in non-volatile storage. The ESP8266 doesn’t have dedicated EEPROM, but Fitting into a UB3 Jiffy box: since it uses the same LCD panel as the 3.5-inch Micromite BackPack, it can be mounted in a UB3 Jiffy Box using the same laser-cut acrylic lid (available from the PE PCB Service). This is the perfect way to mount and protect the unit if installed in a wall cavity. 21 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. Therefore, we chose carefully the pins used for the D1 Mini LCD BackPack. Fig.3: if all goes well with registration, you’ll 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 secure, as anyone that has it can use your allowance. 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 22 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 Our software provides a useful function, but it really shows only a tiny 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 Wi-Fi. 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 Wi-Fi network as the user; if it has lost its Wi-Fi credentials, then OTA will not work. 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. Practical Electronics | October | 2021 Being programmable over Wi-Fi also means that someone else with Wi-Fi 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. There are example sketches (under the ArduinoOTA heading) and more information can be found here: https://bit.ly/pe-oct21-ota 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 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 – Analogue input with a nominal full-scale value of 3.2V Table 1: D1 Mini pin numbering leave your nearest stop, or even when it is coming down to the minute if realtime data is available. Screen2: the Wi-Fi 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. 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. Practical Electronics | October | 2021 While many of these services require user registration, there is a freely available service for Melbourne tram information. It is documented at: https://bit. ly/pe-oct21-tram 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 opensource Tasmota firmware, go to: https://tasmota.github.io/docs/ This software and many others use the MQTT protocol; fortunately, 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 own right. Reproduced by arrangement with SILICON CHIP magazine 2021. www.siliconchip.com.au 23