Last active
October 11, 2019 20:07
-
-
Save enjoycowboy/af9be233f447e385046de3e91f6899c5 to your computer and use it in GitHub Desktop.
lorawan test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Arduino.h> | |
#include "DHT.h" | |
#include "LoRaWAN.h" | |
#include <stdint.h> | |
#include <SoftwareSerial.h> | |
DHT dht; | |
SoftwareSerial *hSerialCommands = NULL; | |
char APPKEY[] = "ed:cb:35:f3:94:17:12:e5:c1:1c:8a:8f:49:6e:a1:50"; | |
char APPEUI[] = "70:B3:D5:7E:D0:02:39:B2"; | |
char CHMASK[] = "FF00:0000:0000:0000:0001:0000"; | |
void setup() | |
{ | |
Serial.begin(9600); | |
Serial.println("xxxxxxxxxxxxxxxxxxxxxxxxx"); | |
Serial.println(); | |
delay(10000); | |
hSerialCommands = SerialCommandsInit(7, 6, 9600); | |
SendAtCommand(AT_CHMASK, AtSet, CHMASK); | |
Serial.println("joining...."); | |
if (JoinNetwork(0) == RAD_OK) | |
{ | |
Serial.println("Joined"); | |
} | |
else | |
{ | |
Serial.println("Not joined"); | |
} | |
Serial.println("Status\tHumidity (%)\tTemperature (C)\t(F)"); | |
dht.setup(5); // data pin 2 | |
} | |
void loop() | |
{ | |
delay(dht.getMinimumSamplingPeriod()); | |
double humidity = dht.getHumidity(); | |
double temperature = dht.getTemperature(); | |
char buf[16]; | |
char txt[] = " C, H%"; | |
char hum[6]; | |
snprintf(hum, sizeof hum, "%f", humidity); | |
snprintf(buf, sizeof buf, "%f", temperature); | |
strcat(txt, buf); | |
strcat(hum, buf); | |
Serial.println(buf); | |
SendString(buf, 2); | |
Serial.print(dht.getStatusString()); | |
Serial.print("\t"); | |
Serial.print(humidity, 1); | |
Serial.print("\t\t"); | |
Serial.print(temperature, 1); | |
Serial.print("\t\t"); | |
Serial.println(dht.toFahrenheit(temperature), 1); | |
delay(15000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment