Software apps and online services
Hand tools and fabrication machines
Using this B-L072Z-LRWAN1 board combined with STM's Mems-Sensor Arduino Shield X-NUCLEO-IKS01A1 or X-NUCLEO-IKS01A2 , you can combine wireless IoT with simple sensors like those for temperature, pressure, humidity and magneto sensor. This project adapted the demo firmware to build a WindVane Weather Station using The Things Network and Cayenne LPP.
An extra requirement besides the 3D printer, PCB demo boards and the complete tool set is some metal construction hardware to make it spin easily: a 28/15mm bearing stuck on a 20cm long pole (M8 rod).
Some simple Lora module test showing 20km+ range: LinkedIn.
- Go to the STM website and download the LoraWan and STM Open Development Environment SW4STM32 (Eclipse based).
- Install the SW4STM32 (Eclipse) and optional install the LoraWan software (STM32CubeExpansion_LRWAN_V1.1.0) in a new workspace directory (don't change the naming of the directory-structure).
- Download the new End_Node firmware from this project, and add the LoraWan Project directory in the work space. (Zip files contains the complete project-directories) :
Startup the .project file. location : ..\End_Node\SW4STM32\B-L072Z-LRWAN1\mlm32l07x01\.project . Check out the code in Eclipse
Next step is to setup the Lora Network info (via TTN).
The B-L072Z-LRWAN1 is equipped with a Murata module that contains the Semtech Lora Radio and an SMT32L0 MCU. This radio has a unique Device Identifier called [Device EUI]. The board is factory equipped with firmware that shows the Device EUI via the Virtual Com port. So hook up your Loraboard via USB and open a Terminal like Putty or TeraTerminal (115200 baudrate, 8 bit 1 stopbit, noparity, Flowctrl XonXoff). If you don't find the right COM port, check the device manager on your system and look for the ST-link Virtual Comport. You see something like this:
Copy and save the DevEui hex code, you need it at TTN. The AppEui and AppKey will be sourced via TTN as well - see the next section.
Go to TTN and open or setup your account. Go to your console and start a new Application which is using OTAA (over the air activation). TTN will issue an Application EUI, so copy this hex code. In your application create a new device. This requires the DevEui of the previous section. TTN will also generate a security key called the Application Key, so copy this as well. It shows something like this in your device overview:
You can make the App Key visible with the eye-icon. You can change the hex-code style with the '<>' - very smart for copying it into the C-code. :)
Now to make the firmware in the device unique for the TTN-application, you need to adapt the settings of the OTAA lora ID's. Go to the comissioning.h include file, and change hex-code of the LORAWAN_APPLICATION_EUI and LORAWAN_APPLICATION_KEY with the TTN data from the previous section. LORAWAN_DEVICE_EUI is read by the software, no need to change this.
Save the file and compile the whole project. Go to the Debug directory and copy the .bin file to the temporary drive (when plugging in the Lora board, the ST-link will automatically generate a external drive, copy and past the .bin file here). The ST-link controller on the board will flash the STM32L0 MCU and restart the board.
Remark : You van use also the IKS01A2 version of the Mems-shield, but this needs some software-library adaptations as it is using a different Pressure Sensor on the shield. Physically it fits in the same housing/casing.
After flashing the B-L072Z-LRWAN1 board is reset and start running. You can reset the board manual by pressing the black reset-button.
Open the terminal connection and watch the console. Firmware will first state when it starts a calibration. This is for the magneto sensor calculating the max-min values needed to convert the operational values to the right direction-angle. During calibration, the BlueLED is flashing for 10 seconds. Put the board in a flat position (X-Y plane) and turn it a bit around facing north-south, etc.
After 10 seconds, it's calibrated and the console shows the OTAA activity and will give the status. IF you are close enough to a TTN gateway, the board will JOIN and your information is sent every 10 seconds. These 10 seconds are for testing, in a real situation you should change the APP_TX_DUTYCYCLE in main.c to a value for 15 minutes or so (value is set in milliseconds). The terminal monitor dumps some calculated values for the data on screen - just for verification purposes.
If you don't want to see this data, you can set the defined compiler variable:
Once you have the board joining the TTN network, you can see the device data in the TTN console coming in (Data section). Data comes in a burst of series of bytes. This info is setup in the Cayenne LPP format: [channel][type][data]. In Main.c, you find the function
that makes this happen.
Now you can in TTN pre-set the payload format to Cayenne LPP, and TTN will show you the converted data. It looks something like this:
The payload is translated into recognized fields - Great!
Some remarks on this application: Wind Direction is not a common LPP type, so the wind-angle is passed via the analog_in_5 (LPP channel5). Other info:
- Analog_in_5 is the Wind Direction angle (0 is North, 90 East, 180 South, etc.)
- Analog_in_3 is the battery status in %
- Digital_out_6 is the status of the Blue LED (on/off)
- Gps_4 are fixed coordinates, can be modified in the code.
- Other names of the payload fields are as named
Remark: The LPP channels are not related to the TTN channel for communication up and downlink to the TTN-gateway.
Remark: you can send downlink-info to the Lora Board by TTN-Application Channel 2: 01h or 00h to toggle the blue LED on or off.
- Start a project
- Select "LoRa" -> The Things Network - > Cayenne LPP as a device:
Once the project is setup, you can see the received data fields, and choose in what format you like to see the console including data over time, diagrams, gauges, etc. Also, you should be possible to view it on your mobile with the Cayenne app. So far the app on Android-version of Cayenne does not load the project - WIP ?
For battery operation, the B-L072Z-LRWAN1 board is equipped with a battery holder of 3xAAA. To make the battery work correctly, the ST-link controller on the board needs to be switched off and the reset disconnected. Powering via battery does not power the ST-link controller, but the reset is still influencing the MCU reset, so this needs to be disconnected.
This can be done by removing the SB37 connection. Unfortunately, this is not a jumper-option, so you have to desolder the small zero Ohm resistor which is very tiny (0603). The SB37 is on the backside of the board. See also the User Manual UM2115 for more details on this.
Also remove the stub SB18, so the battery wont be drained by the red power led.
There are three 3D-printed casings that support the B-L072Z-LRWAN1 + X-NUCLEO-IKS01A1 shield. (You van use also the IKS01A2 version). Physically it fits in the same housing).
The STL files for printing the housing can be found on ThingIverse . There are 3 version made:
- V1 : Tight casing with pin-connection between front and back
- V2: Larger casing with slide-in edges to make it more tight.
- V3: same as V2, but with air-flow Nose on the front and air-outlet on the back.
V3 makes it better to measure humidity and temperature as on sunny days the casing heats up and when cooling down humidity might be trapped in the casing. V3 prevents this somehow - but casing is more ugly... :)
Printing is best done in ABS plastics or special plastics like Pc-Max from Polymaker. To prevent warping of the connected parts (front and back), best results are with a raft and a support-set, printing nose-down (or bottom-down):