The Things Node - Cayenne

Yes, have been using Cayenne on other devices and also with the MicroChip LoRa Mote with no problems so at a basic level I get it. I just expected the Things Node to work without any fiddling :slight_smile: It’s the fiddling bit I am not clear on.

I can see my Things Node in Cayenne, but all I see is RSSI and SNR and Location. None of sensors.

Thanks so much for your help!

Pat

Ok, so I need to modify the sketch that runs on the Node to use LPP?

If’ you’ve done it, are you willing to share?

Pat

use the CayenneLPP sketch

and edit 3 things :

editedsketchCayeneLPP

log in to Cayenne and select The Things node (you need the device id to register )

Thanks! I completely follow, but the only CayenneLPP file I have is at Examples->TheThingsNetwork->CayenneLPP

And it contains only this (below) … i.e. knows nothing about the Node :frowning: I assume I need to weave the two files together (i.e. the CayenneLPP and Examples->TheThingsNode->Basic.

#include <TheThingsNetwork.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);
CayenneLPP lpp(51);

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

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

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

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

void loop()
{
debugSerial.println("-- LOOP");

lpp.reset();
lpp.addTemperature(1, 22.5);
lpp.addBarometricPressure(2, 1073.21);
lpp.addGPS(3, 52.37365, 4.88650, 2);

// Send it off
ttn.sendBytes(lpp.getBuffer(), lpp.getSize());

delay(10000);
}

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