일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- STM32
- raspberry
- homeassistant
- Android
- 완속충전기
- 급속충전기
- esp8266
- 전기차충전기
- 홈어시스턴트
- YMODEM
- IOT Core
- everon
- 전기차충전
- 보안
- 서버리스
- lambda
- 파이썬
- 전기차
- 디자인패턴
- 충전기
- 안드로이드
- OCPP
- 플라스크
- 라즈베리파이
- thread
- 에버온
- flask
- 펌웨어
- AWS
- dynamodb
Archives
- Today
- Total
Louie NRT Story
[LoRa] SystemBase Inc. uLory 본문
반응형
Date Created: 05 FEB 2020
Index
1. Components
2. Install uLory Driver & Manual
3. Change Setup Mode
4. Command using Putty
5. Change Destination ID
6. Change Default mode
1. Components
2. Install uLory Driver & Manual
3. Change Setup Mode
* Note about LoryView
- Accoring to the manaul it provides a utility.
4. Command using Putty
5. Change Destination ID
1) Check Source ID of a uLory
2) Check Source ID of another uLory
3) Command Destination ID each other
6. Change Default mode
7. Send & Receive Data using Raspberry Pi
8. Code
1) Device 01
//include system librarys
#include <stdio.h> //for printf
#include <stdint.h> //uint8_t definitions
#include <stdlib.h> //for exit(int);
#include <string.h> //for errno
#include <errno.h> //error output
//wiring Pi
#include <wiringPi.h>
#include <wiringSerial.h>
// Typying "dmesg|tail"
// Find Serial device on Raspberry with ~ls /dev/tty*
// ARDUINO_UNO "/dev/ttyACM0"
// FTDI_PROGRAMMER "/dev/ttyUSB0"
// HARDWARE_UART "/dev/ttyAMA0"
char device[]= "/dev/ttyUSB0";
// filedescriptor
int fd;
int count_value = 0;
char s1[10];
unsigned long baud = 9600;
unsigned long time=0;
//prototypes
int main(void);
void loop(void);
void setup(void);
void setup(){
printf("%s \n", "Raspberry Startup! Device_01");
fflush(stdout);
//get filedescriptor
if ((fd = serialOpen (device, baud)) < 0){
fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
exit(1); //error
}
//setup GPIO in wiringPi mode
if (wiringPiSetup () == -1){
fprintf (stdout, "Unable to start wiringPi: %s\n", strerror (errno)) ;
exit(1); //error
}
}
void loop(){
// Pong every 3 seconds
if(millis()-time>=10000){
sprintf(s1, "Device_01: %d\n", count_value);
serialPuts (fd, s1);
printf("Send Data: %s", s1);
// you can also write data from 0-255
// 65 is in ASCII 'A'
count_value++;
time=millis();
}
// read signal
if(serialDataAvail (fd)){
char newChar = serialGetchar (fd);
printf("%c", newChar);
fflush(stdout);
}
}
// main function for normal c++ programs on Raspberry
int main(){
setup();
while(1) loop();
return 0;
}
2) Device 02
//include system librarys
#include <stdio.h> //for printf
#include <stdint.h> //uint8_t definitions
#include <stdlib.h> //for exit(int);
#include <string.h> //for errno
#include <errno.h> //error output
//wiring Pi
#include <wiringPi.h>
#include <wiringSerial.h>
// Typying "dmesg|tail"
// Find Serial device on Raspberry with ~ls /dev/tty*
// ARDUINO_UNO "/dev/ttyACM0"
// FTDI_PROGRAMMER "/dev/ttyUSB0"
// HARDWARE_UART "/dev/ttyAMA0"
char device[]= "/dev/ttyUSB0";
// filedescriptor
int fd;
int count_value = 0;
char s1[10];
unsigned long baud = 9600;
unsigned long time=0;
//prototypes
int main(void);
void loop(void);
void setup(void);
void setup(){
printf("%s \n", "Raspberry Startup! Device_02");
fflush(stdout);
//get filedescriptor
if ((fd = serialOpen (device, baud)) < 0){
fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
exit(1); //error
}
//setup GPIO in wiringPi mode
if (wiringPiSetup () == -1){
fprintf (stdout, "Unable to start wiringPi: %s\n", strerror (errno)) ;
exit(1); //error
}
}
void loop(){
// Pong every 3 seconds
if(millis()-time>=10000){
sprintf(s1, "Device_02: %d\n", count_value);
serialPuts (fd, s1);
printf("Send Data: %s", s1);
// you can also write data from 0-255
// 65 is in ASCII 'A'
count_value++;
time=millis();
}
// read signal
if(serialDataAvail (fd)){
char newChar = serialGetchar (fd);
printf("%c", newChar);
fflush(stdout);
}
}
// main function for normal c++ programs on Raspberry
int main(){
setup();
while(1) loop();
return 0;
}
3) Compile code via gcc
gcc lora.c -o lora -l wiringPi -DRaspberryPi
Reference
반응형
'에너지' 카테고리의 다른 글
[나인와트] 사설 LoRa 망을 활용한 무선 원격검침 시스템 (1) | 2020.03.01 |
---|---|
[Wireless] LoRa (0) | 2020.02.23 |
[BlueTooth] HC-06 (0) | 2020.02.03 |
[RaspberryPi] Led Control (0) | 2020.02.03 |
[나인와트] 2019 Incheon Civic Hack-Fair (0) | 2020.01.05 |
Comments