Build Your Own Mioty® Demo Kit Using Only Off-the-Shelf Components

by phaseshifted in Circuits > Raspberry Pi

39 Views, 0 Favorites, 0 Comments

Build Your Own Mioty® Demo Kit Using Only Off-the-Shelf Components

video-breakout.gif
opensource-demokit.jpg
render.png

mioty® is a robust, low-power wireless protocol designed for massive IoT deployments. While commercial development kits exist, it is entirely possible to build a fully functional mioty demo node yourself using standard components and an open hardware PCB.

In this Instructable, you will build a working mioty demo kit based on a Raspberry Pi Pico and a HopeRF RFM69 module. It is basically a breakout board for the Raspberry Pi Pico, where the Raspberry Pi can be removed, in case you need it for a different project as well.

In this demo, we will order the PCB, solder the components, and upload a simple demo firmware that sends data over mioty.

This project is suitable for makers with basic soldering experience and some familiarity with Arduino-style programming.

Supplies

20251229_130727.jpg
20251229_130520.jpg

Electronics

  1. Raspberry Pi Pico
  2. The normal version is completely fine for this project, you don't need the Pico 2 or the W version that would include WiFi. Also, go for the original version with the micro-USB port and not the copies with USB C, these might be different to integrate into the Arduino environment.
  3. Radio module: HopeRF RFM69CW or RFM69HCW (EU 868 MHz)
  4. Watch out for the "C" - this is the compact form factor. Modules without the "C" won't fit this PCB
  5. SMA connector and 868 MHz antenna
  6. 2x 20-pin headers
  7. Passive components (0805 format):
  8. R1: 100Ω (optional, but can be used to generate small current pulses for example to keep your power bank active if you're using this project together with a power bank)
  9. C1: 0.1 µF (decoupling)
  10. C2: 1 µF (decoupling)
  11. Optional: Buttons and Grove Connectors

PCB

  1. mioty Open Source demo kit PCB, we will order it as part of this demo: https://github.com/phaseshifted-iot/mioty-demokit

Tools

  1. Soldering iron with fine tip
  2. Solder wire
  3. Flux
  4. Tweezers
  5. Side cutters
  6. micro-USB cable for Raspberry Pi Pico

Software

  1. A computer with Visual Studio Code installed

Order the Breakout Board PCB

pcbway.png

The PCB design files are provided as KiCad sources and ready-to-manufacture exports in the GitHub repository. Depending on your favorite PCB supplier, ordering an initial quantity of 5 pieces starts around 10$ including shipping.

  1. Open the repository:
  2. https://github.com/phaseshifted-iot/mioty-demokit
  3. Navigate to the /export folder.
  4. Download the Gerber files.
  5. Upload the Gerbers to your preferred PCB manufacturer.
  6. Use standard FR-4, 1.6 mm thickness, 2-layer board.
  7. No special impedance control or advanced options are required.

Once the PCB arrives, you are ready to assemble the hardware.

Soldering and Assembly

FQXSI8NMJI5DERH.gif

Start with the lowest profile components and work up to the connectors.

Recommended order:

  1. Resistors and capacitors:
  2. R1: Resistor 0805 100Ω (optional)
  3. C1: Decoupling capacitor 0805 0.1 µF
  4. C2: Decoupling capacitor 0805 1 µF
  5. (Optional components):
  6. Buttons: 5.2mm x 5.2mm (Button_Switch_SMD:SW_SPST_TL3342)
  7. Grove: Connector_JST:JST_PH_B4B-PH-K_1x04_P2.00mm_Vertical
  8. Header pins for the Raspberry Pi Pico
  9. RFM69 module
  10. SMA antenna connector. Alternatively, there is a connection foreseen for a coil antenna, but this will give you a worse RF performance.

Pay close attention to:

  1. Orientation of the RFM69 module: The ANT-pin should be closest to the antenna, that's an easy way to check the orientation.
  2. Proper ground connection for the SMA connector (also solder on the back side)
  3. Clean solder joints on SPI pins

Setup Visual Studio Code

vs-code-pico-extension.png

Unfortunately, there is currently no implementation of a dedicated Arduino library for the TS-UNB implementation of the Pico. But it is quite straight forward to set up everything inside Visual Studio Code with the Raspberry Pi Pico extension.

Install Visual Studio Code

Download and install VS Code from:

https://code.visualstudio.com

Install the Raspberry Pi Pico SDK

Follow the official Raspberry Pi guide for your operating system:

https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf

This installs:

  1. Pico SDK
  2. ARM GCC toolchain
  3. CMake
  4. Python tools

After installation, verify that the environment variable PICO_SDK_PATH is set.

Install VS Code Extensions

Open VS Code and install:

  1. C/C++ (Microsoft)
  2. CMake Tools (Microsoft)
  3. Raspberry Pi Pico Extension (very practical to configure and flash your pico)

Example Mioty Demo for Pico

Clone TS-UNB library

Create a working directory, for example mioty-projects.

Clone the TS-UNB library:


git clone https://github.com/mioty-iot/TS-UNB-Lib-Pico.git

You now have the mioty stack available locally.

Navigate to the /examples folder and open the sendString.cpp example.

Definitions

mioty Network Key: Randomly generate this number for each device individually. This key will be used to encrypt the messages over the air.

MAC EUI64: This is a globally unique identifier that is different on every mioty device. Usually, a mioty hardware manufacturer would purchase an address range from IEEE, and then use these addresses for their devices. As makers, we can't do that. Therefore, a good trick is to use the EUI of a component that already is on our hardware. For example, the MAC address of the Pico.

Demo Code

This demo project will send a simple String over the mioty protocol. We will just compile this project and send it to the Pico to test if everything works properly. To send and receive mioty messages afterwards, you will also need a mioty Base Station, which can be covered in a different tutorial.

#include "../src/RPPicoTsUnb.h"

// This is the node specific configuration
#define MAC_NETWORK_KEY 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
#define MAC_EUI64 0x70, 0xB3, 0xD5, 0x67, 0x70, 0xEF, 0x00, 0x00
#define MAC_SHORT_ADDR 0x70, 0xEF


#define TRANSMIT_PWR 14 // Transmit power in dBm
#define LED_PIN 25

using namespace TsUnbLib::RPPico;

// Select preset depending on TX chip
//TsUnb_EU1_Rfm69w_t TsUnb_Node;
TsUnb_EU1_Rfm69hw_t TsUnb_Node;

//TsUnb_US0_Rfm69w_t TsUnb_Node;
//TsUnb_US0_Rfm69hw_t TsUnb_Node;


//The setup function is called once at startup of the sketch
void setup() {
sleep_ms(100);
stdio_init_all();
gpio_init(LED_PIN);
gpio_set_dir(LED_PIN, GPIO_OUT);
gpio_put(LED_PIN, 1);
sleep_ms(100);
gpio_put(LED_PIN, 0);

TsUnb_Node.init();
TsUnb_Node.Tx.setTxPower(TRANSMIT_PWR);
TsUnb_Node.Mac.setNetworkKey(MAC_NETWORK_KEY);
TsUnb_Node.Mac.setEui64(MAC_EUI64);
TsUnb_Node.Mac.setShortAddress(MAC_SHORT_ADDR);
TsUnb_Node.Mac.extPkgCnt = 0x01;


// Blink LED
gpio_put(LED_PIN, 1);
sleep_ms(1000);
gpio_put(LED_PIN, 0);

}


int main() {
// wdt_enable(); // Enable 8s supervision TODO:watchdog not implemented
setup();
while(1){
// Send the text "Hello"
char str[] = "Hello";
TsUnb_Node.send((uint8_t *)str, sizeof(str) / sizeof(str[0]) - 1);

// Blink LED when TX is done
gpio_put(LED_PIN, 1);
sleep_ms(100);
gpio_put(LED_PIN, 0);
sleep_ms(100);
gpio_put(LED_PIN, 1);
sleep_ms(100);
gpio_put(LED_PIN, 0);

// Sleep some time
sleep_ms(4000);
}
}


To flash this code to your Pico, it is easiest to do the following:

  1. In the Visual Studio Code / Raspberry Pi Quick Access console on the left, hit "Import Project"
  2. Select your TS-UNB-Lib-Pico > examples folder, leave other settings untouched
  3. Click "Import" - the extension will configure CMake automatically
  4. Build the project first:
  5. In the Raspberry Pi Pico extension panel, click "Compile Project" button
  6. Wait for the build to complete (you'll see "Build finished" in the terminal)
  7. Connect your Pico:
  8. Hold the BOOTSEL button on your Pico while plugging in the USB cable
  9. Release the button once connected
  10. Upload the code:
  11. In the Raspberry Pi Pico extension panel, click "Run Project (USB)"
  12. The Pico will automatically reboot and run your sendString program