Heltec CubeCell - part 2

Sorry but this is the Forum for The Things Network not Helium…funded by TTI for the benefit of TTN & TTI/The Things Stack users…

You should try the Helium forum/discord.

1 Like

Thanks for the hint. Helium is not the problem. I’m already planning to switch the weather station to TTS. My problem is that I’m looking for a sketch and a decoder to operate an anemometer. It is currently running on an Arduino UNO for testing and should then run on a CubeCell.
Who can help me? I’m not a programmer.
Many Thanks

Code:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

const int RecordTime = 3; //Define Measuring Time (Seconds)
const int SensorPin = 3; //Define Interrupt Pin (2 or 3 @ Arduino Uno)

int InterruptCounter;
float WindSpeed;

void setup()
{
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}

void loop()
{
meassure();
Serial.print(“Wind Speed: “);
Serial.print(WindSpeed); //Speed in km/h
Serial.print(” km/h - “);
Serial.print(WindSpeed / 3.6); //Speed in m/s
Serial.println(” m/s”);

display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 10);
display.println(“Wind Speed: “);
display.setCursor(0, 20);
display.println(WindSpeed);
display.setCursor(50, 20);
display.println(” km/h “);
display.setCursor(0, 40);
display.println(WindSpeed / 3.6);
display.setCursor(50, 40);
display.println(” m/s”);
display.display();
}

void meassure() {
InterruptCounter = 0;
attachInterrupt(digitalPinToInterrupt(SensorPin), countup, RISING);
delay(1000 * RecordTime);
detachInterrupt(digitalPinToInterrupt(SensorPin));
WindSpeed = (float)InterruptCounter / (float)RecordTime * 2.4;
}

void countup() {
InterruptCounter++;
}

The Arduino forums might be a better place to ask questions that are specific to Arduinos

And if your not a programmer then Arduino do have a forum where you can ask people to write code for you.

And if you aren’t a user of any word processing packages, please be aware of the code formatting tools like </> for any future posts.

As alluded to by @LoRaTracker, you are unable to suddenly find someone write the whole program for you, particularly on a LoRaWAN implementation on one of the more notoriously tricky devices.

Are you clairvoyant, or why do you say that?
A forum is there to ask for help.
It could be that maybe someone has implemented such an application before. After all, I’m asking my question in a CubeCell forum and not in the animal magazine!!

Thanks

Yes

Help yes, on this forum, do all the work, not so much.

Could be, the reality is that you’ve got the measurement script done. Sending sensor data is a well solved problem here, as that’s what LoRaWAN tends to be about - all you need to do is use the Heltec LoRaWAN firmware to send the WindSpeed value. If you need documentation on CubeCell programming, what is wrong with the materials on the Heltec website?

Alternatively you could use a ready made Dragino LT device that does pulse counting.

1 Like

Not sure which editor you got the code from, but the libraries look like standard Arduino, so you would have to swap all the ” and ” characters for ".

The Arduino Adafruit libraries used do not appear to be compatible with CubeCell core in the Arduino IDE , so the code would need to be re-written for a known compatible library.

Well, not really. This is The Things Network forum. :wink:
The topic is CubeCell related though.

Hello, I read your post with interest.
Unfortunately, I’m not a programmer, so I’m looking for a ready-made program solution with a decoder for an anemometer (wind gauge) for my small weather station. I would then like to send the data to TTN and evaluate them graphically with ThingSpeak.
I’m looking for a sketch for a CubeCell board and the associated decoder (payload parser).
Do you have a sketch like that?
And do you know of such a project?

Thanks Uli

No, sorry. I use GxAircom as a weather station (open source).

Hi everybody, really stupid question here but I have been struggling all day without finding an answer online.
I am sending 13 bytes uplinks with the AB02 but on TTN i can only see 8 bytes (even if I copy the payload to my clipboard with the relevant button).

I am using ADR and UNconfirmed uplinks, the gateway is really close (i’m testing the system) and the datarate is SF7125.
At first I was sending messages once every 30 seconds (just for test purposes and for short periods of time) but now I have let it on for a bit less than a couple of hours with a message every 10 minutes but it didn’t change.

I tested decreasing the appDataSize to see if I was doing something wrong but it looks like fine (e.g if I put appDataSize = 4 i only see the first 4 bytes of my message. Howether if I set it again to 13 i only see the first 8 bytes on TTN).
Any clue on what am I missing?
Thanks a lot in advance

Need to see your code to understand what you are sending.

And please use the </> from the post formatting tools to post text of code

image

14:27:38 - 14:27:32 = 6 seconds you have barely allowed the RX window to close and you send the next uplink, you are hammering the FUP.

