Monitoring perishable goods along the distribution process with the LTE-M RDK

Perishable goods need accurate and real time monitoring at every step of the distribution and transport chain from producer to consumer.

Perishable goods need accurate and real time monitoring at every step of the distribution and transport chain from producer to consumer. Collecting data during this distribution process is crucial to guarantee the product quality meets the standards set by the producer to ensure the best customer experience. The most obvious application is for the distribution of goods that require to be kept within temperature and humidity thresholds at all times to ensure they do not perish.

IoT technologies can help to monitor such goods along the distribution chain starting at the moment of production, following on during transport and storage. It enables to be alerted in real-time when thresholds are in danger of being exceeded and offer valuable insights to producers and customers report over the distribution chain of a perishable item.

This experiment showcases how temperature & humidity are monitored periodically and send over using LTE-M towards to Maker. When a temperature and/or humidity threshold are exceeded, an asset state will be updated using an automation rule.

Assemble the hardware

First step is to make sure that you have the following hardware components nearby:

  • Sodaq SARA AFF
  • SIM Card
  • Temperature, pressure, humidity sensor (based on BME280)

 Afterwards assemble the hardware as detailed or depicted on the image below :

  • Insert the SIM card into the SIM card slot on the SARA AFF board
  • Connect TPH sensor to SCL/SDA (I2C socket)
  • Use the provided USB cable to connect Sodaq SARA AFF (USB port next to the SIM slot) to your computer 
hardware-schema-with-tph

Loading and setting up the sketch

Programs written using Arduino Software (IDE) are called sketches. These sketches are written in the text editor and are saved with the file extension .ino. In the following section we will program the hardware and send the collected sensor data to AllThingsTalk Maker:

  • Open Arduino IDE
  • Select MonitorPerishableGoods as example by clicking File > Examples > AllThingsTalk LTE-M SDK > Rapid Development Kit > MonitorPerishableGoods.
  • Open the keys.h tab. In this tab we have to provide some keys to ensure that the device is authenticated and has the correct settings (APN) for the cellular network of choice but also on the AllThingsTalk Maker platform.
  • Enter your keys; we tried to make it really simple:
    In the Maker application, and specific for the LTE-M Rapid Development Kit you have previously created, go to Settings > Authentication  (located in the upper right corner), and copy the DeviceID and Device Token and paste them accordingly in the Arduino IDE keys.h tab. 
  • Change the APN to "m2mc.simservices". 
  • When done, the keys.h tab should like this:
#ifndef KEYS_h

#define KEYS_h

// Enter your Allthingstalk device authentication

char* DEVICE_ID = "fgEjb8kvKZ5goFSHOnSBgiTi";

char* DEVICE_TOKEN = "maker:4NyvLLGa4Vf4m0lqFzNFnRZEjAxTH6MPfodzdUJ2";

// Enter APN of your LTE-M service provider

// See docs:

char* APN = "m2mc.simservices";

// Allthingstalk Space Endpoint (leave as is if unfamiliar)

char* SPACE_ENDPOINT = "api.allthingstalk.io";

#endif

Programming the hardware

We will now upload the sketch and keys to your LTE-M Rapid Development Kit, and when restarting the hardware data will be collected, and forwarded using the LTE-M network towards the AllThingsTalk platform.

  • Check again if your device is connected to your computer using the USB cable.
  • Make sure the SARA is detected by the Arduino IDE application by verifying it is listed and selected in Tools > Port
  • Now simply click the upload button (highlighted in the image below). This will verify the sketch and libraries, compile and upload to the LTE-M Rapid Development Kit.

Arduino Upload button

After uploading, you might need to reset the board by pressing the RESET button on the Sodaq SARA.


  • When the uploading was done and successful, the sensor readings will be collected, connection established and data will be displayed in AllThingsTalk Maker

     

Alternatively, you can also open the Tools > Serial monitor of the Arduino IDE. This can be very useful when debugging your own sketches.

  • Make sure you select the correct COM port to listen (under Tools > Port )
  • When the monitor is open, make sure the Baud rate is set to 115200

Sketch details


We have used the multi coloured LED on the SARA board to indicate the status of the device.


LED sequence/timeline

Enable extended debug. Get more insights on how the behaviour of the LTE-M RDK, the modem and/or network by enabling the Debug functions (verbose or verbose + AT) in the sketch. This can be done by changing adapting "att.debugPort" statement.

For Verbose debug:

att.debugPort(debugSerial,true);

 For verbose + AT commands:

att.debugPort(debugSerial,true,true);

Visualise and use the incoming data

If all went well you should see data coming in...

 

Learn more on how to visualise the data with Pinboards and make use of the data to automate your process or notify stakeholders using Rules.