Skip to the content
PCBKitNew board
2 layers25 × 59.7 mmGenericSensor v2, the printed circuit board in 3D

GenericSensor v2

angelnu/LorawanSensor22

LoraWan soil sensor

Size
25 × 59.7 mm
Copper layers
2
Thickness
1.6 mm
Parts
35
Nets
37
Pads
148
Tracks, vias
382, 30
Pours
2
Routed
Yes
KiCad
KiCad 6 (file 20211014)
Created
21 Jun 2020
Updated
21 Jan 2024

Overview

GenericSensor v2 is an open-source printed circuit board by angelnu, from the angelnu/LorawanSensor repository on GitHub, published under the MIT licence. It is a 2-layer board of 25 × 59.7 mm with 35 parts on 37 nets, routed with 382 tracks and 30 vias.

It is built around the RFM95W-868S2. Its parts include 9 capacitors, 3 connectors, 2 resistors, 2 ICs and 1 diode. It belongs with the radio and wireless and sensors and measurement boards and the STM32 boards of this library.

Main components

1

README

README.md

STM32 Low Power LoraWan Sensors

This project provides a framework to easily build LoraWan devices. The requirements are:

  • sensors that could run without replacing batteries during the life cycle of the device
  • small size
  • easy to build and program (need a 20-30)
  • simple to create a new type: just a new file
  • cost bellow 20€
  • resist the outside weather with easy to 3D print cages

The sensor can work on a CR123 battery for 20 years (self-discharge of the battery being the main factor). It sends the battery voltage and (optionally) the temp of the MCU (using factory calibration).

For each new detected device it generates unique LoraWan keys and upload them to flash. This way the same firmware can be used for multiple instances of the same board.

NOTE: Do not put the config directory in a public repository. Instead save as extra home/private repository so you have versioning while keeping your keys private!

Download commands might be used to query or modify the configuration. See the commands section bellow.

Bill of Materials

Devices can be built for ca 10-20€ ussing the following parts:

  • STM32 MCU - any of the following:
    • STM32L412KB (3 €) - prefered: 128KB RAM for a future firmware OTA update
      • STM32L412KBT6 128K Flash, 8K RAM, LQFP-32
    • STM32L412K8 (2.5 €) - same as STM32L412KB but only 64K Flash
      • STM32L412K8T6 64K Flash, 8K RAM, LQFP-32
    • STM32L010K8 (1.5 €) - cheaper MCO+, slower, less memory, not tem and slightly higher consumption
      • STM32L412K8T6 64K Flash, 8K RAM, LQFP-32
  • RFM95W (3.5 € via Aliexpress, 3x this price if bought in Europe)
  • RC123a battery and holder (2€ via Aliexpress, 2x this price if bought in Europe)
  • PCB (2-5 € when ordering 12 from Aisler ) - see Devices folder for the sources and the uploaded PCBs to Aisler
  • 3D-printed boxes - see cages in Devices folder
  • some SMT components (1 €) - see schematics in Devices folder

Downlink commands

Downlink commands are used to query and/or modify the device settings without having to reprogram the flash. Each command uses one byte plus optional data depending on the command. The commands are implemtented in the lorawan_process_command at lorawan.cpp

Commands will be queued and transferred to the device after the next uplink transfer. Multiple commands can be queued but be carefull not to exceed to the watdown timeout or the device will get reset.

Commands:

  • 0x00 - READ configuration
    • Description: Returns the configuration of the device. See device_config_t for more details on the struct
    • Additional downlink bytes: none
    • Example output: 02 03 3C00 05 3C 6400 5802 01 0A 05 FF
  • 0x01 - Reset config to the default
    • Additional downlink bytes: none
  • 0x02 - Sets the configuration
    • Additional downlink bytes: config as returned by the 0x00 command
    • Example input: 02 02033C00053C64005802010A05FF
  • 0x05 - Read Device UID
    • Additional downlink bytes: none
    • Output: 12 bytes with STM32 UID
  • 0x06 - Read firmware GIT commit
    • Additional downlink bytes: none
    • Output: ASCII string
  • 0x07 - Read firmware BUILD date
    • Additional downlink bytes: none
    • Output: ASCII string

