Skip to content

Commit

Permalink
PSG
Browse files Browse the repository at this point in the history
  • Loading branch information
nivu07 committed Feb 23, 2018
1 parent 0173840 commit b0abd4b
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 4 deletions.
29 changes: 29 additions & 0 deletions Arduino Codes/AnalogReadSerial/AnalogReadSerial.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
float sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
float volt = (sensorValue*5)/1023;

Serial.println(volt);
delay(1000); // delay in between reads for stability
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void setup()
mySerial.begin(9600); //serial port to radio
Serial.println("Startup");

initialize_radio();
initialize_radio();

//transmit a startup message
myLora.tx("TTN Mapper on TTN Enschede node");
Expand Down Expand Up @@ -104,9 +104,9 @@ void initialize_radio()
* ABP: initABP(String addr, String AppSKey, String NwkSKey);
* Paste the example code from the TTN console here:
*/
const char *devAddr = "061af623";
const char *nwkSKey = "1ce5af4045f23cf1b439e76e662e7c87";
const char *appSKey = "29830b609499fbf6b1d19d1c1d70b076";
const char *devAddr = "06960d46";
const char *nwkSKey = "c75167ccc9f87a634b794e1f0c8cc83b";
const char *appSKey = "147235d532cb50ffc7e25542fdb4f023";

join_result = myLora.initABP(devAddr, appSKey, nwkSKey);

Expand Down
61 changes: 61 additions & 0 deletions Arduino Codes/lora_receiver/lora_receiver.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <SoftwareSerial.h>
SoftwareSerial loraSerial (2, 3); //rx 2 tx 3

String inputString = "";
int D7 = 7;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
loraSerial.begin(57600);
pinMode(D7,OUTPUT);

delay(2000);
RN2483_init();

}

void loop() {

sendcmd("radio rx 0");

if(loraSerial.available()){
String resp = loraSerial.readString();
Serial.println(String(resp));

}

delay(1000);




}

void RN2483_init(){

sendcmd("sys reset");
sendcmd("radio set mod lora");
sendcmd("radio set freq 868100000");
sendcmd("radio set pwr 14");
sendcmd("radio set sf sf12");
sendcmd("radio set afcbw 125");
sendcmd("radio set rxbw 250");
sendcmd("radio set fdev 5000");
sendcmd("radio set fdev 5000");
sendcmd("radio set prlen 8");
sendcmd("radio set crc on");
sendcmd("radio set cr 4/8");
sendcmd("radio set wdt 0");
sendcmd("radio set sync 12");
sendcmd("radio set bw 250");
sendcmd("sys get hweui");
sendcmd("mac pause");

}

void sendcmd(String data){
Serial.println(data);
loraSerial.println(data);
String resp = loraSerial.readStringUntil('\n');
Serial.println(resp.length());
}
File renamed without changes.
Binary file not shown.
28 changes: 28 additions & 0 deletions LoRa Point to Point.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
basic setup commands for radio communication

sys reset
radio set mod lora
radio set freq 868100000
radio set pwr 14
radio set sf sf12
radio set afcbw 125
radio set rxbw 250
radio set fdev 5000
radio set prlen 8
radio set crc on
radio set cr 4/8
radio set wdt 0
radio set sync 12
radio set bw 250
sys get hweui
mac pause

command for transmitting the data

radio tx "data"

command for reciving the data

radio rx 0

for each commands for ctrl+enter followed by shift+ctrl+enter

0 comments on commit b0abd4b

Please sign in to comment.