Parts List:
9V Battery 2 ea
Microbit 2 ea
Ultrasonic sensor RCWL-061 . 1 ea
Hook-up Wire, 22gauge solid, various colors
Wiring: Ultrasonic Sensor to Vcc, GND, Trig-->Pin 5, Echo--->Pin 8
DF Robot Voice Synthesis Module. Vcc, GND, SCL--->Pin 19, Data--->Pin 20
Transmitter Code:
Extensions: MakerBit, https://github.com/DFRobot/pxt-DFRobot_speechSynthesisV2
Speech Synthesis Moduie Wiki: https://wiki.dfrobot.com/dfr0760/docs/19216
Above: I2C Connections on Microbit are Pin 19(Serial Clock) and Pin 20(Serial data)
Ultrasonic Sensor uses MakerBit extension
Receiver Code:
Version 2: Using an HC-12 trasceiver with a Microbit for greater range- 100's of feet!
Using AT Commnands with the HC-12
https://sites.google.com/view/acera-arduino/advanced/using-at-commands-with-bluetooth-and-radio
If greater range is needed, the radio connection can be made using the HC-12 transceiver modules.
You can use an HC-12 transceiver module with a Micro:bit to transmit data to another Micro:bit.
Because the HC-12 communicates via standard UART (Serial), and the Micro:bit has customizable serial pins, the two devices pair together quite easily.
Here is how you can set it up, along with a few hardware quirks to keep in mind
Receiver Unit:
.1. The Wiring Connection
You will need to establish a standard cross-over serial connection (TX to RX).
HC-12 Pin. M icro:bit Pin
Notes
VCC ---3V or External 5V
See power warning below.
GND -----GND
Must share a common ground if using external power.
TXD Pin 1 (RX)
You can assign this to any digital pin in code.
RXD Pin 2 (TX)
You can assign this to any digital pin in code.
SET. Unconnected
Only pull to GND if you need to send AT commands to change baud rate or channels.
Important Power Consideration: While the HC-12 can operate down to 3.2V, transmitting at high power can draw up to 100mA. The Micro:bit V1's onboard voltage regulator can only safely supply about 90mA to external accessories. The V2 is better (~190mA), but if you experience brownouts or dropped signals, power the HC-12 modules with an external 5V power supply (like a battery pack) and ensure the grounds are tied together.
The data lines (TX/RX) are 3.3V logic compatible, so they are safe to connect directly to the Micro:bit without logic level converters.
2. The Code Implementation
You can handle the communication in either MakeCode or MicroPython. The HC-12 defaults to a 9600 baud rate, which is perfect for the Micro:bit.
In MakeCode (Blocks): Use the Advanced > Serial menu. You will need to use the serial redirect block in your on start loop to route the TX and RX to the specific pins you wired (e.g., TX to P2, RX to P1) at a baud rate of 9600. Then, you can use serial write line to transmit data, and serial on data received to read incoming strings.
Test code:
Add RCWL-1601 ultrasonic sensor: