Louie NRT Story

[LoRa] SystemBase Inc. uLory 본문

에너지

[LoRa] SystemBase Inc. uLory

hyeok0724.kim@gmail.com 2020. 2. 4. 18:41
반응형

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

 

Connect uLory to Raspberry Pi 3B+

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

https://www.sysbas.com/

 

시스템베이스 - 세계 최고를 지향하는 IoT 전문회사

시리얼통신 시장과 반도체 및 임베디드 모듈과 같은 다양한 제품을 통해 다양한 산업 분야에서 세계 최고가 되도록 노력할 것입니다.

www.sysbas.com

반응형

'에너지' 카테고리의 다른 글

[나인와트] 사설 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