Skip to content

Example Arduino code of using an Adafruit Feather M0 LoRa module to send sensor data.

License

Notifications You must be signed in to change notification settings

TheBluProject/Feather_M0_LoRa

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Feather M0 LoRa Node

Example Arduino code of using an Adafruit Feather M0 LoRa module to send sensor data.

This code has been tested with KotahiNet in New Zealand. It should be able to be used on any LoraWAN network with a little modification to the frequency plan.

Where possible I have included links to New Zealand suppliers of components. My go to is nicegear, followed by MindKits. Jaycar Electronics have a range of sensors but they're more expensive.

Things you need

Hardware

Software

Sending your first message

Connecting it up

To send the most basic "Hello World!" message you need to add two connections on the Feather board, and add an antenna. A straight 87mm long wire makes a perfect antenna to get started. Below are the connections needed:

Minimum wiring

Configuring the code

Open Feather_M0_LoRa.ino in the Arduino IDE and find the LoRaWAN Config section in the code.

Enter the Device Address, Network Session Key, and Application Session Key you recieved from KotahiNet.

eg If you recieved

Device address: 01234567
Network Session Key: 0123456789ABCDEF0123456789ABCDEF
Application Session Key: 0123456789ABCDEF0123456789ABCDEF

You would enter it as

// LoRaWAN Config
// Device Address
devaddr_t DevAddr = 0x01234567;

// Network Session Key
unsigned char NwkSkey[16] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };

// Application Session Key
unsigned char AppSkey[16] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };

Then click the Upload button in the Arduino IDE to compile the code and send it to your Feather. It will upload the code and it will start running. If you've configured the code correctly and you're in range of a KotahiNet receiver then you will have sucessfully sent your first messages.

Changing the startup message

To change the startup message, edit the STARTUP_MESSAGE value near the top of the code. This must be LESS THAN 40 CHARACTERS.

/**
 * Startup message to send
 */
#define STARTUP_MESSAGE "Hello World!"

Then Upload the code to the Feather again.

Adding a sensor

Barometric Pressure

Hardware

Easiest is to get a BMP085/BMP180/BMP280/BME280 breakbout board

And connect it up BMP085/BMP180 wiring

Software

Remove the comments in front of the sensor you have, eg

//#define SENSOR_BMP085           // BMP085
//#define SENSOR_BMP180           // BMP180
//#define SENSOR_BMP280           // BMP280
#define SENSOR_BME280           // BME280

Then Upload the code to the Feather again.

Humidity and Temperature

Hardware

Or a breakout board that has the resistor included

And connect it up DHT11/DHT22 wiring

Software

Remove the comments in front of the sensor you have, eg

//#define SENSOR_DHT11            // DHT 11
//#define SENSOR_DHT21            // DHT 21 (AM2301)
#define SENSOR_DHT22            // DHT 22 (AM2302)

Then Upload the code to the Feather again.

Light Intensity (TSL2561 sensor)

Hardware

And connect it up TLS2561  wiring

Software

Remove the comments in front of the sensor you have, eg

#define SENSOR_TSL2561          // TLS2561

Then Upload the code to the Feather again.

Light Intensity (BH1750FVI sensor)

Hardware

And connect it up BH1750  wiring

Software

Remove the comments in front of the sensor you have, eg

#define SENSOR_BH1750          // BH1750FVI

Then Upload the code to the Feather again.

Temperature (DS18B20 sensor)

Hardware

Or a breakout board that has the resistor included

And connect it up DS18B20  wiring

Software

Remove the comments in front of the sensor you have, eg

#define SENSOR_DS18B20         // DS18B20

Then Upload the code to the Feather again.

About

Example Arduino code of using an Adafruit Feather M0 LoRa module to send sensor data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Other 95.8%
  • C 4.2%