IOTA

 
 
IOTA is an open-source distributed ledger. It uses a directed acyclic graph (DAG) instead of a blockchain.
IOTA's DAG is referred to as the tangle, and is a generalization of the block chain protocol.

More information about IOTA can be found at:
http://iota.org/







Send DHT11 sensor data using the Things Uno and The Things Network to IOTA Tangle using Masked Authenticated Messaging (MAM)



Information
The source codes used in this tutorial can be found at:
https://github.com/robertlie/dht11-ttn

Operating system used
macOS 10.13 High Sierra

Hardware used
  • The Things Gateway
    https://www.thethingsnetwork.org/docs/gateways/gateway/

    Specification:
    • LoRaWAN compatible
    • 868 MHz (EU) or 915 MHz (US) Microchip LoRa module
    • Provides up to 10 km / 6 miles radius of network coverage
    • Can serve up to 10000 nodes (depending on traffic)
    • Connects easily to your WiFi or Ethernet connection
    • Contains a XBEE slot for future connectivity protocols or homebrew add-ons
    • Security through the https connection and embedded in the LoRaWAN protocol
    • Devices can freely communicate over all gateways connected to The Things Network
    • Bluetooth 4.2 included
    • Engage with a global community of IoT developers
    • Easy cloud integration with popular IoT platforms
    • Based on open source hardware and software standards
    • Use a 868 MHz / 915 MHz tuned, 50 Ohm impedance antenna for use with the SMA connector

    The Things Gateway top view

    The Things Gateway bottom view

    The Things Gateway cover removed

    The Things Gateway board

    The Things Gateway LoRa module

    The Things Gateway antenna connector

    The Things Gateway antenna length

    The Things Gateway power and ethernet connection

  • The Things Uno Wireless Microcontroller Board
    https://www.thethingsnetwork.org/docs/devices/uno/

    Specification:
    • The Things Uno was designed with a low barrier for building proof of concepts for IoT projects using LoRaWAN compliant network
    • 16MHz ATmega32U4 MCU with 32KB Flash memory
    • 2.5KB RAM, 1KB EEPROM
    • On-board 868MHz (EU) or 915MHz (US) Microchip RN2483 LoRa transceiver module (with on-board antenna)
    • Range up to 10km/6 miles
    • An optional external antenna (mounting pads for SMA) can be added to maximize the range
    • Recognised by Arduino IDE as an Arduino Leonardo
    • Arduino UNO R3 shield compatible
    • Based on open source standards
    • Devices can freely communicate over all gateways connected to The Things Network

    The Things Uno top view

    The Things Uno bottom view

    The Things Uno side view

  • USB 2.0 cable, USB-A > Micro USB-B (length: 1 m)

    USB A - micro USB-B

  • The Things Gateway power supply (length: 1.50 m)

    The Things Gateway power supply

  • Jumper wires (3x female-male; 20 cm long)

    Jumper wires female-male

  • DHT11 sensor module (DHT = Digital Humidity Temperature)

    Specification:
    Supply voltage: 3.3 ~ 5.5V DC
    Output: single-bus digital signal
    Measuring range: humidity 20-90% RH, temperature 0 ~ 50°C
    Accuracy: humidity ±5% RH, temperature ±2°C
    Resolution: Humidity 1% RH, temperature 1°C
    Long-term stability: < ±1% RH / Year

    DHT11 sensor

Software prerequisites
none

Procedure
  1. Before you start, please note this tutorial was specifically written for macOS users.

    I also assume: You have The Things Gateway and have activated it, see:



    Note:
    You do not need The Things Gateway (= LoRa Gateway) if there is one nearby and is connected to The Things Network.
    To check if a LoRa Gateway is nearby and is connected to The Things Network:
    https://www.thethingsnetwork.org/map

    You have The Things Uno and you already have followed these tutorials:







  2. In the "How To: The Things Uno Part 3 - Connecting Sensors" tutorial, the DHT22 sensor is used.
    In my tutorial I am using the DHT11 sensor module instead.

    Connect the DHT11 sensor module to The Things Uno using the jumper wires.

    The Things Uno DHT11
    GND GND
    pin 2 DATA
    3.3V VCC


    DHT11 sensor module connected to The Things Uno

  3. Download the dht11-ttn project on your computer:
    Type: git clone https://github.com/robertlie/dht11-ttn.git

  4. Upload the dht11-ttn/sketches/dht11/dht11.ino sketch to The Things Uno and run this sketch.
    • Start Arduino IDE.
    • Use the Arduino IDE Library Manger and install the following libraries:
      • TheThingsNetwork (by The Things Network)
      • DHT sensor library (by Adafruit)
    • Select menu: Tools > Board > Arduino Leonardo
    • Select the port, select menu: Tools > Port > /dev/cu.usbmodem1421
      Note: Your port name may differ.
    • Modify the dht11.ino sketch, select menu: File > Select the dht11.ino file.
      Update the appEui, appKey and freqPlan according to your situation.

    • Press the verify button to verify the sketch. Make sure there are no errors.
    • Press the upload button to upload the sketch to The Things Uno.
    • Open the Serial monitor, select menu: Tools > Serial Monitor.
      Make sure the baud rate is set to 115200 baud (bottom right)

      Sketch output displayed in serial monitor

      The temperature and humidity is displayed every 10 second.

    • Log into The Things Network console.
      Select the correct app and device to see the logged data.

      The Things Network console

      Note:
      To display readable data, the following decoder payload function format is used:

      function Decoder(bytes, port) {
         var humidity = (bytes[0]<<8) | bytes[1];
         var temperature = (bytes[2]<<8) | bytes[3];
         return {
            humidity: humidity/ 100,
            temperature: temperature/100
         }
      }


      As demonstrated The Things Network server receives the temperature and humidity data.

    • Close the serial monitor

  5. Test if the temperature and humidity data can be extracted from The Things Network server using a nodeJS application.
    • Open a terminal
    • Type: cd dht11-ttn
    • Modify the dht_ttn.js file by entering your appID and accessKey.

      The appID can be found here:
      Application ID

      The accessKey can be found here:
      Access key

    • Type: npm install

      Type: node dht_ttn.js

      dht_ttn.js output

      As you can see the temperature and humidity data can be extracted from The Things Network server as well as other information.


  6. Test if the temperature and humidity data can be extracted from The Things Network server using a nodeJS application. This node application in turn stores the sensor data on the Tangle using Masked Authenticated Messaging.
    • Open a terminal
    • Type: cd dht11-ttn
    • Modify the dht_ttn_mam.js file by entering your appID and accessKey.

      The appID can be found here:
      Application ID

      The accessKey can be found here:
      Access key

    • Type: node dht_ttn_mam.js

      dht_ttn_mam.js output

    • Open another terminal and type: node mam_receive.js your_root
      The stored data is displayed.

      mam_receive.js output