Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Majed Abouhatab, P.E.
Published © LGPL

Where Do Sparkies Come From? The LoRa Prequel

An answer to one of life's most awkward questions.

IntermediateFull instructions provided3 hours522

Things used in this project

Hardware components

Helium Developer Kit
Helium Developer Kit
×1
Arduino Pro Mini 328 - 3.3V/8MHz
SparkFun Arduino Pro Mini 328 - 3.3V/8MHz
×1
RFM95W
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Wiring and Connections

Code

ARDUINO_STM32L0_B_L072Z_LRWAN1

Arduino
Upload this code to B-L072Z-LRWAN1.
#include "LoRaRadio.h"
const int Green = 4;
const int Red = 5;
const int Blue = 10;
void setup()
{
  pinMode(Red, OUTPUT);
  pinMode(Green, OUTPUT);
  pinMode(Blue, OUTPUT);
  pinMode(BUTTON, INPUT);
  LoRaRadio.begin(915E6);
}
void loop() {
  if (!digitalRead(BUTTON)) {
    digitalWrite(Blue, 1);
    LoRaRadio.beginPacket();
    LoRaRadio.print("SPARKY");
    LoRaRadio.endPacket();
    LoRaRadio.purge();
    delay(1000);
    LoRaRadio.receive();
    delay(1000);
    LoRaRadio.parsePacket();
    String txt = "";
    while (LoRaRadio.available()) txt += char(LoRaRadio.read());
    if (txt=="WOOF")digitalWrite(Green, !digitalRead(Green));
    digitalWrite(Blue, 0);
  }
}

ARDUINO_AVR_MINI

Arduino
Upload this code to Arduino Pro Mini.
#include <SPI.h>
#include <LoRa.h>
// Dog specific
String Marco = "SPARKY", Polo = "WOOF";

void setup() {
  // Only use SS and no reset or dio0
  LoRa.setPins(SS, -1, -1);
  // External switch
  pinMode(4, OUTPUT);
}

void loop() {
  // 915 MHz
  LoRa.begin(915E6);
  // Make sure you are getting right size
  while (LoRa.parsePacket() != Marco.length());
  String txt = "";
  // Build the string
  while (LoRa.available()) txt += char(LoRa.read());
  // Are you calling my name?
  if (txt == Marco) {
    // External switch on then off
    digitalWrite(4, 1);
    delay(100);
    digitalWrite(4, 0);
    delay(1000);
    // Reply to the call
    LoRa.beginPacket();
    LoRa.print(Polo);
    LoRa.endPacket();
  }
  LoRa.end();
}

Credits

Majed Abouhatab, P.E.
54 projects • 41 followers
Electronics Professional Engineer, Pilot, Skydiver, Runner, and World Traveler.
Contact

Comments

Please log in or sign up to comment.