Updated: Mar 21
In this project we demonstrate BBC micro:bit how to easily connect it to WiFi / Internet and send a notification to a phone without writing a single line of code. The micro:bit comes with a microphone, among the other features. We are going to use it to detect loud sound e.g. clicking fingers and when a loud sound is detected we send an alert notification to our phone.
In order to connect and send the alert notification, we use the IOT Circket WiFi module. All we have to do with it is to attach batteries, configure it and our "IoT sound detector" is ready to communicate with our phone. In this example we choose a Pushsafer internet service but you might want to choose any other services e.g. Pushover, Blynk, IFTTT, Zapier, Emails, Google Docs, practically any internet service you like. Alternatively you can also integrate it to your local home automation system such as Home Assistant, Node-RED and the like over MQTT or HTTP apis.
Everyone can realise this project from beginners to advanced engineers.
Step 1) Set up micro:bit
Micro:bit is a tiny computer which empowers anyone at all skill levels to create exciting electronics projects. It includes microphone, gyroscope, accelerometer, temperature sensor, light sensor and other features. In this example we are going to use the microphone to detect clicking fingers or any other high volume noise. Once the sound is detected we are going to:
Display the Heart icon on the LED display
Set the P0 pin to "1" for a short period of time (1 second) - to wake up Cricket WiFi module to send a notification to a phone
Let's go and create the program in https://makecode.microbit.org/ as shown below:
Here is our complete project: https://makecode.microbit.org/_3gr76PCMDXKh
Once the program is ready we need to put it on our micro:bit with the following steps:
Click the "Download" button and save the program on the local disk
Connect micro:bit via USB to PC (MICROBIT drive should appear)
Copy/Paste the downloaded program to MICROBIT drive (micro:bit should be flashing LED when performing the copying)
Our micro:bit is ready! We can test it by clicking fingers and see if the heart icon shows up on the LED display. If yes, we can disconnect from USB and move on to the next step.
For more information how to get started with micro:bit please check out this official guide how to get started with micro:bit. We were inspired to do this project with the sound input tutorials which you might also like to check.
Step 2) Assembly
In this step we are going to connect all the components together with the following steps:
Connect micro:bit to the batteries
Connect Cricket to the batteries (we peel out the coat from the cables to connect Cricket on the same power source)
Connect micro:bit's P0 pin to Cricket's WAKE_UP pin [green cable]
A complete project assembly may look like this:
Step 3) Setup Pushsafer
Pushsafer, we learned, is one of the easiest and reliable internet service which provides multi-platform push notifications. There is some free allowance of notifications but we quickly ran out of it and had to purchase 1000 extra notifications for ~$1. It is very cheap for what it gives you back and it is super simple to set up:
Go to pushsafer.com
Open an account
Create a notification message
Generate a URL link and save it somewhere (we will need this link to copy/paste to Cricket's configuration in the next step)
Install mobile app on your phone (iPhone or Android) and login with the same account
Below there is a screenshot of how we created an example message:
Now we can press the "Send Message" button and, if everything is configured correctly, we should receive a message: "Microbit: Hello from Cricket!" on our phone.
Please do not forget to press the "Create Link" button and save the URL address as we will need this to configure Cricket in the next step.
Step 4) Configure Cricket
IOT Cricket is an easy to use ultra-low power WiFi module, which can operate directly on batteries for a very long time (for years in many use cases). You simply attach a sensor and battery to it and the device is ready to transmit data instantaneously to a network.
Now we are going to configure the Cricket module to send notifications to a phone when it wakes up. It happens when a voltage appears on the WAKE_UP pin. In our case it is when micro:bit sets the P0 pin to "1" and as it is connected to Cricket's WAKE_UP pin, it raises the voltage on that pin and it wakes it up. After that, Cricket connects to the Pushsafer service by using the URL link, which we obtained in the previous step. Once connected, the Pushsafer service sends the notification to our phone.
Let's do it step by step.
Let's first connect Cricket to our WiFi network:
Press the built-in Cricket's button for 5 seconds (it opens toe_device hotspot)
Connect to the "toe_device" hotspot from a phone or laptop
Pass your WiFi credentials: SSID and Password; and press CONNECT button
For more information please see the steps here.
Open CONFIG panel and set the following:
CONNECTIVITY > type: HTTP_GET
CONNECTIVITY > url: [copy/paste the URL obtained from the previous step]
IO1 > force update: On
An example configuration may look like this:
This is it. We can press the switch off button in the top right corner to exit from the configuration and our device is ready to go!
It's time to test it out!
Testing our device
Let's make some sound! This should wake up micro:bit to display the Heart icon and raise voltage on the P0 pin. This subsequently wakes up Cricket, which instantaneously connects to the Pushsafer service. Once connected the Pushsafer service sends the notification to our phone.
We have presented how easily you can make projects with Micro:bit and connect them to almost any internet service by using Cricket. It is the base to build upon for more advanced projects.
The ecosystem of software and services which Cricket can be integrated over HTTP and MQTT is HUGE! To mention a few IFTTT, Zapier, automation systems such as Home Assistant, Node RED, Grafana, etc.
Now as we know the basics, the sky is our limit of what other projects we can make!
Thanks for getting up to here. We hope you enjoyed this tutorial!
Things On Edge team
Things On Edge (thingsonedge.com) is a company based in Cambridge, UK. They design easy to use, ultra-low power Cricket Wi-Fi modules. They enable makers at all skill levels to build battery powered WiF devices and integrate them to a huge IOT ecosystem of software and services over MQTT and HTTP apis. All this without writing a single line of code and programming.