Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this library really support US915? #100

Open
MichaelBla opened this issue Aug 24, 2021 · 5 comments
Open

Does this library really support US915? #100

MichaelBla opened this issue Aug 24, 2021 · 5 comments
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@MichaelBla
Copy link

MichaelBla commented Aug 24, 2021

I can't get this to connect in the US although I can see it try in my gateway.

I can't find anyone else having success with this in the US so I wonder if it has been tested here.

@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Aug 25, 2021
@terryzar
Copy link

It does work in US915. Besides, your gateway sees it, ensure the keys are set exactly the same on both ends and both are configured for the same joining method (OTA or ABP).
For joining, use US915_HYBRID, not just US915. Now the sensor will transmit on LoRa channels 1 through 8 instead of all 64 channels (your gateway likely does not support all 64 channels).
We are using a Multtitech Conduit Gateway so we also set the ADR mode to 0 and dataRate to 0.

@MichaelBla
Copy link
Author

MichaelBla commented Aug 27, 2021 via email

@hpssjellis
Copy link

hpssjellis commented Aug 30, 2021

I am having success with the Helium network in North America using the new MKRWAN feature on the Portenta where you can enable channels:

For TTN I think you have to enable the "0" channel, can someone check:

  modem.disableChannel(0);
  modem.enableChannel(1);    // only one enabled for Helium

Demo program here

Here is the code I am using:

/*
  Helium Send And Receive
  This sketch demonstrates how to send and receive data with the MKR WAN 1300/1310 LoRa module.
  This example code is in the public domain.
  note: Helium must be setup for what it does with the CayenneLPP encoded data
*/

#include <MKRWAN.h>
#include <CayenneLPP.h>


LoRaModem modem;
CayenneLPP lpp(51);
bool connected = false;

// Please enter your sensitive data in the Secret tab or arduino_secrets.h
// Note: Best to have the App_Device hard coded. Run the program once to see the value.
//#include "arduino_secrets.h"
#define SECRET_APP_EUI "0000000000000000"
#define SECRET_APP_KEY "0000000000000000000000000000000"

String appEui = SECRET_APP_EUI;   // just strings of the above 
String appKey = SECRET_APP_KEY;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(LEDR,OUTPUT);
  pinMode(LEDG,OUTPUT);
  pinMode(LEDB,OUTPUT);
  digitalWrite(LEDR, HIGH); // new boards HIGH = off
  digitalWrite(LEDG, LOW);
  digitalWrite(LEDB, HIGH);
  
  //while (!Serial);       // don't wait for serial
  
  Serial.println("Wait 4");
  delay(3000);             // delay instead, so it works when disconnected
  digitalWrite(LEDG, HIGH);// allows time to connect serial monitor

  Serial.println("Wait 3");
  delay(3000);       
  digitalWrite(LEDG, LOW);
 
  Serial.println("Wait 2");
  delay(3000);       
  digitalWrite(LEDG, HIGH);

  Serial.println("Wait 1");
  delay(3000);       
  digitalWrite(LEDG, LOW);
  
  // change this to your regional band (eg. US915, AS923, ...)
  if (!modem.begin(US915)) {
    Serial.println("Failed to start module");
    while (1) {}
  };
 
  Serial.print("Your module version is: ");
  Serial.println(modem.version());
  Serial.print("Your device EUI is: ");
  Serial.println(modem.deviceEUI());

  myPrintMask();
  delay(3000);
  Serial.println("Now Disabling all channels and enable channel 1 only for Helium ");

  modem.disableChannel(0);
  modem.enableChannel(1);    // only one enabled for Helium
  modem.disableChannel(2);
  modem.disableChannel(3);
  modem.disableChannel(4);
  modem.disableChannel(5);
  modem.disableChannel(6);
  myPrintMask(); 
  delay(3000);
  myPrintMask();
  Serial.println("Now Joining the Helium Network ");
}