The appTxDutyCycle needs to be 600k to be 10 min

uint32_t appTxDutyCycle = 600000;

The elipsice in the screen shot implies that there is more data to see.

But first, please be kind to the community and give us some feedback on your understanding of the Fair Use Policy and why unconfirmed uplinks are normal and confirmed are very rare.

There is never any need to have a device transmitting on a schedule when you are developing - a push to send does everything you need and means you can keep up with the information on the console.

Thanks a lot for your fast answer.
I did use the right appTxDutyCycle, I already knew it was in milliseconds.

uint32_t appTxDutyCycle = 600000;

I don’t know why I have two uplinks in 6 seconds, maybe I disconnected it by mistake and reconnected it, but usually it sends the uplink every 10 minutes as it should be.

Concerning what I am sending it’s a 13 byte payload (I am sure it is because I print it on Serial Monitor before sending) containing some encoded sensor readings.

Thanks you for your kind answer.
When you cite the elipsice do you mean the three dots at the end of the payload? (e.g 05 55 09 47 14 82 01 00 …)? (sorry for my lack of understanding)
If so, I noticed them and I that’s what makes me think that TTN receives the full payload but displays only the first 8 bytes. However both when I copy the payload or when I use the button “toggle array formatting” I don’t see the remaining part of the payload.

Concerning the feedback you asked, I don’t have a solid knowledge base but I think I grasped the idea behind the Fair Use Policy (I already used the air time calculator someone posted earlier) while I just know that confirmed uplinks should be avoided unless necessary (I think I have a vague intuition about why).

Last minute discovery (I wrote this answer yesterday but I wanted to check one last time):
If I pass my mouse over the payload I noticed that I can see the full payload. So I guess it’s only a visualization problem… I am sorry I wasted people’s time, hope this will save someone else from my same mistake. I am still unable to copy the payload though.
(sorry for the bad quality but I had to do a photo).

1 Like

If you use the copy button next to the payload and past it into notepad, you will see the entire payload. Also if you select the message (click on it) you will see all the metadata about the uplink or downlink.

If you use this in the sketch it will inject 13 bytes in the payload.

  appDataSize = 13;
    for (int i = 0; i < 13; i++) {
      int16_t int_i = i;
      Serial.print("int_(%i) : ");
      Serial.println(int_i);
      appData[i] = (int_i);
      Serial.print("appData[(%i)] : ");
      Serial.println(appData[i]);
  }

And use this in the node Payload formatters → Uplink

function decodeUplink(input) {
    var data = {};
    var warnings = [];


  if (input.fPort == 1) {
      data.byte0 = input.bytes[0];
      data.byte1 = input.bytes[1];
      data.byte2 = input.bytes[2];
      data.byte3 = input.bytes[3];
      data.byte4 = input.bytes[4];
      data.byte5 = input.bytes[5];
      data.byte6 = input.bytes[6];
      data.byte7 = input.bytes[7];
      data.byte8 = input.bytes[8];
      data.byte9 = input.bytes[9];
      data.byte10 = input.bytes[10];
      data.byte11 = input.bytes[11];
      data.byte12 = input.bytes[12];

  }
  else {
      warnings.push("Unsupported fPort");
  }
  return {
    data: data,
    warnings: warnings
  };
}

You will get all 13 decoded.

    "received_at": "2023-01-11T10:07:09.038709431Z",
    "uplink_message": {
      "session_key_id": "AYADFEC12eY0+w==",
      "f_port": 1,
      "frm_payload": "AAECAasdsrwrgcICQoLDA==",
      "decoded_payload": {
        "byte0": 0,
        "byte1": 1,
        "byte10": 10,
        "byte11": 11,
        "byte12": 12,
        "byte2": 2,
        "byte3": 3,
        "byte4": 4,
        "byte5": 5,
        "byte6": 6,
        "byte7": 7,
        "byte8": 8,
        "byte9": 9
      },

Erm, int’s aren’t bytes and the int_i is just the same as i, so whilst it will work, but not the %i as it’s not a printf nor does it have a parameter, try:

  appDataSize = 13;
    for (uint8_t i = 0; i < 13; i++) {
      appData[i] = i;
  }

[/quote]

As for the payload formatter, the TTS default one automagically does the same thing:

function decodeUplink(input) {
  return {
    data: {
      bytes: input.bytes
    },
    warnings: [],
    errors: []
  };
}

image

And

image

Nearly the same

But when you change the number of bytes, it just works …

Or

function decodeUplink(input) {
  return {
    data: input.bytes,
  };
}