stm32单片机驱动lora模块sx1278技术资料
开发环境 keil5
子设备读取Ds18b20数据,通过iic显示到OLED 屏幕上,同时用spi协议发送给lora,再传给网关。
网关接收到数据在OLED 屏幕上显示。
单片机源码:
- #include "stdio.h"
- #include "DELAY/Delay.h"
- #include "UART/uart.h"
- #include "ADC/ADC.h"
- #include "LED/LED.h"
- #include "IIC/IIC.h"
- #include "OLED/OLED.h"
- #include "SPIx/SPIx.h"
- #include "SX1278/SX1278.h"
- #define ALARM 22
- int main(void)
- {
- u8 i = 0;
- int temper = 0;
- unsigned char rx[20];
- /*初始化各外设*/
- initSysTick();
- initADC();
- initUART(); //波特率9600
- initLED();
- initIIC();
- initOLED();
- initSPIx(SPI2);
- initSX1278();
- formatScreen(0x00);
- for(i=0;i<=128;i+=2)
- {
- showImage(0,0,i,8,LORA_LOGO);
- }
- formatScreen(0x00);
- while (1)
- {
- receivePackets(&rx[0]);
- temper = (int)(rx[11]-'0')*10 + (int)(rx[12]-'0');
- printf("%s\n",rx);
- printf("%d\n", temper);
- showString(0,1,rx,FONT_16_EN);
- if(temper < ALARM)
- {
- showString(35,4,"NORMAL",FONT_16_EN);
- }else{
- showString(35,4,"ALARM!",FONT_16_EN);
- }
- toggleLED();
- Delay_ms(500);
- }
- }
复制代码 全部资料51hei下载地址:
Child_device.7z
(202.7 KB, 下载次数: 280)
|