add lora
This commit is contained in:
parent
22b36fbc01
commit
b1a742d777
14
can/can.ino
14
can/can.ino
@ -2,7 +2,9 @@
|
|||||||
#include <mcp_can.h>
|
#include <mcp_can.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <LiquidCrystal_I2C.h>
|
#include <LiquidCrystal_I2C.h>
|
||||||
|
#include <SoftwareSerial.h>
|
||||||
|
|
||||||
|
SoftwareSerial lora(8, 9); // RX, TX
|
||||||
LiquidCrystal_I2C lcd(0x27, 20, 4);
|
LiquidCrystal_I2C lcd(0x27, 20, 4);
|
||||||
|
|
||||||
#define CAN_CS 10
|
#define CAN_CS 10
|
||||||
@ -22,8 +24,16 @@ int v = 0;
|
|||||||
int ubatr = 0;
|
int ubatr = 0;
|
||||||
int current = 0;
|
int current = 0;
|
||||||
int c_max = 0;
|
int c_max = 0;
|
||||||
|
char buffer[50];
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
pinMode(5, OUTPUT);
|
||||||
|
pinMode(6, OUTPUT);
|
||||||
|
digitalWrite(5, LOW);
|
||||||
|
digitalWrite(6, LOW);
|
||||||
|
lora.begin(9600);
|
||||||
|
|
||||||
lcd.init();
|
lcd.init();
|
||||||
lcd.backlight();
|
lcd.backlight();
|
||||||
|
|
||||||
@ -98,6 +108,10 @@ void loop() {
|
|||||||
lcd.print(" A ");
|
lcd.print(" A ");
|
||||||
Serial.print("current max = ");
|
Serial.print("current max = ");
|
||||||
Serial.println(c_max);
|
Serial.println(c_max);
|
||||||
|
|
||||||
|
snprintf(buffer, sizeof(buffer), "%d,%d,%d,%d", n, v, ubatr, current);
|
||||||
|
n = n + 1;
|
||||||
|
lora.println(buffer);
|
||||||
}
|
}
|
||||||
if (current_time - previous_time_c >= timing) {
|
if (current_time - previous_time_c >= timing) {
|
||||||
previous_time_c = current_time;
|
previous_time_c = current_time;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user