@shramik_salgaonkar this is my setting
//setKey(char *NwKSKey, char *AppSKey, char *AppKey);
lora.setKey(NULL, NULL, “3FB33E70EECACFB206D4589FFD44980E”);
and its why to the lora.setKey(“3FB33E70EECACFB206D4589FFD44980E”, “3FB33E70EECACFB206D4589FFD44980E”, “3FB33E70EECACFB206D4589FFD44980E”);
why have you kept two lora.setkey
? keep only that i gave you with your Appkey.
lora.setKey(“3FB33E70EECACFB206D4589FFD44980E”, “3FB33E70EECACFB206D4589FFD44980E”, “3FB33E70EECACFB206D4589FFD44980E”);
am using only this one
i told you to use this one.
its working now but , its now reading the temperature and humidity
#include <CayenneLPP.h>
#include <DHT.h>
#include <LoRaWan.h>
#define DHTPIN A0 // the pin we’re connected the temperature and humidity sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
unsigned char data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA,};
char buffer[256];
CayenneLPP lpp(51);
void setup(void)
{
dht.begin();
SerialUSB.begin(115200);
while(!SerialUSB);
lora.init();
memset(buffer, 0, 256);
lora.getVersion(buffer, 256, 1);
SerialUSB.print(buffer);
memset(buffer, 0, 256);
lora.getId(buffer, 256, 1);
SerialUSB.print(buffer);
// void setID( char *DevAddr, char *DevEUI, char *AppEUI);
//lora.setId(NULL, “F9C01FAA68E1D265” , “70B3D57ED00210F4”);
//setKey(char *NwKSKey, char *AppSKey, char *AppKey);
lora.setKey(NULL, NULL, “3FB33E70EECACFB206D4589FFD44980E”);
// lora.setKey(“3FB33E70EECACFB206D4589FFD44980E”, “3FB33E70EECACFB206D4589FFD44980E”, “3FB33E70EECACFB206D4589FFD44980E”);
lora.setDeciveMode(LWOTAA);
lora.setDataRate(DR0, EU868);
lora.setChannel(0, 868.1);
lora.setChannel(1, 868.3);
lora.setChannel(2, 868.5);
lora.setReceiceWindowFirst(0, 868.1);
lora.setReceiceWindowSecond(869.5, DR3);
lora.setDutyCycle(false);
lora.setJoinDutyCycle(false);
lora.setPower(14);
while(!lora.setOTAAJoin(JOIN));
}
void loop(void)
{
bool result = false;
delay(1000);
int h = dht.readHumidity();
int t = dht.readTemperature();
lpp.reset();
lpp.addTemperature(1, t);
lpp.addBarometricPressure(2, h);
result = lora.transferPacket(lpp.getBuffer(), lpp.getSize(), 10);
//result = lora.transferPacket("Hello World!", 10);
//result = lora.transferPacket(data, 10, 10);
if(result)
{
short length;
short rssi;
memset(buffer, 0, 256);
length = lora.receivePacket(buffer, 256, &rssi);
if(length)
{
SerialUSB.print("Length is: ");
SerialUSB.println(length);
SerialUSB.print("RSSI is: ");
SerialUSB.println(rssi);
SerialUSB.print("Data is: ");
for(unsigned char i = 0; i < length; i ++)
{
SerialUSB.print("0x");
SerialUSB.print(buffer[i], HEX);
SerialUSB.print(" ");
}
SerialUSB.println();
}
}
}
change to
#define DHTPIN 2
and add the following lines in the main loop
SerialUSB.println(t, h);
@shramik_salgaonkar … AM getting now this problem
+MSG: LoRaWAN modem is busy
+JOIN: Join failed
+JOIN: Done
+MSG: Please join network first…
how can i solve it?
which code are you using? I am pretty sure not the one i gave. as it is printing temperature and humidity
am using this code
#include <CayenneLPP.h>
#include <DHT.h>
#include <LoRaWan.h>
#define DHTPIN A0 // the pin we're connected the temperature and humidity sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
unsigned char data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA,};
char buffer[256];
CayenneLPP lpp(51);
void setup(void)
{
dht.begin();
SerialUSB.begin(115200);
while(!SerialUSB);
lora.init();
memset(buffer, 0, 256);
lora.getVersion(buffer, 256, 1);
SerialUSB.print(buffer);
memset(buffer, 0, 256);
lora.getId(buffer, 256, 1);
SerialUSB.print(buffer);
// void setID( char *DevAddr, char *DevEUI, char *AppEUI);
//lora.setId(NULL, "F9C01FAA68E1D265" , "70B3D57ED00210F4");
//setKey(char *NwKSKey, char *AppSKey, char *AppKey);
lora.setKey(NULL, NULL, "71C0CEF60AF960DADB0C51287B5E56A4");
// lora.setKey("3FB33E70EECACFB206D4589FFD44980E", "3FB33E70EECACFB206D4589FFD44980E", "3FB33E70EECACFB206D4589FFD44980E");
lora.setDeciveMode(LWOTAA);
lora.setDataRate(DR0, EU868);
lora.setChannel(0, 868.1);
lora.setChannel(1, 868.3);
lora.setChannel(2, 868.5);
lora.setReceiceWindowFirst(0, 868.1);
lora.setReceiceWindowSecond(869.5, DR3);
lora.setDutyCycle(false);
lora.setJoinDutyCycle(false);
lora.setPower(14);
while(!lora.setOTAAJoin(JOIN));
}
void loop(void)
{
bool result = false;
delay(1000);
int temperature = dht.readTemperature();
int humidity = dht.readHumidity();
lpp.reset();
lpp.addTemperature(1, temperature);
lpp.addRelativeHumidity(2, humidity);
result = lora.transferPacket(lpp.getBuffer(), lpp.getSize(), 10);
SerialUSB.print("Temperature: "+String (temperature));
SerialUSB.print("humidity: "+String (humidity));
//result = lora.transferPacket("Hello World!", 10);
//result = lora.transferPacket(data, 10, 10);
if(result)
{
short length;
short rssi;
memset(buffer, 0, 256);
length = lora.receivePacket(buffer, 256, &rssi);
if(length)
{
SerialUSB.print("Length is: ");
SerialUSB.println(length);
SerialUSB.print("RSSI is: ");
SerialUSB.println(rssi);
SerialUSB.print("Data is: ");
for(unsigned char i = 0; i < length; i ++)
{
SerialUSB.print("0x");
SerialUSB.print(buffer[i], HEX);
SerialUSB.print(" ");
}
SerialUSB.println();
}
}
}
not sure why it wont work now, if the code is same. the only change i noticed is different APP Key
i have never worked with this device, though tried my best to get it working and from the research the above code should be working.
@shramik_salgaonkar… but why the data am reading through the serial monitor it does not much with that in cayenne ?
Not really sure either. You have an issue with your DHT sensor for sure since it’s reading 214 billion degrees and 0 humidity. What is the payload you are sending for the values?
yes
how can i do if i have to send command back to the devices via cayenne?