Skip to content

Instantly share code, notes, and snippets.

@matthijskooijman
Created November 26, 2014 20:58
Show Gist options
  • Save matthijskooijman/365dd3b92810b2c9c147 to your computer and use it in GitHub Desktop.
Save matthijskooijman/365dd3b92810b2c9c147 to your computer and use it in GitHub Desktop.
Long haul testing
These are just ejemplo_1a (TX) and ejemplo_1b (RX), with the receiver's loop modified to actually print packets instead of displaying a confusing message about timeouts. Also, the serial baudrate was changed for debugging.
Wiring is:
MISO/MOSI/SCK to their respective pins on the Arduino
SSN to D2
GND to GND
All three VDD pins to 3V3
No other pins are wired.
/*
* Semtech SX1272 module managing with Arduino
*
* Copyright (C) 2014 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 Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 1.0
* Design: David Gascón
* Implementation: Covadonga Albiñana
*/
// Include the SX1272 and SPI library:
#include "SX1272.h"
#include <SPI.h>
int e;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
// Print a start message
Serial.println("SX1272 module and Arduino: receive packets without ACK");
// Power ON the module
sx1272.ON();
// Set transmission mode and print the result
e = sx1272.setMode(4);
Serial.println(e, DEC);
// Select frequency channel
e = sx1272.setChannel(CH_10_868);
Serial.println("Setting Channel: state ");
Serial.println(e, DEC);
// Select output power (Max, High or Low)
e = sx1272.setPower('H');
Serial.println("Setting Power: state ");
Serial.println(e);
// Set the node address and print the result
e = sx1272.setNodeAddress(8);
Serial.println(e, DEC);
// Print a success message
Serial.print("SX1272 successfully configured ");
}
void loop(void)
{
// Receive message
e = sx1272.receivePacketTimeout(10000);
if (e == 0) {
Serial.print("Received ");
Serial.print(sx1272.packet_received.length);
Serial.print(" bytes: ");
Serial.write(sx1272.packet_received.data, sx1272.packet_received.length);
Serial.println();
} else {
Serial.print(F("Receive packet timeout, state "));
Serial.println(e, DEC);
}
}
/*
* Semtech SX1272 module managing with Arduino
*
* Copyright (C) 2014 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 Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 1.0
* Design: David Gascón
* Implementation: Covadonga Albiñana
*/
// Include the SX1272 and SPI library:
#include "SX1272.h"
#include <SPI.h>
int e;
char message1 [] = "Packet test 1, wanting to see if received packet is the same as sent packet";
char message2 [] = "Packet test 2, is it received?";
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
// Print a start message
Serial.println("SX1272 module and Arduino: send packets without ACK");
// Power ON the module
sx1272.ON();
// Set transmission mode and print the result
e = sx1272.setMode(4);
Serial.println(e, DEC);
// Select frequency channel
e = sx1272.setChannel(CH_10_868);
Serial.println("Setting Channel: state ");
Serial.println(e, DEC);
// Select output power (Max, High or Low)
e = sx1272.setPower('H');
Serial.println("Setting Power: state ");
Serial.println(e);
// Set the node address and print the result
e = sx1272.setNodeAddress(3);
Serial.println(e, DEC);
// Print a success message
Serial.print("SX1272 successfully configured ");
}
void loop(void)
{
// Send message1 and print the result
e = sx1272.sendPacketTimeout(8, message1);
Serial.print("Packet sent, state ");
Serial.println(e, DEC);
delay(4000);
// Send message2 and print the result
e = sx1272.sendPacketTimeout(8, message2);
Serial.print("Packet sent, state ");
Serial.println(e, DEC);
delay(4000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment