-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
122 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |