Silicon ChipMake it with Micromite - August 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: Ol’ Timer II by Tim Blythman
  11. Project: Low-cost, Wideband Digital RF Power Meter by Jim Rowe
  12. Project: Switchmode Replacement for 78xx regulators by Tim Blythman
  13. Feature: KickStart by Mike Tooley
  14. Feature: Microphone Preamplifier (for Vocoder) – Part 4 by Jake Rothman
  15. Feature: Make it with Micromite by Phil Boyce
  16. Feature: Circuit Surgery by Jake Rothman
  17. Feature: Max’s Cool Beans by Max the Magnificent
  18. PCB Order Form
  19. Advertising Index

This is only a preview of the August 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)
Make it with Micromite Phil Boyce – hands on with the mighty PIC-powered, BASIC microcontroller Part 31: Using the Cricket IoT module with a Micromite I n the June 2021 edition of PE 54 The compact, low-power Cricket IoT module – how easy is it to use with a Micromite? minor limitations that I ran into (and in all fairness, these were probably due to my limited experience with the Cricket after just a couple of hours of tinkering!). At this stage, it was only natural for me to ponder the idea of hooking up a Micromite to the Cricket, and see what else could be achieved. Hence, the topic this month is to explore that idea further. I hope it will spark some imaginative ideas as to how you could use a Cricket in your own Micromite projects. Building Blocks is pressed, the code would trigger the Cricket to send me an email notification. The only decision I had to make to achieve this was choosing a web service to preconfigure the Cricket, enabling it to send emails. Due to its popularity and array of capabilities, I chose the IFTTT service: https://ifttt.com You are probably thinking that there is nothing amazing about using a button, let alone wondering why I’m bothering to even use a Micromite for such a simple scenario (after all, you could just connect the button directly to the Cricket). The + B A T T A A A 3 V3 B a ttery + C onf i g b utton A A A The thought process I had was really simple: use a Micromite to do the logical processing of any input device(s), and whenever required, trigger the Cricket to send the relevant data to its pre-configured web service. My initial aim was to use a tactile button, connect it to a Micromite, and write a short MMBASIC program so that whenever the button B a ttery there was an interesting article about the Internet of Things (IoT); more specifically, an introduction to the lowcost, yet versatile Cricket IoT module (we’ll refer to it as just the ‘Cricket’ hereafter). The article explained that the Cricket makes it easy to get started with IoT, enabling the complete beginner to explore many possibilities of this exciting technology. I immediately ordered one so that I could start tinkering, and more importantly, to see if it lived up to the claims. I was not disappointed. Within minutes of it dropping through my letterbox, I had the temperature in my garden being logged to the Internet. Having successfully worked through the whole of Md. Khairul Alam’s PE article, it was very clear that the main benefits of the Cricket are its ultra-low power consumption and ease of configuration so that it can send data to a third-party web service such as ThingSpeak, or the very popular IFTTT (If This Then That). These two benefits really do make the Cricket an ideal solution for creating a battery-powered IoT sensor that ‘wakes-up’ at regular intervals thanks to the onboard real-time clock (RTC), read the status of up to three input pins (and/ or measure the local temperature, as well as the current battery voltage), and then transmit this data to an Internet-based service via your local Wi-Fi network. Or to put it simply, by using a Cricket, it is extremely easy to make a battery powered sensor that transmits data to ‘the Internet’. I began thinking about other potential applications for the Cricket, for example, to connect up a magnetic door sensor (ie, reed switch) to one of its digital input pins so that it could then send an alert to my smartphone whenever the door was opened. This concept was quickly achieved by using a specific pin labelled ‘Wake_Up’; however, there were a few 4 W A K E _ U P 5 I0 2 / A D C 6 I0 3 0V G ND Sta tus LE D Things On Edge CRICKET Fig.1. The Cricket has six pins, four of which are used when it’s connected to the Micromite. In addition, a button is connected between Micromite pin 3 and 0V (not shown here). Practical Electronics | August | 2021 point is, I want to demonstrate these ‘building blocks’ working together – and once they are, you can then simply replace the button (ie, the input), and the email notification (ie, the output) with literally any alternative combinations that your imagination allows. To expand on this a little, consider being able to use a collection of different sensor modules (that could be any mix of I2C, SPI and UART hardware – something the Cricket can’t currently handle). Whenever a particular condition occurs with the data from the sensors, you can then trigger various outputs such as a pop-up notification to your smartphone, as well as turn on various lights (or any other mainspowered device) in your home. All this becomes possible by using the combination of just three building-blocks: the Micromite, the Cricket, and in this case, the IFTTT service. But before we get carried away, lets return to using a button to trigger an email. Cricket pins Referring to Fig 1, you can see that there are six pins on the Cricket. Their labels are self-explanatory, but to avoid any doubt, these six pins have the following functionality: 1. BATT This is the battery power input (1V to 3.5V), typically one or two AAA/AA. 2. 3V3 This is an output. It can power external hardware while the Cricket is ‘awake’. 3. WAKE_UP A high on this input will wake the module (if sleeping). Note: this pin can also be used as a digital input (IO1). 4. IO2/ADC Digital or analogue input. 5. IO3 Digital input. 6. GND Ground supply. The Cricket has been specifically designed to be powered from a battery. One (or ideally two) batteries can be used. Note that if you use a voltage regulator to supply power to the Cricket then it will behave erratically. Therefore, we will not be using the Micromite 3.3V output to power the Cricket. Fig.1 shows two 1.5V batteries in series – positive to the Cricket’s BATT pin and negative to the Cricket’s GND pin and the Micromite’s 0V line. Connecting the Cricket to the MKC We will make four connections to the Cricket from the MKC. Note that we could have connected them together with just two wires (0V, and Wake_ Up); however, we will also connect the Micromite to the Cricket’s IO2 and IO3 pins for extra functionality. Practical Electronics | August | 2021 Referring to Fig.1 (and as explained above), power is supplied from two 1.5V batteries connected in series; connected to the BATT and GND pins on the Cricket. Remember: the 3V3 pin on the Cricket is not a power input, it is a power output. Do not feed power into this pin – you will permanently damage the Cricket. You have been warned! Micromite pin 4 (which will be set to an output) is connected to the Wake_Up pin. This will provide the capability to wake the Cricket from ‘sleep’ by setting pin 4 high in our program code (with the command P I N ( 4 ) = 1 ), or more specifically, by pulsing pin 4 high (with the command PULSE 4,10). Pin 5 and Pin 6 on the Micromite (also set as outputs) are connected to the Cricket’s two input pins, IO2 and IO3 respectively. These are optional, but they will be used to allow our program code to apply a logic level (0 or 1) so that these logic-level states can also be sent to the Internet. This arrangement effectively provides us with four possible combinations (00, 01, 10, and 11). In addition to hooking up the Cricket, we also need to connect a button to the Micromite (the one that will trigger the email). If you don’t have a button readily available, then simply substitute it with a switch. Whatever you use, it should be connected between 0V and any I/O pin (I chose pin 3). Before writing any MMBASIC code, we first need to register for an IFTTT account (and also configure it to send an email), and afterwards we will have to set up the Cricket to connect it to our local Wi-Fi network and configure it to talk to IFTTT. Let’s work through the first of these steps. IFTTT You can register for an IFTTT at: https://ifttt.com. If you already have an IFTTT account, then simply log in; otherwise complete the straightforward registration process using a valid email address. When you have logged into your account, you should see a screen similar to that shown in Fig.2a (if not, then click on the ‘My Applets’ link). Next, we need to configure an IFTTT applet to send an email. To do this, work through the following 18 steps. (Note: I have taken screen grabs to explain these steps, but there are 21 of them and there simply isn’t room to show all the steps here. So, where there is reference to Fig.2 in plain text, I have included the screenshot in this article – all other references to Fig.2, in italics, are in a separate document that you can download from the August 2021 page of the PE website.) Fig.2m. Configuring IFTTT to send an email with the subject line ‘Message from Cricket’. 1. Click the ‘Create’ button (black button, top-right corner) and you will see a screen similar to Fig.2b. 2. Click the ‘Add’ button next to ‘If This’ (Fig.2b). 3. In the ‘Search services’ box (Fig.2c), start typing webhooks. As you start typing, you will see the number of icons reduce. 4. Click the blue ‘Webhooks’ icon (Fig.2d) 5. Click the blue ‘Receive a web request’ block (Fig.2e) 6. In the ‘Event Name’ input box (Fig.2f), type button_pressed 7. Press the ‘Create trigger’ button (Fig.2g) 8. Click the ‘Add’ button next to ‘Then That’ (Fig.2h) 9. In the ‘Search services’ box (Fig.2i), start typing email until you see the ‘Email’ icon (Fig.2j) 10. Ensure you click on the ‘Email’ icon – not any other icon that may be visible (Fig.2j). 11. Click the blue ‘Send me an email’ block (Fig.2k). 12. In the ‘Subject’ input box (Fig.2l), clear the existing text, and then type Message from Cricket (see Fig.2m). 13. In the ‘Body’ input box, clear the existing text, and carefully type the text below. Bold text is entered by selecting the ‘Add ingredient’ 55 to power the Cricket (ideally, using a pair of AAA/AA batteries – as shown in Fig.1) and then press the Config button for approximately five seconds. Once the blue LED is flashing, the Cricket is operating as a wireless hotspot. Use your computer to search for local Wi-Fi networks and connect to the Cricket by selecting toe_device (see Fig.3, repeated from the PE June 2021 Cricket IoT article, Fig.15). No password is required to connect, and you will automatically be linked to the Cricket. The first time you do this you will be prompted to enter your local Wi-Fi SSID and password; and once entered, click the ’Connect‘ button. If the SSID and password were entered correctly you can now click on the ‘Config’ tab (see Fig.4) and carefully enter the following Cricket settings: Fig.2s. Choosing ‘My Services’ in IFTTT . button. (Refer to Fig.2m): The button was PRESSED on:<br> OccurredAt<br> (Temperature = Value1'C)<br> <br> Status of IO2:IO3 = Value2: Value3<br> 14. Click the ‘Update action’ button (Fig.2m). 15. Click the ‘Continue’ button (Fig.2n). 16. Click the ‘Finish’ button (Fig.2o). 17. Click the ‘Edit title’ link (Fig.2p), and change it to the shorter title, ‘Micromite Button Pressed’ (Fig.2q). 18. Click ‘My Applets’ link to see it in your list of Applets (Fig.2r). CONNECTIVITY Type url payload content-type HTTP_POST *** see text below *** {"value1":"#temp","value2": "#io2","value3":"#io3"} application/json RTC BATTERY MONITOR TEMPERATURE SENSOR averaging avg num of points off off on on 8 Finally, you will need to obtain the HTTP address (created by IFTTT) which will be used to configure the Cricket. To obtain this, click on your user icon (top right corner next to the black ‘Create’ button), and select ‘My Services’ from the drop-down menu (Fig.2s). Then scroll down the list and click on ‘Webhooks’ (probably the last item in the list). This will result in Fig.2t, where you click on the ‘Documentation’ button (top-right corner). You will now see a screen similar to Fig.2u. Copy the HTTPS address shown under the heading ‘To trigger an Event’ (highlighted in red in Fig.2u) and paste it into something like Notepad (this information will be used shortly). That concludes the IFTTT setup; next we need to configure the Cricket. IO1 force update IO2 IO3 on on (DIGITAL_IN) on (DIGITAL_IN) Configuring the Cricket The configuration for the URL should end up looking something like: http://maker.ifttt.com/trigger/button_pressed/with/ key/******************** (* replaced with your API key). Once the above configuration has been entered correctly into the Cricket’s ‘Config‘ tab, ensure that the device status shows as UPDATED (this is in yellow under the STATUS heading, and can be seen in the top of Fig.4). Then press the ‘power’ icon located in the topright corner of Fig.4. This will save all elements of the configuration data into the Cricket. This concludes all the settings that are required. You can now download the CricketDemo.txt program from the August 2021 page of the PE website and load it into the Micromite so that we can finally test that everything works correctly. To configure the Cricket, it’s worth referring to PE June 2021 (p.47) and looking at Steps 6-8. Essentially, you will need Fig.2u. Copy this HTTPS address from IFTTT. 56 WI-FI enable caching on CONFIG OTA off *** Regarding the URL, paste the HTTPS address obtained from IFTTT (and which we copied above into Notepad, or similar). Important: there are two things that must be edited: • Change https to: http • Change {event} to: button_pressed Practical Electronics | August | 2021 Fig.3. Select toe_device to connect your computer to the Cricket via Wi-Fi. Program code With the CricketDemo.txt program loaded into the Micromite, RUN the program and then press the button connected to Pin 3. Upon pressing the button, you should see the blue status LED (on the Cricket) flash a few times. This indicates that the Cricket has woken and is sending data to the internet. If you do not see the blue status LED flash when the button is pressed, re-check that your button is Fig.5. The content of the received notification email (as viewed on a smartphone). The layout is as configured in the IFTTT applet, and the data values are passed from the Cricket (via the Internet) to IFTTT. As well as seeing the status of IO2 and IO3, the date and time of the button press is also shown, along with the temperature (yes, it really was 30°C). Practical Electronics | August | 2021 Fig.4. The Cricket Config screen. the button is pressed. And how about connected correctly to pin 3, and also replacing the button with a distance that the CricketDemo.txt program is module instead, and trigger the output running. Within around 10 seconds of (lights, email, mains smart-plug… ) pressing the button (and the status LED based on the distance detected. flashing), you should receive an email I hope this has inspired you to explore to the email address used when setting further, so until next month, have FUN up your IFTTT account. If viewing the playing Cricket! email on a smartphone, it will look something similar to that shown in Fig.5. If no email is received (but the Cricket’s Questions? Please email Phil at: blue status LED did flash), then you will contactus<at>micromite.org need to re-check the configurations in both the Cricket, and also your IFTTT Micromite Button Pressed applet. If everything has worked for you as expected, great! If not, and you’re struggling to get it working correctly, then drop me an email and I will try to help. It’s well worth looking at the program code and making changes to alter the values JTAG Connector Plugs Directly into PCB!! of IO2 and IO3 No Header! No Brainer! (it will be fairly obvious how to do this, especially if you read the code comments). That’s it for this month, but why not have a play with IFTTT and see what Our patented range of Plug-of-Nails™ spring-pin cables plug directly other web services into a tiny footprint of pads and locating holes in your PCB, eliminating you could trigger the need for a mating header. Save Cost & Space on Every PCB!! instead of an email. Solutions for: PIC . dsPIC . ARM . MSP430 . Atmel . Generic JTAG . Altera If you are fortunate Xilinx . BDM . C2000 . SPY-BI-WIRE . SPI / IIC . Altium Mini-HDMI . & More enough to have some Philips Hue lighting, why not Tag-Connector footprints as small as 0.02 sq. inch (0.13 sq cm) try switching some lights on whenever www.PlugOfNails.com 57