Libelium is offering new technical support channels, to contact with de Technical Support team to solve any issue our doubt please contact with your sales agent or visit our contact site



Post a new topicPost a reply Page 1 of 1   [ 6 posts ]
Author Message
 Post subject: SX1272 LoRa Multiprotocol Shield Digital Output Issue
PostPosted: Fri Apr 27, 2018 10:00 am 

Joined: Fri Apr 27, 2018 8:41 am
Posts: 3
Hello all,

I recently purchased SX1272 LoRa with Multiprotocol Radio Shield x2. Examples for TX and RX nodes are successfully runing on Arduino UNO.

However, when I try using built in LED (pin 13) for signalization of received message it seems I can't set it high or low. Below are commands I'm using with example SX_03b_RX_LoRa_ACKwRetries. When I comment out everything else (except mine) in void setup() it works.
Code:
/*I'm not copying code from example to be easy to read
Only copying lines I added to example*/

const int ledPin = 13;       // the number of the LED pin
int ledState = HIGH;         // the current state of the output pin

void setup() {
  pinMode(ledPin, OUTPUT);

  // set initial LED state
  digitalWrite(ledPin, ledState);
}

void loop() {

  // set the LED:
  ledState = !ledState;
  digitalWrite(ledPin, ledState);

  delay(5000);
}


Can someone explain why always me :lol:
..and why is that happening and how to use digital pins as input or output?


Top
 Profile  
 
 Post subject: Re: SX1272 LoRa Multiprotocol Shield Digital Output Issue
PostPosted: Fri Apr 27, 2018 10:10 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi,

We think that we don't understand your problem... the code you shared seems correct. It sets the pin 13 as output, then it sets the initial state to 1 and finally it change from 1 to 0, from 0 to 1, from 1 to 0, and so on.

Regards


Top
 Profile  
 
 Post subject: Re: SX1272 LoRa Multiprotocol Shield Digital Output Issue
PostPosted: Fri Apr 27, 2018 10:26 am 

Joined: Fri Apr 27, 2018 8:41 am
Posts: 3
Hi libelium team,

and thanks for fast response. To keep it simple I included code for both, receiver and transmitter. Transmitter sends message with payload 1 or 0. When receiver gets 1 it sets variable ledState = HIGH and after it should turn LED on with digitalWrite(ledPin, ledState) BUT IT DOESN'T :x

With Serial.println(ledState, DEC) at receiver line 128 I check if variable ledState is high - and it is (however LED is OFF).

Transmitter:
Code:
/* 
 *  LoRa 868 / 915MHz SX1272 LoRa module
 * 
 *  Copyright (C) Libelium Comunicaciones Distribuidas S.L.
 *  http://www.libelium.com
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see http://www.gnu.org/licenses/.
 * 
 *  Version:           1.2
 *  Design:            David Gascón
 *  Implementation:    Covadonga Albiñana, Victor Boria, Ruben Martin
 */

#include <Wire.h>

// Cooking API libraries
#include <arduinoUtils.h>

// Include the SX1272 and SPI library:
#include "arduinoLoRa.h"
#include <SPI.h>

int e;

char message1 [] = "1";
char message2 [] = "0";

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
 
  // Print a start message
  Serial.println(F("SX1272 module and Arduino: send packets with ACK and retries"));
 
  // Power ON the module
  e = sx1272.ON();
  Serial.print(F("Setting power ON: state "));
  Serial.println(e, DEC);

  /***** MODE 1-10 max range/slow data rate-min range/fast data rate *****/
  // Set transmission mode and print the result
  e |= sx1272.setMode(4);
  Serial.print(F("Setting Mode: state "));
  Serial.println(e, DEC);
 
  // Set header
  e |= sx1272.setHeaderON();
  Serial.print(F("Setting Header ON: state "));
  Serial.println(e, DEC);

  /*************** CHANNEL 10-17 ****************/
  // Select frequency channel
  e |= sx1272.setChannel(CH_10_868);
  Serial.print(F("Setting Channel: state "));
  Serial.println(e, DEC);
 
  // Set CRC
  e |= sx1272.setCRC_ON();
  Serial.print(F("Setting CRC ON: state "));
  Serial.println(e, DEC);

  /***** POWER 'M', 'H' or 'L' if you want Maximum, High or Low *****/
  // Select output power (Max, High or Low)
  e |= sx1272.setPower('H');
  Serial.print(F("Setting Power: state "));
  Serial.println(e, DEC);
 
  // Set the node address and print the result
  e |= sx1272.setNodeAddress(3);
  Serial.print(F("Setting node address: state "));
  Serial.println(e, DEC);
 
  // Print a success message
  if (e == 0)
    Serial.println(F("SX1272 successfully configured"));
  else
    Serial.println(F("SX1272 initialization failed"));
}

void loop(void)
{
  // Send message1 and print the result
  e = sx1272.sendPacketTimeoutACKRetries(8, message1);
  Serial.print(F("Packet 1 sent, state "));
  Serial.println(e, DEC);
  sx1272.getRSSIpacket();
  Serial.println();

  delay(10000); 

  // Send message1 and print the result
  e = sx1272.sendPacketTimeoutACKRetries(8, message2);
  Serial.print(F("Packet 2 sent, state "));
  Serial.println(e, DEC);
  sx1272.getRSSIpacket();
  Serial.println();

  delay(10000); 
 
}


Receiver:
Code:
/* 
 *  LoRa 868 / 915MHz SX1272 LoRa module
 * 
 *  Copyright (C) Libelium Comunicaciones Distribuidas S.L.
 *  http://www.libelium.com
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see http://www.gnu.org/licenses/.
 * 
 *  Version:           1.2
 *  Design:            David Gascón
 *  Implementation:    Covadonga Albiñana, Victor Boria, Ruben Martin
 */

#include <Wire.h>

// Cooking API libraries
#include <arduinoUtils.h>

// Include the SX1272 and SPI library:
#include "arduinoLoRa.h"
#include <SPI.h>

int e;
char my_packet[100];

const int ledPin = 13;      // the number of the LED pin
int ledState = HIGH;         // the current state of the output pin

void setup()
{
  //LED pin as output
  pinMode(ledPin, OUTPUT);

  // set initial LED state
  digitalWrite(ledPin, ledState);
 
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
 
  // Print a start message
  Serial.println(F("SX1272 module and Arduino: receive packets with ACK and retries"));
 
  // Power ON the module
  e = sx1272.ON();
  Serial.print(F("Setting power ON: state "));
  Serial.println(e, DEC);

  /***** MODE 1-10 max range/slow data rate-min range/fast data rate *****/
  // Set transmission mode and print the result
  e |= sx1272.setMode(4);
  Serial.print(F("Setting Mode: state "));
  Serial.println(e, DEC);
 
  // Set header
  e |= sx1272.setHeaderON();
  Serial.print(F("Setting Header ON: state "));
  Serial.println(e, DEC);

  /*************** CHANNEL 10-17 ****************/
  // Select frequency channel
  e |= sx1272.setChannel(CH_10_868);
  Serial.print(F("Setting Channel: state "));
  Serial.println(e, DEC);
 
  // Set CRC
  e |= sx1272.setCRC_ON();
  Serial.print(F("Setting CRC ON: state "));
  Serial.println(e, DEC);

  /***** POWER 'M', 'H' or 'L' if you want Maximum, High or Low *****/
  // Select output power (Max, High or Low)
  e |= sx1272.setPower('H');
  Serial.print(F("Setting Power: state "));
  Serial.println(e, DEC);
 
  // Set the node address and print the result
  e |= sx1272.setNodeAddress(8);
  Serial.print(F("Setting node address: state "));
  Serial.println(e, DEC);
 
  // Print a success message
  if (e == 0)
    Serial.println(F("SX1272 successfully configured"));
  else
    Serial.println(F("SX1272 initialization failed"));
}

void loop(void)
{
  // Receive message
  e = sx1272.receivePacketTimeoutACK(12000);

  Serial.println();
 
  if ( e == 0 )
  {
    Serial.print(F("Receive packet with ACK and retries, state "));
    Serial.println(e, DEC);
    sx1272.getRSSIpacket();

    for (unsigned int i = 0; i < sx1272.packet_received.length; i++)
    {
      my_packet[i] = (char)sx1272.packet_received.data[i];
    }
    Serial.print(F("Message: "));
    Serial.println(my_packet);
  }
  else {
    Serial.print(F("Receive packet with ACK and retries, state "));
    Serial.println(e, DEC);
    sx1272.getRSSIpacket();
  }

  if ( my_packet[0] == '1') ledState = HIGH;
  else ledState = LOW;

  Serial.println(ledState, DEC);

  // set the LED:
  digitalWrite(ledPin, ledState);
}


Top
 Profile  
 
 Post subject: Re: SX1272 LoRa Multiprotocol Shield Digital Output Issue
PostPosted: Fri Apr 27, 2018 1:28 pm 

Joined: Fri Apr 27, 2018 8:41 am
Posts: 3
Ok..now I wasted almost hole day and still don't know why I can't use digital pins on Arduino UNO with libraries provided by Libelium for sx1272. As long as I don't use libraries it all works perfect.

In my previus post I included code so everyone can chek if they have the same problem.

Hope Libelium team can explain.


Top
 Profile  
 
 Post subject: Re: SX1272 LoRa Multiprotocol Shield Digital Output Issue
PostPosted: Sun Apr 29, 2018 2:40 pm 

Joined: Wed Dec 06, 2017 4:51 pm
Posts: 11
SBL_Mali_Kekec wrote:
However, when I try using built in LED (pin 13) for signalization of received message it seems I can't set it high or low. Below are commands I'm using with example SX_03b_RX_LoRa_ACKwRetries. When I comment out everything else (except mine) in void setup() it works.


Hi SBL_Mali_Kekec,

Please note that Multiprotocol shield uses two protocols, i-e, SPI and I2C. If you consult to the Arduino Pinout, you will notice that Arduino SPI pins are Digital Pins (10,11,12,13 for SS, MOSI, MISO, SCK) respectively including ICSP headers.

So, using SPI protocol, the stated digital pins will somehow gets disabled or will hinder the use of these pins.

I hope, I have answered your question.


Top
 Profile  
 
 Post subject: Re: SX1272 LoRa Multiprotocol Shield Digital Output Issue
PostPosted: Wed May 02, 2018 2:35 pm 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi,

@malik_umair91, thanks for your contribution with the forum!

@SBL_Mali_Kekecd, did you solve the issue with the help of malik_umair91?

Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 6 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use.