void loop() {

  while (!connected) {
    Serial.println("trying to reconnect");
    digitalWrite(LEDR, LOW); // new boards HIGH = off
    digitalWrite(LEDG, LOW);
    digitalWrite(LEDB, HIGH);
    connected = modem.joinOTAA(appEui, appKey);
    delay(5000);    
    digitalWrite(LEDR, HIGH); // new boards HIGH = off
    digitalWrite(LEDG, LOW);
    digitalWrite(LEDB, HIGH);
    delay(1000);
  }

  lpp.reset();
  float x = rand() / 10000000.0; //analogRead(A0)
  lpp.addTemperature(1, x); 

  
  /*
  // Can do any of these
  lpp.reset();
  lpp.addDigitalInput(1, 0);
  lpp.addDigitalOutput(2, 1);
  lpp.addAnalogInput(3, 1.23f);
  lpp.addAnalogOutput(4, 3.45f);
  lpp.addLuminosity(5, 20304);
  lpp.addPresence(6, 1);
  lpp.addTemperature(7, 26.5f);
  lpp.addRelativeHumidity(8, 86.6f);
  lpp.addAccelerometer(9, 1.234f, -1.234f, 0.567f);
  lpp.addBarometricPressure(10, 1023.4f);
  lpp.addGyrometer(1, -12.34f, 45.56f, 89.01f);
  lpp.addGPS(1, -12.34f, 45.56f, 9.01f);

  lpp.addUnixTime(1, 135005160);
  
  lpp.addGenericSensor(1, 4294967295);
  lpp.addVoltage(1, 3.35);
  lpp.addCurrent(1, 0.321);
  lpp.addFrequency(1, 50);
  lpp.addPercentage(1, 100);
  lpp.addAltitude(1 , 50);
  lpp.addPower(1 , 50000);
  lpp.addDistance(1 , 10.555);
  lpp.addEnergy(1 , 19.055);
  lpp.addDirection(1 , 90);
  lpp.addSwitch(1 , 0);
  
  lpp.addConcentration(1 , 512);
  lpp.addColour(1 , 64, 128, 255);
  
  */

  Serial.println();
  Serial.println("Sending:" + String(x, 1));

  
  Serial.println();

  int err;
  modem.beginPacket();
  modem.write(lpp.getBuffer(), lpp.getSize());
  err = modem.endPacket(true);
  if (err > 0) {
    Serial.println("Message sent correctly!");
    digitalWrite(LEDR, HIGH); // new boards HIGH = off
    digitalWrite(LEDG, HIGH);
    digitalWrite(LEDB, HIGH);
  } else {
    Serial.println("Error sending message :(");
    Serial.println("(you may send a limited amount of messages per minute, depending on the signal strength");
    Serial.println("it may vary from 1 message every couple of seconds to 1 message every minute)");
    digitalWrite(LEDR, LOW); // new boards HIGH = off
    digitalWrite(LEDG, HIGH);
    digitalWrite(LEDB, LOW);
  }
  delay(1000);
  if (!modem.available()) {
    Serial.println("No downlink message received at this time.");
    return;
  }
  char rcv[64];
  int i = 0;
  while (modem.available()) {
    rcv[i++] = (char)modem.read();
  }
  Serial.print("Received: ");
  for (unsigned int j = 0; j < i; j++) {
    Serial.print(rcv[j] >> 4, HEX);
    Serial.print(rcv[j] & 0xF, HEX);
    Serial.print(" ");
  }
  Serial.println();
  digitalWrite(LEDR, HIGH); // new boards HIGH = off
  digitalWrite(LEDG, HIGH);
  digitalWrite(LEDB, LOW);
  delay(30000);  // delay 30 seconds for testing
}



void myPrintMask(){ 
  delay(30);
  Serial.println("Your module version is: " + String(modem.version()) ); 
  delay(30);
  Serial.println("getDataRate: " + String(modem.getDataRate()) );
  delay(30);
  Serial.println("getADR: " + String(modem.getADR()) );
  Serial.println("getRX2Freq: " + String(modem.getRX2Freq()) );
  Serial.println("getRX2DR(): " + String(modem.getRX2DR()) );
   
  Serial.println("getFCU: " + String(modem.getFCU()) );
  Serial.println("getFCD: " + String(modem.getFCD()) );
  delay(30);
  Serial.println("getChannelMask: " + String(modem.getChannelMask()));
  delay(30);
  
  Serial.println("isChannelEnabled(0): " + String(modem.isChannelEnabled(0)));
  delay(30);
  Serial.println("isChannelEnabled(1): " + String(modem.isChannelEnabled(1)));
  delay(30);
  Serial.println("isChannelEnabled(2): " + String(modem.isChannelEnabled(2)));
  delay(30);
  Serial.println("isChannelEnabled(3): " + String(modem.isChannelEnabled(3)));
  delay(30);
  Serial.println("isChannelEnabled(4): " + String(modem.isChannelEnabled(4)));
  delay(30);
  Serial.println("isChannelEnabled(5): " + String(modem.isChannelEnabled(5)));
  delay(30);
  Serial.println("isChannelEnabled(6): " + String(modem.isChannelEnabled(6)));
  delay(30);
  Serial.println("-------------------------------");
}

@MichaelBla
Copy link
Author

MichaelBla commented Aug 31, 2021 via email

@hpssjellis
Copy link

@MichaelBla Glad I could help,

@per1234 per1234 added the topic: code Related to content of the project itself label Jun 7, 2023
@per1234 per1234 changed the title ARDUINO_FW_VERSION version mismatch and does this library really support US915? Does this library really support US915? Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

4 participants