The Things Node - Cayenne

ah ok

install the things node library … comes with the CayenneLPP example

ttn node lib

ttn node lib 2

You are very patient. Thank you :slight_smile: I thought I had done that … but will give it another go!!

Pat

Yeah - it is installed :frowning: This is what I see … no CayenneLPP in TheThingsNode library.

image

image

I can’t read your screenshot… must be my old eyes :wink:

TTN lib 3

maybe click and update the lib version ?

TTN lib 4

Very very odd. Sorry for the wild goose chase. I will go hunting. I did update the lib. Will fool around before asking any more :slight_smile: Thanks a million.

1 Like

TTN node CayenneLPP:

#include <TheThingsNode.h>
#include <CayenneLPP.h>

// Set your AppEUI and AppKey
const char *appEui = "0000000000000000";
const char *appKey = "00000000000000000000000000000000";

#define loraSerial Serial1
#define debugSerial Serial

// Replace REPLACE_ME with TTN_FP_EU868 or TTN_FP_US915
#define freqPlan REPLACE_ME

TheThingsNetwork ttn(loraSerial, debugSerial, freqPlan);
TheThingsNode *node;
CayenneLPP lpp(51);

#define PORT_SETUP 1
#define PORT_INTERVAL 2
#define PORT_MOTION 3
#define PORT_BUTTON 4

void setup()
{
  loraSerial.begin(57600);
  debugSerial.begin(9600);

  // Wait a maximum of 10s for Serial Monitor
  while (!debugSerial && millis() < 10000)
    ;

  // Config Node
  node = TheThingsNode::setup();
  node->configLight(true);
  node->configInterval(true, 60000);
  node->configTemperature(true);
  node->onWake(wake);
  node->onInterval(interval);
  node->onSleep(sleep);
  node->onMotionStart(onMotionStart);
  node->onButtonRelease(onButtonRelease);

  // Test sensors and set LED to GREEN if it works
  node->showStatus();
  node->setColor(TTN_GREEN);

  debugSerial.println("-- TTN: STATUS");
  ttn.showStatus();

  debugSerial.println("-- TTN: JOIN");
  ttn.join(appEui, appKey);

  debugSerial.println("-- SEND: SETUP");
  sendData(PORT_SETUP);
}

void loop()
{
  node->loop();
}

void interval()
{
  node->setColor(TTN_BLUE);

  debugSerial.println("-- SEND: INTERVAL");
  sendData(PORT_INTERVAL);
}

void wake()
{
  node->setColor(TTN_GREEN);
}

void sleep()
{
  node->setColor(TTN_BLACK);
}

void onMotionStart()
{
  node->setColor(TTN_BLUE);

  debugSerial.print("-- SEND: MOTION");
  sendData(PORT_MOTION);
}

void onButtonRelease(unsigned long duration)
{
  node->setColor(TTN_BLUE);

  debugSerial.print("-- SEND: BUTTON");
  debugSerial.println(duration);

  sendData(PORT_BUTTON);
}

void sendData(uint8_t port)
{
  printSensors();

  lpp.reset();
  lpp.addDigitalInput(1, node->isButtonPressed());
  lpp.addDigitalInput(2, node->isUSBConnected());
  lpp.addDigitalInput(3, node->isMoving());
  lpp.addAnalogInput(4, node->getBattery()/1000.0);
  lpp.addTemperature(5, node->getTemperatureAsFloat());
  lpp.addLuminosity(6, node->getLight());
  
  float x,y,z;
  node->getAcceleration(&x, &y, &z);
  lpp.addAccelerometer(7, x, y, z);
  
  ttn.sendBytes(lpp.getBuffer(), lpp.getSize());
}

