Seeeduino with cayenne

try the receiving code from the seeduino wiki:

// Seduino LoRaWAN - RX example
#include <LoRaWan.h>

unsigned char buffer[128] = {0, };

void setup(void)
{
    SerialUSB.begin(115200);
    lora.init();
    lora.initP2PMode(433, SF12, BW125, 8, 8, 20);
}

void loop(void)
{
    short length = 0;
    short rssi = 0;

    memset(buffer, 0, 128);
    length = lora.receivePacketP2PMode(buffer, 128,  &rssi, 1);

    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();
    }
}

@shramik_salgaonkar … Should I combine the two codes? and upload it on the board?

First, just try the basic code and check whether you are receiving the data from cayenne → ttn → seeduino.

@shramik_salgaonkar… I am having a problem with my devices after to upload the code on the seeeduino bord, I am able to send data to the TTN and to check it also in cayenne … but once I tried to power up my seeeduino board with a 5v battery it stops sending data
what should I do?

can you provide a link to the device you are using.

it is mentioned:

2. Battery

You can power the board via a 3.7V Lipo battery. There’s a JST2.0 cable included, use it if you can’t get a battery with JST2.0 connector.

IMG_20191106_132740_6|250x500

id o have the battery but… am I can upload the code on the board with that battery connect?

No you cannot use, two power supply together. Why you wont to upload the code while the battery is connected?

@shramik_salgaonkar … look I can upload the code for the bink led its go work … but if I try to upload the code to send data to the TTN it does not work

which is the code you are using?

#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);
#define moisture A2 // the pin we're connected the moisture sensor
int mval;



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);
    pinMode(moisture,INPUT);
    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, "xxxxxxxxxxxxxxx" , "xxxxxxxxxxxxxxxxx");
    //setKey(char *NwKSKey, char *AppSKey, char *AppKey);
   lora.setKey(NULL, NULL, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");




    



    
   // lora.setKey("xxxxxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    
    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();
  mval = analogRead(moisture);
  
  lpp.reset();
  lpp.addTemperature(1, temperature);
  lpp.addRelativeHumidity(2,  humidity);
  lpp.addAnalogInput(3, mval);
  
  result = lora.transferPacket(lpp.getBuffer(), lpp.getSize(), 10);

   
   SerialUSB.print("Temperature: "+String (temperature));
   SerialUSB.print("humidity: "+String (humidity));
   SerialUSB.print("moisture: "+String (mval));


    
    
    
    
    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();
        }
    }
}

what are you getting in the serial monitor?

when am uploading the code , am using the usb cabe plug to my computer

but after to upload i have to remove the USB cable an plug the battery , then after to unplug am getting nothing

so what you are saying that it works when you have connected it to your pc but does not work when you connect it to a battery.

yes

i guess you are not powering the device properly.

but why is it working with the blinking exmple

but it does work connected to PC?? can you share the data received on the TTN console when connected to PC.