Firmware

This project requires Platformio and the STM32 Cube Programmer. Both need to be installed and available in the PATH.

Keys for each detected device will be stored under config/devices.ini. Before you run for the first time please create the file and include your app EUI (or modify afterwards). You can create this by registering a new app at the TTN console. The file should have:

text
[global]
appeui = <your app EUI>

If you run without creating the file first then the programmer will create a dummy APPEUI which you will need to modify. You can keep the config folder into its own git repository but please keep it private! On checkout you might use the this script to check it out.

For programming either use the platformio UI or any of the CLI commands proposed for the device.

If you connect a serial interface while booting you should see the following:

text
Settings unchanged
DEVICE VERSION: 3
DEVICE CONFIG: 0x02033C00053C64005802010A05FF
Device UID: 0x3200230006504D3843353720
BUILD DATE: Jun 21 2020
BUILD TIME: 18:07:48
COMMIT ID: e3d1d3b5d34d39d88d90022d6fe365ebce3887b5
APPEUI: 0x.....
DEVEUI: 0x....
Starting
7579 Sending.. 18248 TX_COMPLETE

Adding new devices

  1. Add a section to platformio.ini for your device. The key part is to have a dedicated -D SENSOR_<PCB name>_<sensor name>_<MCU name> (such as -D SENSOR_GENERIC_DISTANCE_SMT32) -> this will be needed in the next step.
  • If you are just using the generic PCB then you can copy Basic v1 and modify to your needs
  • If you are creating your own PCB based on the STM32 MCU then you can copy Generic v1 and modify to your needs
  • If you use a different MCU then you will need to create your own target extending base and base_debug. Please notice that you will in this case have to add support for the new MCU in multiple areas of the code where the MCU is relevant: the code has been tested with STM32 (mainly) and atmega32.
  1. Add a new cpp file to src/devices/ for your new device. The namming convention is .cpp. If you are using a STM32 CPU you should consider copying generic_basic_stm32.cpp which does not depend on any external sensors to work and then add your own sensors to it. You need to make this file to only get included and compiled when SENSOR_<PCB name>_<sensor name>_<MCU name> is defined.
  2. Add to devices.h a section for your device where you set your device_config_device_t. This struct includes what persistent settings your device needs. These settings can later be modified via a LORAWAN command.
  3. Documment your device in the devices folder. This folder structure is:
      • cages: instructions and files to 3D print cages for devices
      • KiCad: Schematics and PCBs created with KiCad
      • pictures: pcitures embedded in markdown readme
      • README: instructions, pictures and links for devices. It is structured with a chapter for each device sharing the same PCB and a subcharter for each mayor version of the device.

ToDos

  • Firmware OTA update

Parts

35
QtyValueFootprintReferences
6PUResistor_SMD:R_0805_2012MetricRA15, RB3, RB4, RB5, RB6, RB7
5100 nFCapacitor_SMD:C_0805_2012MetricC4, C5, C6, C7, C9
21 uFCapacitor_SMD:C_0805_2012MetricC8, C10
210 pFCapacitor_SMD:C_0805_2012MetricC1, C2
212KResistor_SMD:R_0805_2012MetricR3, R7
2MountingHoleMountingHole:MountingHole_2.2mm_M2H1, H2
2SolderJumper_2_BridgedJumper:SolderJumper-2_P1.3mm_Bridged_Pad1.0x1.5mmJPC0, JPC3
2SolderJumper_2_OpenJumper:SolderJumper-2_P1.3mm_Open_Pad1.0x1.5mmJPO0, JPO3
132KHzCrystal:Crystal_SMD_3215-2Pin_3.2x1.5mmY1
1Antenna_ChipRF_Antenna:Texas_SWRA416_868MHz_915MHzAE1
1BOOTButton_Switch_SMD:SW_SPST_TL3342BOOT1
1Battery_CellBattery:CR123_holderBT1
1Conn_01x04_MaleConnector_PinHeader_2.54mm:PinHeader_2x02_P2.54mm_VerticalJ3
1Conn_01x06_MaleConnector_PinHeader_2.54mm:PinHeader_1x06_P2.54mm_VerticalJ1
1Conn_01x09_MaleConnector_PinHeader_2.54mm:PinHeader_1x09_P2.54mm_VerticalJ2
1Ferrite_Bead_SmallResistor_SMD:R_0805_2012MetricFB1
1LEDDiode_SMD:D_0805_2012MetricD1
1RESETButton_Switch_SMD:SW_SPST_TL3342RESET1
1RFM95W-868S2RF_Module:HOPERF_RFM9XW_SMDU2
1STM32L041K6TxPackage_QFP:LQFP-32_7x7mm_P0.8mmU1

