Compare commits
3 Commits
08efd15d24
...
ed049c234b
| Author | SHA1 | Date | |
|---|---|---|---|
| ed049c234b | |||
| f0805dd48a | |||
| 2e06a62e2a |
@ -8,6 +8,8 @@ SoftwareSerial lora(8, 9); // RX, TX
|
||||
float tens = 0;
|
||||
float amp = 0;
|
||||
|
||||
String line;
|
||||
|
||||
void setup() {
|
||||
lora.begin(9600);
|
||||
Serial.begin(115200);
|
||||
@ -21,5 +23,14 @@ void loop() {
|
||||
Serial.print(",");
|
||||
Serial.println(amp);
|
||||
|
||||
lora.println();
|
||||
}
|
||||
while (Serial.available()) {
|
||||
char c = Serial.read();
|
||||
|
||||
if (c == '\n') {
|
||||
lora.println(line);
|
||||
line = "";
|
||||
} else {
|
||||
line += c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
48
receive-arduino/receive-arduino.ino
Normal file
48
receive-arduino/receive-arduino.ino
Normal file
@ -0,0 +1,48 @@
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
SoftwareSerial lora(8, 9); // RX, TX
|
||||
|
||||
bool test_with_fake = false;
|
||||
|
||||
String line;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
lora.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (!test_with_fake) {
|
||||
while (lora.available()) {
|
||||
char c = lora.read();
|
||||
if (c == '\n') {
|
||||
Serial.println(line);
|
||||
line = "";
|
||||
} else {
|
||||
line += c;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (1) {
|
||||
int speed = random(0, 51);
|
||||
int rpm = random(0, 3000);
|
||||
int power = random(0, 1500);
|
||||
float eff = random(0, 1000) / 10.0;
|
||||
int bat = random(0, 100);
|
||||
float tens = random(360, 550) / 10.0;
|
||||
float amp = random(0, 300) / 10.0;
|
||||
int warn = random(0, 7);
|
||||
|
||||
Serial.print(speed); Serial.print(',');
|
||||
Serial.print(rpm); Serial.print(',');
|
||||
Serial.print(power); Serial.print(',');
|
||||
Serial.print(eff, 1); Serial.print(',');
|
||||
Serial.print(bat); Serial.print(',');
|
||||
Serial.print(tens, 1); Serial.print(',');
|
||||
Serial.print(amp, 1); Serial.print(',');
|
||||
Serial.println(warn);
|
||||
|
||||
delay(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user