Originally published in Issue 40 of the DIYODE Magazine, November 2020.
IntroductionThere may be times where you need a project to monitor real-world conditions in a remote location and transmit that data to the end user wirelessly. It could be, for example, a series of remote pumping stations which are critical infrastructure for your property or operations. You may need to monitor the air quality for a buildup of gases in the pit, the flow rate to gauge the performance of the pump, and maybe the voltage of a backup battery. It could also be a remote weather station or access control system for the gates around your property.
It’s not practical for yourself or an employee to constantly travel to each site to monitor the system. Therefore, automation is your best solution.
The good news is that there are a number of ways you could do this. For example, back in Issue 21, we created a LoRa/Arduino-based IoT device, which in our testing was able to transmit data from a sender unit to a receiver over a distance of nearly 7.5km. At the time we were thoroughly impressed with the reach of this project but in hindsight, 7km is insignificant once you consider Australia covers an area of 7.692 million km². The distance problem aside, there are other issues that would make LoRa undesirable in this situation.
LoRa is a shared network that operates on the shared Industrial, Scientific and Medicine (ISM) UHF radio band between 915MHz - 928 MHz. This band does not require a license from the Australian government to transmit on, which means anyone is free to use the band, and as such, this small band could become congested.
The best way to explain this congestion is to imagine the ISM band as the space inside of a pub or bar, and you and your friends are clients in this bar, all communicating together in much the same way as IoT nodes do. As more and more people (clients) enter the venue, there is more and more background noise as the other clients are trying to communicate in the limited space of the venue. This leaves you with no other options but to repeat the same message.
If you don’t, your communication is simply drowned out by the accumulation of other communications. If your project is a simple weather station, LoRa can make sense as a few missed communications here and there will have minimal impact. However, if like in our hypothetical situation with a mission critical device, such as our remote pump stations, lost communications could be disastrous.
Cellular based IoT on the other hand uses a dedicated spectrum which the network provider tightly controls. Only approved clients can communicate in the space essentially creating a reserved VIP lounge for you and your friends.
So, what are your options if you need to communicate with a device over much greater distances than a LoRa node will allow or if you have a mission critical need? Well, thanks to the collaboration between Arduino and Telstra, we have the answer.
Arduino has developed the Arduino MKR NB 1500, an IoT ready 32-bit Arm Cortex M0+ based microcontroller development board with a u-blox SARA-R4 multi-band Long Term Evolution 4G (LTE-M) / NB-IoT narrowband module. The development board boasts 256KB of flash memory and 32KB of static RAM, which should give you quite a bit of space for programming.
In total there are 15 digital I/O pins D0 – D14 with 11 of these capable of PWM. On the analog side, we have 7 analog I/O pins, all of which can be used as a digital pin, and 2 can be used for PWM. Combined, this makes the MKR 1500 quite a feature packed development board with enough memory and I/O for even some challenging projects.
Of course, in this case, it’s all about the ability to transmit and receive signals from the project, and for that, we have the Telstra Machine to Machine (M2M) LTE-M network.
As you can see from the coverage map, this network covers an area of 3 million km² across Australia, providing service to the most populated areas. Thus, provided that your device is in range of the coverage map, you’re good to go.
An interactive map can be found here: https://www.telstra.com.au/business-enterprise/about-enterprise/our-network/iot-coverage-map
But what about any congestion? Well, that’s covered too. Unlike LoRa with its shared spectrum, the Telstra network is a dedicated spectrum network where only limited users are on the spectrum at the same time. Likewise, the base towers use software called a scheduler to work as a mediator, ensuring that devices are not trying to talk / communicate over the top of one another.
This prevents lost communications and also means that you can potentially use a lower transmit power. This is ideal for remote devices which may need to be battery powered as the size of the battery and associated supporting hardware, like solar panels, is reduced.
On top of these benefits, you also get multifaceted authentication security on the Telstra LTE-M network. Security has, until recently, generally been an afterthought in the IoT world. This could, in large, be a result of simplistic thinking.
Most of us would think that our IoT enabled coffee machine is fairly safe. After all, on face value, the worst someone can do if they were to take control is to ruin your morning coffee. However, it’s important to remember that your network security is only as safe as the weakest link.
If your coffee maker is attached to your Wireless Local Area Network (WLAN), a suitably skilled bad actor could potentially gain access to other devices on your network via your coffee machine. Take, for example, the North American Casino that was hacked in 2017. Hackers gained access to the system via an IoT fish tank monitor. Whilst clearly an extreme case, this goes to demonstrate how bad actors are progressing to more and more creative exploits.
As such, security is now becoming more and more the focus in IoT, especially in the corporate world where an IoT device could be used for corporate espionage. This makes Cell-based IoT devices that are not directly connected to your WiFi network much more attractive. With LTE-M networks, communication is validated using a Universal Integrated Circuit Card (UICC), which we often referred to as a Subscriber Identification Module or SIM card.
This card is the first step in authenticating access to the network. This mutual authentication ensures that not only is the device who it claims to be but also that the network / server is also who it claims to be.
To tie the two technologies together, Arduino has developed the IoT cloud. This allows you to not only very easily create IoT applications using the 1500 NB and Telstra network, but also access and display the data on any computer or mobile device anywhere in the world. This gives you the ability to not only check sensor data for your project anytime but also respond to it.
For example, let’s continue with our hypothetical pump station. This pump station has an issue where the flow of the pump needs to be controlled remotely. With this system, not only can you monitor real-world sensor data in real-time reliably, but you can also react in real-time, based on demand or even reactionary due to unforeseen situations.
Data planThanks to the collaboration between Arduino and Telstra, you can purchase the Arduino MKR NB 1500 board with a SIM from Telstra for $119, which includes 10MB per month of data for FREE for the first 6 months! We did the calculations, and that’s a lot of data for many IoT projects.
The amount of data you need will depend entirely on the type of project you’re creating. If you’re needing real-time up to the second sensor data then you will need more data compared to only needing updates every 10 seconds or so.
For example, an integer on the Arduino MKR NB 1500 is a 32-bit value. So, if you were to send a single 32-bit integer every second for a month you would use most of the 10MB per month plan. This is worked out as there are 2, 592, 000 seconds in a month so you would need 8.3 MB of data just for this value.
Note: This does not account for any overhead on top of the actual packet frame that is sent.
However, if you were to send the same integer every 10 seconds you would use just over 1MB, and if you were to drop it to 30 seconds, the data use would drop to 0.0108MB. The good news is this can all be easily controlled in the Arduino IoT Cloud software.
After the 6 months of free data, you will need to sign up for an M2M data plan. There are many plans to choose from based on the data you will use. They start from $2.40 for 100KB of data per month. You can check out the different plans here: https://diyode.io/040dataplans
Hands-On Prototype:Parts Required:
1 x Arduino MKR NB 1500 with Telstra M2M LTE-M Sim and account
1 x MQ4 Methane sensor (Core Electronics: SEN0129)
1 x MQ6 LPG Sensor (Core Electronics: SEN0131)
1 x MQ7 Carbon Monoxide Sensor (Core Electronics: SEN0132)
* A breadboard and prototyping hardware is also required.
The Prototype:Like many of our other reviews, we like to get hands-on with what we review, so let’s put the MKR NB 1500 board to the test using the Telstra narrowband network.
Our main goal to check out this hardware is to put it to work in a practical, albeit hypothetical, real-world application. Therefore, our first tinker with the hardware will be to create a simple remote air quality project that could be used in confined spaces to ensure that the space is safe for entry prior to sending personnel into the space.
Note: The sensors we are using are not designed, nor are they accurate enough, to be used in a situation where a person’s life is dependent on them. This is merely an example situation for which a person could implement this technology. We do not recommend you use this project for real-world confined space monitoring.
Our first look at the technology will be a simple single-sided communication example in which the unit is simply sending sensor data. In the near future, we intend to create a larger bi-directional communication project where we not only receive sensor data but have the ability to remotely control devices as well.
We have provided a parts list, Fritzing diagram, code, and build instructions if you want to replicate this project for yourself.
We used sensors that we already had in our parts storage for this project. The identical part may not be obtainable from your local electronics retailer, however, we have listed similar sensors made by DFRobot. These are available at Core Electronics and use the same sensor technology as the sensors we used, however, the footprints are different.
3-Pin Sensor Pinout
4-Pin Sensor Pinout
The GPIO pins on the Arduino MKR NB 1500 do not support 5V. As such, we need to ensure that the input from the sensors does not exceed 3.3V. At max concentration, the sensors are capable of outputting 4V on the analog output which could potentially damage the Arduino MKR NB 1500. As such, we will implement a voltage divider to drop the voltage to below the 3.3V max. For our demonstration, we will simply use a voltage divider with R1 and R2 both set to 10KΩ, which will drop the output by half. This means the Arduino will be safe, but it will reduce the accuracy of the sensor readings.
If we were developing this as a proper project, we would implement a more precise method of limiting the voltage without affecting the accuracy of the sensor. As a demo, however, it works fine.
Regardless of which sensor you use, you need to wire the sensor so that the analog output pin of the sensor goto a 10KΩ - 10KΩ voltage divider with the junction of the divider going to an analog pin of the Arduino MKR NB 1500. Likewise, each of the sensors needs 5V and ground applied to them. All three must share common ground with the Arduino MKR NB 1500.
For our project, we powered the Arduino MKR NB 1500 via the USB port and powered the sensors from a separate 5V supply. We did this because the three sensors combined can require as much as 350mA and we didn’t want our PC to be providing that much current during programming. Once you have finished programming the Arduino, you can directly power the Arduino and sensors from the same 5V source using the Vin pin.
Arduino Create IoTWith the circuit created, we turned our attention to programming the device. This was done entirely through the Arduino Create IoT cloud, which you can find here: https://create.arduino.cc/iot/
Using the Arduino Create IoT Cloud to build the project is incredibly simple. Essentially, it’s a 4 step process:
- Create a Device
- Create a Thing
- Create a Sketch
- Create a Dashboard
With these simple steps done, you will have a functioning IoT device on the Telstra M2M cellular network, which can send the sensor data to any location on Earth provided the device is located within the coverage area. An immensely impressive feat given the very small amount of time it takes to get the program running.
We’ll describe these steps in further detail.
Create a DeviceCreating / setting up the device will be straightforward for most makers. In our case, however, we were plagued with the same issue that we encountered with the Portenta H7 development board review. This range of microcontrollers do not have a dedicated USB to serial converter chip. Instead, they use the microcontroller itself to handle the USB comms, which is perfectly fine for the vast majority of makers but on our Windows desktop PC we had to manually force the microcontroller into bootloader mode. We did this by pressing the reset button in twice within a second and then selected the new com port which comes up. We had to repeat this process several times to get the timing right to be successful though. In the end, we found it easier to swap to our Windows laptop, which did not have the same issue. Thus, if you’re having difficulty connecting the board, your first attempt to troubleshoot should be to try on a different computer.
To get started, point your web browser to the Arduino Create IoT website: https://create.arduino.cc/iot/
If not done so already, you will need to create an account or log in.
Select Devices from the top menu.
Select the Add Device button.
Select the 'Set up an Arduino device' button.
After a few seconds you may be asked to install the Arduino Create Agent plugin. Install this and eventually, you will be greeted with a screen identifying that the software has found a compatible Arduino device connected.
If this is your device, select the configure button.
After doing so, you will be provided with a randomly generated name. We recommend that you change this name to something that will identify its use. For our example, we will call it the DIYODE_MKR_1500.
Once you have entered an appropriate name, select the next button. The Create software will now create an instance of your device. During this process the software appears to upload a sketch to the development board and does a series of checks and tests.
Note: In our test, this is where we found some issues, seemingly stemming from the USB / Bootloader problems mentioned previously. If you’re getting error messages here, try a different computer and or putting the device in bootloader mode before adding the name above.
If all went well, you should be greeted with the window shown here.
If it didn’t work, you may be shown a worrying message like the one shown here. If so, don’t despair. We had the same error and there was nothing wrong with our hardware. We simply repeated the process and it worked fine.
With the device correctly set up, you can now set up the overall project, which Arduino Create calls a “thing”. In our example, our “thing” is going to be a gas sensor, and thus, our thing will be named DIYODE_Gas_Sensor.
Simply name your thing and then link it to the device created and named in the previous step.
From here, select the Add Property button which will allow you to add instances of properties, such as your sensors. Doing this automatically generates the code to handle the transmission of the expected data from this property.
This will bring you to the following screen in which you can select from an entire gamut of features for the property you’re adding.
For us, the property is going to be a sensor so we will name it after the sensor to make it clear what sensor we are referring to.
The Variable name is the name that we need to reference in the code. This name should be relevant to the sensor used which will make it easier during the coding process.
Our sensor is an analog sensor, and as such, we expect it is going to return a positive number between a minimum of 0 and a maximum of 1024, assuming a 10-bit ADC. As such, we can define the type as an int, for integer, and set the min and max values accordingly.
For permission, we set them as read only which makes sense as we only need to receive an analog signal from them.
Update is set to Regularly and with a period of 30 seconds. As we said earlier, the amount of data you’re sending will dictate the amount of data you will use on your plan. If you don’t need up to the second data you can save costs by increasing the period.
We also selected Show history visualization, which seemingly stores the historical data in the Arduino Cloud, allowing us to view it later after creating the dashboard.
Our property screen looked like the one shown here.
Repeat the process until all of your sensors have been added.
Next, select the Edit sketch button in the top right corner to begin the coding section.
To add more than five properties to your project you will need to have an account and a paid Maker plan with Arduino, which will give the benefits as listed here. The Maker plan can be purchased directly from the Arduino Digital Store and will cost $6.99 USD per month. https://store.arduino.cc/digital/create
The next step should be a more familiar step for anyone who has used Arduino before, which is the coding. What’s impressive here is the automation. Arduino takes care of all of the communication side of things based on your selections in the adding of a property. There is no ‘big brain’ work needed.
All we need to do is create a simple sketch that puts the desired sensor value into a variable, matching the variable name or names we created earlier. The Arduino software takes care of the transmission and timing without us needing to lift a finger.
That makes our coding task incredibly simple.
For us, we simply use the AnalogRead() function to read the analog pin the sensor is connected to and put that value into the corresponding variable. We don’t need to convert anything as we can just transfer the raw data as shown here.
#include "thingProperties.h"
int readSensor;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
Serial.println("Hello world");
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
// Your code here
sensor1 = analogRead(1);
carbonMonoxide = analogRead(2);
methaneSensor = analogRead(3);
Serial.println(sensor1);
Serial.println(carbonMonoxide);
Serial.println(methaneSensor);
delay(1000);
}
If you want to process your data and not simply send the raw data out, that is just as simple. All you need to do is perform the mathematical operations on the sensor value, and once completed, put the result into the corresponding variable name created in the Add property section. To help you, Arduino has included these variable names in the comments of the generated code.
Once you’re happy with your code you can upload it to the development board. Plug the board into the USB on your computer and upload it directly from this web interface.
After this, your last step is to create a dashboard so you can view the data from the device.
Create a dashboardFrom the Arduino Create IoT homepage select the Dashboards button.
Select Add and you will see a list of graphical elements. These can be used to provide I/O or otherwise display data coming from, or going to, the IoT device.
For our project, we scrolled to the very bottom of the list and selected the chart option. This will allow us to easily graph and display the raw sensor data in a way that is easy to understand and instantly gauge.
Of course, if you want to experiment here you will surely find many interesting ways to interact and display data coming from your device. A quick look certainly gave us some inspiration for future use cases for this exciting hardware.
After selecting the way to display the data (in our case using the graph element) you can then position the element on the GUI dashboards workplane. You then need to link the element to a specific property. For us, we linked this graph to the carbon monoxide sensor.
Repeat the same procedure to add other elements and linking them to the desired property.
Arduino has created a mobile application called Arduino IoT Cloud Remote which allows you access to the exact same dashboard, albeit modified to fit a mobile phone screen.
ANDRIOD: https://play.google.com/store/apps/details?id=cc.arduino.cloudiot
APPLE: https://apps.apple.com/us/app/id1514358431
Based on the success of our hands-on test, we are incredibly impressed with the performance and ease of use that the Arduino hardware and Telstra’s network provides.
As such, we are very excited to see where and how the community implements projects using this system.
We can see a huge amount of niche applications from automotive devices used to locate and disable a stolen vehicle to water management projects on remote agricultural land, mining sites, etc.
This combination really puts incredible power into the hands of hobbyists, which only a few years ago would seem fantastical.
Shopping ListThe Arduino MKR NB 1500 board + antenna with Telstra SIM and 10MB FREE DATA for 6 months is available from Telstra Online for A$119
https://dev.telstra.com/iot-marketplace/arduino-mkr-nb-1500
Entire Article:The entire article was published in Issue 40 of the DIYODE Magazine, November 2020.
Comments