Questions

How big is the GenericSensor v2 PCB?

It measures 25 × 59.7 mm and has 2 copper layers, 1.6 mm thick.

What parts does the GenericSensor v2 use?

35 parts, built around the RFM95W-868S2. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the GenericSensor v2 KiCad files?

From the angelnu/LorawanSensor repository on GitHub, at the commit this page was made from: the board is devices/GenericSensor/KiCad/GenericSensor_v2.kicad_pcb and its schematic devices/GenericSensor/KiCad/GenericSensor_v2.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the GenericSensor v2 design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).

More from angelnu/LorawanSensor

3
  • 2 layers56.5 × 66.8 mmTracker v1, the printed circuit board in 3D

    Tracker v1

    angelnu/LorawanSensor

    LoraWan soil sensor

    45 parts22MIT
  • 2 layers26 × 133.4 mmSoilSensor, the printed circuit board in 3D

    SoilSensor

    angelnu/LorawanSensor

    LoraWan soil sensor

    27 parts22MIT

Similar boards

  • 4 layers66.3 × 40.2 mmCm4 drone, the printed circuit board in 3D

    Cm4 drone

    dridri/bcflight

    Raspberry Pi based drone flight controller and remote control

    56 parts175GPL-3.0
  • 4 layers83 × 109 mmD4 small pcb panel, the printed circuit board in 3D

    D4 small pcb panel

    unsurv/unsurv-offline

    Offline portable GNSS device based on the ESP32

    522 parts72
  • 2 layers57 × 35.5 mmWARS Birdhouse-2, the printed circuit board in 3D

    WARS Birdhouse-2

    brucemack/WARS-Birdhouse

    LoRa Mesh Network Node

    22 parts66GPL-3.0
  • 2 layers45 × 53 mmLoRa Node, the printed circuit board in 3D

    LoRa Node

    cernohorsky/LoRa-Node

    Simple LoRa Node based on Arduino Pro mini with RFM95W module and PCB antenna.

    35 parts66
  • 2 layers72 × 27 mmLoRaProMini, the printed circuit board in 3D

    LoRaProMini

    foorschtbar/LoRaProMini

    A low power LoRaWAN Node

    37 parts51MIT
  • 2 layers61.5 × 18.7 mmLoRA USBStick, the printed circuit board in 3D

    LoRA USBStick

    ElectronicCats/CatWAN_USB_Stick

    An Open Source USB Stick compatible with LoRa and LoRaWAN with Cortex M0+. To connect, review and analyze packages of LoRa®

    36 parts50GPL-3.0
  • 2 layers79.2 × 68.8 mmEnvironment slave, the printed circuit board in 3D

    Environment slave

    pcbcupid/Lora-Wireless-Sensor-Network

    A wireless sensor network based on Lora and esp32C3. This repo will help you build a complete product from scratch to finish!

    72 parts30MIT
  • 2 layers50 × 25 mmLoRa Environmental Sensors, the printed circuit board in 3D

    LoRa Environmental Sensors

    spielhuus/LoRa-Environmental-Sensors

    ATtiny85 based LoRa atmospheric sensor board with BME280

    5 parts28