London, UK

+44 (0) 20 3290 3080

hello@dothex.net

Embedded Systems & Product Development Consultancy · London, UK

A secure NB-IoT agricultural sensor, from schematic to AWS IoT Core

At a glance

  • Industry: Agriculture, remote monitoring
  • Client: An agricultural technology company
  • Location: Western Australia, Australia
  • Our role: Electronics and PCB design, firmware, over-the-air updates, AWS IoT Core integration and dashboard, board bring-up and debugging
  • Platform: Microchip SAMD (Arm Cortex-M0+); NB-IoT (LTE Cat NB1) modem with eSIM and nano-SIM
  • Key technologies: C++, NB-IoT, MQTT, AWS IoT Core (Device Shadow, Rules engine, IoT Jobs), Amazon S3, Amazon QuickSight, X.509, SHA-256 secure element, OTA updates, USB-C, RS-232, Li-Po battery management, Altium
  • Services: Product development · Electronics & PCB design · Embedded software & firmware · Hardware/software integration
  • Outcome: Pilot units installed in the field, reporting soil data to AWS IoT Core and a dashboard covering several devices

The challenge

Soil conditions change across a farm, and the places worth measuring are rarely near mains power or Wi-Fi. The client wanted a sensor that is buried in the ground and left there, measuring soil moisture, temperature and mineral content, and sending its readings to the cloud without anyone visiting it.

That set the requirements. The device had to run for long periods on a battery, reach the cloud over the mobile network from rural sites, prove its identity to the cloud so that only genuine devices could send data, and take firmware updates without being dug up. The client also needed to see the data from several devices in one place.

Our role

We designed the device end to end, working remotely with the client’s team in Western Australia: the schematic and PCB, firmware in C++, the security set-up, the connection to AWS IoT Core and the dashboard on the AWS side. We brought up and debugged the boards, and pilot units were then installed in the field.

Block diagram of the NB-IoT soil sensor built around a Microchip SAMD microcontroller, connected to AWS IoT CoreNB-IoT soil sensorAWSSoil sensormoisture · temperaturemineralsUSB-C portconfiguration, debuggingand chargingMicrochip SAMDArm Cortex-M0+ · C++Sensor samplingconfigurable interval,hourly by defaultMQTT clientX.509 · TLSOTA updatesfirmware viaAWS IoT JobsNB-IoT modemLTE Cat NB1power-saving modeseSIM + nano-SIMswitchableSecure elementSHA-256X.509 identityLi-Po batteryaround two yearsbetween changesBattery managementUSB-C chargingAWS IoT CoreMQTT over TLS · X.509Thing registryand policiesDevice Shadowdevice settingsRules engineroutes readingsIoT JobsOTA updatesAmazon S3sensor data · firmware imagesAmazon QuickSightdashboard for several devicesPCconfiguration and debugging over USBProductioncertificates loaded into the secure elementRS-232readingsfirmwarewww.dothex.net

System architecture

The device is built around a Microchip SAMD microcontroller (Arm Cortex-M0+), with firmware written in C++. It reads a soil sensor, wakes the NB-IoT modem to send the readings over MQTT to AWS IoT Core, and spends the rest of its time asleep.

  • Sensing: a soil sensor connected over RS-232, measuring moisture, temperature and mineral content.
  • Connectivity: an NB-IoT (LTE Cat NB1) modem with both an eSIM and a nano-SIM, and the device can switch between them when needed.
  • Security: a SHA-256 secure element holding each device’s X.509 identity, loaded during production.
  • Power: a Li-Po battery with battery management, recharged over USB-C.
  • Service and updates: USB for configuration and debugging from a PC, and firmware updates over the air.

Hardware for a sensor that lives underground

We designed the schematic and PCB in Altium, with EMC and EMI in mind from the start, around the SAMD microcontroller, the NB-IoT modem, the secure element, the battery management circuit and the sensor interfaces. The electronics had to suit a unit that is buried in the soil and left alone for long periods. Once the first boards were built, we brought them up and debugged them before the firmware work moved on.

Two SIM options

The modem carries both an eSIM and a nano-SIM, and the device can switch between them. That gives the client a choice of how each unit connects, and a way to move to another option when one does not suit a site.

Years on a battery

A buried sensor cannot be plugged in, so power drove most of the firmware design. The device sends its readings at a configurable interval, hourly by default, and sleeps in between. We used the NB-IoT modem’s power-saving modes so that the radio is only awake when it has data to send. The result is around two years between battery changes, and the Li-Po battery recharges quickly over USB-C.

Security from the production line

Each device has its own X.509 certificate, held in a SHA-256 secure element and loaded during production. The device uses it to authenticate to AWS IoT Core over MQTT, so the cloud only accepts data from devices it knows, and a device’s identity cannot be copied from its firmware.

From field to dashboard

We integrated the AWS side as well as the device. Each unit is registered in AWS IoT Core as a thing, with its certificate and an IoT policy that limits what it may do. Readings arrive over MQTT, and a rule in the AWS IoT rules engine stores them in Amazon S3, where Amazon QuickSight presents them as a dashboard covering several devices. Device settings such as the reporting interval are kept in the Device Shadow, so they can be changed from the cloud and picked up the next time the unit connects. Firmware images are also kept in S3 and delivered over the air as AWS IoT Jobs, so units in the field can be updated without being dug up, while USB stays available for configuration and debugging on the bench.

Results

  • Pilot units installed in the field, reporting soil moisture, temperature and mineral data.
  • One team for the schematic, PCB, firmware, cloud connection and dashboard.
  • Around two years between battery changes, with hourly reporting by default.
  • A unique X.509 identity in a secure element for each device, loaded during production.
  • Firmware updated over the air, with eSIM and nano-SIM options on every unit.

Collecting data from places without power or Wi-Fi?

Latest from the blog