void printSensors()
{
  debugSerial.println();
  debugSerial.println("SENSORS:");
  debugSerial.println("--------");
  
  debugSerial.print("LED Colour:\t");
  debugSerial.println(node->colorToString(node->getColor()));

  debugSerial.print("Temperature:\t");
  debugSerial.print(node->getTemperatureAsFloat());
  debugSerial.println("°C");

  debugSerial.print("Light Sensor:\t");
  debugSerial.print(node->getLight());
  debugSerial.println("lux");
  
  debugSerial.print("Moving now:\t");
  if(node->isMoving())
  {
    debugSerial.println("yes");
  }
  else
  {
    debugSerial.println("no");
  }
  
  debugSerial.print("Button pressed:\t");
  if(node->isButtonPressed())
  {
    debugSerial.println("yes");
  }
  else
  {
    debugSerial.println("no");
  }

  debugSerial.print("USB connected:\t");
  if(node->isUSBConnected())
  {
    debugSerial.println("yes");
  }
  else
  {
    debugSerial.println("no");
  }

  debugSerial.print("Battery:\t");
  debugSerial.print(node->getBattery());
  debugSerial.println("mV");

  float x,y,z;
  node->getAcceleration(&x, &y, &z);

  debugSerial.print("Acceleration:\tx=");
  debugSerial.print(x);
  debugSerial.print("g\n\t\ty=");
  debugSerial.print(y);
  debugSerial.print("g\n\t\tz=");
  debugSerial.print(z);
  debugSerial.println("g");

  debugSerial.println("--------");
  debugSerial.println();
  
}

Fab :slight_smile:

I just found it in the Github repo too … definitely not in my examples!

Compiling now!

Pat

Woop !!

image

Some definite odd stuff with my libraries … now apparently fixed and worked instantly.

Cannot thank you enough for all your help!

Now for a few hours on my day job :slight_smile:

Pat

This is better :slight_smile:

{
“accelerometer_7”: {
“x”: -0.063,
“y”: -0.008,
“z”: -0.969
},
“analog_in_4”: 4.74,
“digital_in_1”: 0,
“digital_in_2”: 1,
“digital_in_3”: 0,
“luminosity_6”: 28,
“temperature_5”: 25.7
}

I am looking at CayenneLPP too, but I got a TTGO T3 V2.1_1.5. It is a ESP32 with Lora built in.
I am not sure what I need to change to make it work. The example code is compiling and running, but i think I need to add som more info to make the Lora part work?
In other code I need to map the pins like this:
// Pin mapping
const lmic_pinmap lmic_pins = {
.nss = 18,
.rxtx = LMIC_UNUSED_PIN,
.rst = 12,
.dio = {26, 33, 32},
};
I think maybe it is the Serial1 that need to be defined?

#define loraSerial Serial1
Any help will be good.
Regards
Svein Utne

Hi Svein,

The example code discussed in this topic is related to The Things Node and will only work with that device because of its onboard sensors.

If you want to have your device working on Cayenne to, make sure that it first works ‘normally’ with TTN, that it can join the network, and that it transmits regulary some sensor data.

Next step is to get that data to Cayenne.
Therefore you have to edit your code and set integration in your console.

see Big ESP32 + SX127x topic part 3

Hi BoRRoZ, Thank you for your answer. I have already good connection to The Things Network, and can see the payload from the web, but Cayenne got more sexy display of data, so I am interested in finding a way to use Cayenne with my Lora data.

Some background info on Cayenne’s LPP (low power payload)
So basically, if you transmit your data in this format, have an account at Cayenne, have registered your device there, added TTN to Cayenne integration in your console, you’re more or less set and you have a dashboard .

Don’t know if there are complete examples (must be) for your device (what sensor(s) / what data ?)

bilde
Thanks againBoRRoZ, I got the data into TTN, but I did not manage to make the dasboard.
I am not sure what device to pick for TTGO T3 Lora32?

please read the last link in the previous post

Thanks again. Now it is working.
bilde

1 Like

hi,
i want to connect my LT-22222-L to ttn but i dont what verif hardware or firmware it is. i only know via the serial communication that the image version is 1.5.6 and the class is A. where can i find those informations? and if i want to inport the end device where can i find the document to do that?

I use the LT-22222 as class C device. If you use it as class A, you have to wait until the next upload to switch the outputs.
LoRaWAN V1.03
PHY V 1.0.3 Rev. A
Supports Class C

i tried changing the class but i get AT_ERROR AT_BUSY_ERROR. how did you know what version is your lorawan and PHY? cause all i get is:
DRAGINO LT-22222-L Device
Image Version: v1.5.6
LoRaWan Stack: DR-LWS-005
Frequency Band: EU868

Log in to the console
Go to applications
Select application
Select End device
General settings
Expand “Network layer”
Here you can see “MAC V”, “Regional Parameters” and “LoRaWAN class capabilities”