/LoRa-Environmental-Sensors

ATtiny85 based LoRa atmospheric sensor board with BME280

Primary LanguageOpenSCAD

LoRa Environmental Sensors

Arduino based board for a Atmospheric Sensor BME280 LoRaWan Node. The LoRa Node measures barometric pressure, humidity, and temperature every 5 min. After the measurements, the ATtiny85 goes into sleep mode and is awakened by the watchdog timer. The RFM module sends the values to the TTN backend with Activation by Personalization (ABP) a fixed spreading factor and one of the four random channels. This project is based on the TinyLoRa-BME280 project [1].

BOM

Ref Value Description
BT1 3034 Battery Cell Holder
BT1 CR2032 Battery Cell CR2032 (210 – 230 mAh)
U1 BME280 SparkFun BME280
U2 ATtiny85-20SU Atmel 8-bit AVR Microcontroller
U3 RFM95W-868S2 Low Power Long Range Transceiver Module
- Wire Wire for the antenna, 8.6 cm

The ATmega microprocessor needs an arduino bootloader. To burn a bootloader to the blank chip see [2]

Wiring

ATtiny85 RFM95 BME280
PB3 CS (Slave Select)
PB4 NSS (Slave Select)
PB2 SCK SCK
PB1(DO) MOSI SDI
PB0(DI) MISO SDO

Installation

The Arduino IDE has to be properly installed.

Add the Libraries to you IDE:

  • Install the Attiny Baord Manager

    Multiple managers can be separated with a comma.

  • Install TinyLoRa-BME280 v1.1

    • Download the ZIP archive from TinyLoRa-BME280 v1.1
    • Install the ZIP archive in the Arduino Library Manager
  • Open Examples > TinyLoRa-BME280_v1.1-master > ATtiny_LoRa_BME280

    • Edit NwkSkey, AppSkey, DevAddr
    • Change the Spreading Factor in ATtinyLoRa.cpp
    • The Sleep time can be set with the SLEEP_TOTAL var.
  • Burn the sketch to the Chip using an Arduino UNO [2]

    • Burn a bootloader first to set the fuses correctly

Payload Format

The Payload is encoded as byte array.

byte content
0..1 temperature (*100)
2..3 humidity (*100)
4..8 barometric pressure

To decode the values add this code in the TTM Console as decoder under Paload Formats.

function Decoder(bytes, port) {
  temp = ((bytes[0]) << 8)
              + ((bytes[1]));
  hum = ((bytes[2]) << 8)
              + ((bytes[3]));
  pres = ((bytes[4]) << 24)
              + ((bytes[5]) << 16)
              + ((bytes[6]) << 8)
              + ((bytes[7]));

  return {
    pressure: ( pres / 100 ),
    temperature: ( temp / 100 ),
    humidity: ( hum / 100 )
  };
}

Links

  1. TinyLoRa-BME280 v1.1
  2. Programming ATtiny85 with Arduino Uno

License

License CC BY 4.0 - Attribution 4.0 International