This project uses a CAN bus to collect voltage, oil pressure, and RPM data from a combustion engine and transmit this information to the cloud via NB-IoT and LoRaWAN®.
A Controller Area Network (CAN bus) has been widely adopted in the automotive industry. This communication method enables different microcontrollers to interact without the need for a central computer to manage them. It facilitates reading data from the instrument panel, processing signals from various sensors, and controlling actuators within the complex systems of today’s automobiles.
By the end of this tutorial, you will be able to collect environmental data via CAN bus and transmit it wirelessly using two of the most widely used IoT communication protocols: LoRaWAN and NB-IoT.
Figure 1: Simplified CAN bus system
Use Case
By reading the vehicle's battery voltage, oil pressure, and engine revolutions from its CAN bus, the device will communicate this data to the cloud using LoRaWAN or NB-IoT. This approach can be applied to a fleet of industrial vehicles, such as semi-trucks or mining equipment, as this information is often only accessed during vehicle failures or corrective maintenance.
This solution is developed to enable continuous monitoring of machinery, allowing us to assess their health status wirelessly and prevent production stoppages, which can lead to economic losses.
Requirements
1. Necessary Hardware
- CAN Bus Interface Microchip MCP2518FD
- WisBlock Baseboard RAK19001
- WisBlock Core RAK4631
- USB to CAN (Optional)
- WisBlock Blues Carrier Module RAK13102
- LiPo Battery
- Blues Notecard (Select one according to your location)
- Blues Notecarrier A, B or F (Optional)
Figure 2: Necessary hardware for the development
2. Gateway
- RAK7268V2 WisGate Edge (used in this guide)
3. Back-End Services
Hardware Connection
The hardware adopts a modular approach provided by WisBlock. The complete firmware is developed and available in the official GitHub repository, and the IoT data visualization platforms are cloud-ready. Additionally, we will replicate the project developed by Blues Wireless by using JSON data to access the information.
Connecting the WisBlock elements is straightforward:
- Plug the core into the core slot and the CAN Bus Interface IO slot of the card. In this guide, you will use the RAK19001 WisBlock Base Board, but you can select a different compatible base board.
- The Blues Notecard can be connected via the WisBlock Blues Carrier Module, which should then be plugged into the base board's IO slot.
- Finally, to prepare your product for deployment, use the WisBlock enclosure, specifically designed for this purpose.
Figure 3: Final project installation view
Now that the devices are connected, you can begin programming.
The Notecard requires a peak current of 2 A to send data. The VDD pin of the WisBlock cannot provide this current, so it is recommended to use a battery or connect an additional USB cable to the Notecard during your project testing.
Blues Hardware Assembly
After completing the instructions outlined in the hardware configuration and uploading the code provided by Blues on GitHub to the notecard, the final assembly is shown in the image below:
Figure 4: Final result for blues wireless version
Firmware Development
The code can be downloaded from the official GitHub repository. It was developed using Visual Studio Code and PlatformIO, which are two widely used tools for programming firmware.
In case the libraries are not available on PlatformIO, you can find them from the following sources:
If you need more information about how to configure and code your WisBlock setup with Platform IO, check the following guide for setting up WisBlock on PlatformIO.
Simulating CAN Bus Data
For this tutorial, a simulated CAN Bus data set is used. The simulation is done using the Software Busmaster and connected to the WisBlock via USB to CAN interface.
1. Install the Busmaster Software with the Canary Patch if you are going to simulate the CAN data with the same interface as the USB2CAN-Module used in this tutorial.
You can find the necessary software at the following links:
2. After installing the software correctly, associate the CAN_Database.dbf file included in the GitHub repository.
Figure 5: BUSMASTER software
3. Select the CAN_Database.dbf and click on Open.
Figure 6: Loading CAN database
4. Go to the Transmit Window button and select DATA. It will show the data saved in the database.
Figure 7: Simulating CAN bus data
5. Change the voltage, RPM, and oil pressure values to simulate the normal operation.
BUSMASTER SIGNAL DATABASE
//******************************BUSMASTER Messages and signals Database ******************************// [DATABASE_VERSION] 1.3 [PROTOCOL] CAN [BUSMASTER_VERSION] [2.3.0] [NUMBER_OF_MESSAGES] 1 [START_MSG] DATA,10,8,3,1,S [START_SIGNALS] Voltage,8,1,0,U,50,0,1,0.000000,1,V, [START_SIGNALS] RPM,8,2,0,U,10000,0,1,0.000000,1,1/s, [START_SIGNALS] OILPressure,16,3,0,U,10000,0,1,0.000000,1,BAR, [END_MSG] //***BUSMASTER Messages and signals Database ***// //[DATABASE_VERSION] 1.3// //[PROTOCOL] CAN// //[BUSMASTER_VERSION] [1.7.0]// //[NUMBER_OF_MESSAGES] 1// //[START_MSG] Message Name, Message ID, Length, Number of Signals, Data Format, Frame Format// //[START_SIGNALS]Signal Name, length, byte number, start bit number, signal type, Max value, Min Value, Byte order (1-Intel), offset, factor, Unit// //[VALUE_DESCRIPTION] Description Name, Description Value// //[END_MSG]//
Sending Data to the Cloud
LoRaWAN Communication
The process of communicating with end devices via LoRaWAN networks can be accomplished through a public network like Helium or by setting up your network using a LoRaWAN gateway. In this instance, configure the second option. For this process, you will need:
This process is straightforward and can be completed in just a few minutes. For a detailed step-by-step configuration, refer to the official RAK7268V2 gateway documentation.
After the successful configuration and connection of the gateway to the TTN LNS, use the given payload decoder.
TTN Payload Decoder
function Decoder(bytes, port) { var decoded = {}; if (bytes[0] == 1) { decoded.Voltage = ((bytes[1] << 8) | (bytes[2])); decoded.RPM = ((bytes[3] << 8) | (bytes[4])); decoded.OilPressure = ((bytes[5] << 8) | (bytes[6])); return decoded; } else if (bytes[0] == 5) { // add more sensor data formats here // } else if (bytes.[0] == xx) { } }
Blues Communication
Just create an account on the Notehub page and then create a new project. For a detailed guide, you can review the Blues documentation to see the process step by step.
Blues Payload Decoder
This payload decoder is used when the transmitted data is sent via the Blues Wireless hardware.
function Decoder(request) { var data = JSON.parse(request.body); var device = data.device; // this is your Device UID var decoded = {}; decoded.CANvoltage = data.body.CANvoltage; decoded.CANrpm = data.body.CANrpm; decoded.CANoilpressure = data.body.CANoilpressure; return [ { device: device, field: "CANvoltage", value: decoded.CANvoltage }, { device: device, field: "CANrpm", value: decoded.CANrpm }, { device: device, field: "CANoilpressure", value: decoded.CANoilpressure } ]; }
Datacake Connection
The connection to Datacake will be established by integrating the TTN and Notehub with the platform. You can create two devices in DataCake or configure a single device to receive data from multiple platforms.
1. After configuring your device on the Datacake platform, check if the payload fields are being received correctly. If so, start configuring the field with the appropriate name and variable.
Figure 8: Datacake Fields Configuration
2. If everything has been set up correctly, you should see a data history display similar to the following image:
Figure 9: Datacake History of Data
After completing the Notehub and TTN integration using Datacake’s official guides, your dashboard should look similar to Figure 10:
Figure 10: Datacake Dashboard Result
You can now send data to Datacake using LoRaWAN or NB-IoT/BLE/Cat-1. Next, let’s implement the complete Blues application.
Figure 11: Comparison RAKwireless vs Blues Wireless
- Production-Ready: Not just a prototype, this is a finished product ready for real-world use.
- Modular Design: Easy and fast to set up thanks to WisBlock’s plug-and-play modular architecture.
- Clean & Professional: Results in a polished and compact final product with minimal assembly.
- Developer-Friendly Firmware: Compatible with Arduino and PlatformIO, no need for complex IDEs.
- Multi-Network Communication: Supports LoRaWAN and cellular (NB-IoT, LTE-M, CAT-1) connectivity.
- Quick Integration with Dashboards: Easily connected to IoT platforms, no advanced front-end/backend coding required.
- Space-Efficient: Small form factor ideal for installations with limited space.
- Stock Notice: Some components used in Blues' reference solution may no longer be available.
Summary
As presented in this tutorial, WisBlock is a modular hardware solution developed by RAKwireless that simplifies the development of industrial-grade IoT applications. When paired with Blues Wireless components, it enables rapid deployment without the need for custom PCB design and offers some good features like:
- Plug-and-Play Hardware: There's no need to design your PCBs—just stack the modules and go.
- Industrial Application Ready: Designed for reliable use in professional and commercial environments.
- Prebuilt Firmware: Core functionality is already developed and ready for deployment, saving time and effort.
-
Developer-Friendly: Works seamlessly with platforms like Arduino and PlatformIO.
|
Harold Duarte Harold is an electronics engineer and senior technical content writer at RAKwireless. He is passionate about learning and developing new solutions for IoT, making it #IoTMadeEasy. |
Changelog
-
Version 1 - CAN Bus Vehicle Monitor with RAK WisBlock and Blues Notecard
- Author: Harold Duarte
- Reviewer: Caryl Enanor
- Date Published: 06/30/2025
Updated