Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - // Include some libraries
 - #include <dht.h> // Include the Digital Temperature Humidity Sensor Library
 - #include <CayenneLPP.h> // Include the Cayenne Library
 - #include <LoRaWan.h> // Include the LoRaWan Library
 - #include <HP20x_dev.h>
 - #include "Arduino.h"
 - #include "Wire.h"
 - #include <KalmanFilter.h>
 - // Initialize Libraries
 - dht DHT;
 - CayenneLPP lpp(51); // Max Message - 51 Bytes
 - char buffer[256]; // Buffer for reading lora's parameters
 - // Define some variables
 - #define DHT22_PIN 4 // Define the variable that the sensor is connected
 - void setup() {
 - // put your setup code here, to run once:
 - Serial.begin(9600);
 - SerialUSB.begin(115200);
 - delay(150);
 - HP20x.begin();
 - delay(100);
 - lora.init(); // Initialize
 - memset(buffer, 0, 256);
 - lora.getVersion(buffer, 256, 1); //get board version
 - memset(buffer, 0, 256);
 - lora.getId(buffer, 256, 1); //get DevEUI
 - // void setId(char *DevAddr, char *DevEUI, char *AppEUI);
 - lora.setId("26011F41", "001C864F75182C45", "70B3D57ED000C00E");
 - // setKey(char *NwkSKey, char *AppSKey, char *AppKey);
 - lora.setKey("9B1FDB959EA1430CF6D5AEC58A30018E", "9AE4543378E0C2B88E79015C984BAE71", NULL);
 - lora.setDeciveMode(LWABP); //Set Mode (OTAA or ABP)
 - lora.setDataRate(DR0, EU868); //Set Data Rate
 - //Set the channels
 - lora.setChannel(0, 868.1);
 - lora.setChannel(1, 868.3);
 - lora.setChannel(2, 868.5);
 - //Set receive parameters
 - lora.setReceiceWindowFirst(0);
 - lora.setReceiceWindowSecond(869.5, DR3);
 - //Set power
 - lora.setPower(20);
 - }
 - void loop() {
 - // put your main code here, to run repeatedly:
 - bool result = false;
 - int chk = DHT.read22(DHT22_PIN);
 - float temp = DHT.temperature;
 - float hum = DHT.humidity;
 - float uv = analogRead(A0);
 - float bPressure = HP20x.ReadPressure() /100.0;
 - float bTemp = HP20x.ReadTemperature() /100.0;
 - float bAltitude = HP20x.ReadAltitude() /100.0;
 - // Send temperature and humidity sensor data
 - lpp.reset();
 - lpp.addTemperature(0, temp);
 - lpp.addRelativeHumidity(1, hum);
 - lpp.addLuminosity(2, uv);
 - lpp.addBarometricPressure(3, bPressure);
 - lpp.addTemperature(4, bTemp);
 - lpp.addAnalogInput(5, bAltitude);
 - result = lora.transferPacket(lpp.getBuffer(), lpp.getSize());
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment