Influxdb Integration

I have been struggling with getting data from my sensor into InfluxDB. I feel my problem is my codec. It does work in decoding the data sent from my sensor but I believe it is not in a format that InfluxDB can use. I have read many posts but have not found many examples of a codec. The official documentation doesn’t make sense to me. My sensor is a RAK wiseblock and I was able to find a codec on their forum that worked for me, but it wasn’t specifically written for an InfluxDB integration. Any help would be appreciated. Thanks

This is my codec.

function DoDecode(fPort, bytes) {
var decoded = {};
switch (bytes[0])
{
case 0x01: // Environment sensor data
// decoded.vbat_per = (bytes[1]);
decoded.Vbat_sensor_1 = (bytes[2] << 8) | bytes[3];
decoded.TemperatureAM_sensor_1 = (bytes[4] & 0x80 ? 0xFFFF<<16 : 0) | bytes[4]<<8 | bytes[5] / 100;
decoded.HumidityAM_sensor_1 = (bytes[6] << 8) | bytes[7] / 100;
decoded.TempInside_sensor_1 = (bytes[8] & 0x80 ? 0xFFFF<<16 : 0) | bytes[8]<<8 | bytes[9] / 100;
decoded.Pressure_sensor_1 = bytes[10]<<24 | bytes[11]<<16 | bytes[12]<<8 | bytes[13] / 100;
}
return decoded;
}

// For Chirpstack
function Decode(fPort, bytes, variables)
{
return DoDecode(fPort, bytes,variables);
}

// Chirpstack v3 to v4 compatibility wrapper
function decodeUplink(input) {
return {
data: Decode(input.fPort, input.bytes, input.variables)
};
}

can you see the data in the events first?

Yes. When I look at the uplink in Events I can see all the decoded sensor data. So that is why I feel I am decoding it correctly but then not putting it in the correct format for InfluxDB to understand. For instance, I have not specified the MEASUREMENT value Influx needs. I assume that it needs to be specified in the code when it RETURNS data. I think I can figure it out if I had a few examples, but I can’t find many simple ones.

Thanks for the response.

I have never used Chirpstack → InfluxDB but looking at the documentation it doesn’t seem like you need to have specific variables names or a MEASUREMENT value, it reads as though Influx DB will just create names based on the variables in the “object” section of the packet. Maybe share what your current decoded packet looks like from “Device Events” and what is showing up on InfluxDB (if anything).

I hear what you are saying and that is how I was expecting it to work as well. However I feel there needs to be specific statements in my codec that InfluxDB will use to create those names. Looking at that documentation I interpret it to mean “object”: will be used as MEASUREMENT in InfluxDB and “temperature_sensor”: would be one of the FIELDS inside that MEASUREMENT entry. I just don’t understand where to put that structure in my codec. And I do not see that kind of structure in other chirpstack codecs for Dragino products. Maybe they are also not set up to send data to InfluxDB. For me, there is not enough information in the chirpstack documentation to understand what I have to do.

image

ok couple of questions what kind of influx DB version are you using ? did you give the correct details in influx DB integration section in chripstack ? InfluxDB version? API endpoint (write)? Organization? Bucket? Token? if everything is correct then once delete the bucket & api token, add again both and see if it works…

I appreciate the questions and the willing to assist with my issues, however I have a new problem. My gateway just stopped working. I have a feeling the LoRa gateway hat on my pi just got fried. It seems very hot not and my gateway never goes online. The pi works and runs the code but it never goes online. Went back to my TTN version, just swapped SD cards but still does not go online.

I will let you know when I get this up and running again.

The MQTT forwarder is seperate from concentratorD and the LoRaWAN hat. Even if your hat got fried, the MQTT forwarder should still be sending stats messages to the server, and the server should still see the gateway as online, even if it’s LoRaWAN functionality broke. Likely the issue is something else entirely.

I had this gateway hardware, a RAK 7243C gateway running their latest firmware configured and connected as a TTN gateway and was running for a few years. I have 2nd similar gateway running outside connected to the TTN so, recently I thought I would use the RAK7243 to experiment with chirpstack. I set up a new SD card running chirpstack 4 and got it working receiving messages from one of my nodes. I ran it this way for a few weeks while I tried to get the data from my node in to either InfluxDB or Node-Red. I could not get either to work. Then I posted this topic for help and shortly after it went offline. I swapped the chirpstack SDcard with the original TTN configured card with RAK firmware on it, the gateway would never come online to TTN . I swapped out the 2245 hat, the kit is called a RAK7243 but the hat is a RAK2245, with an old RAK831 hat, the gateway came up on TTN. So I know the PI works. I tried re-flashing the firmware on the SD card with new chirpstack firmware and it still will not come online. That is the extent of my troubleshooting. It could be something else but I do not know where to look to start. If you have any ideas let me know. I will certainly explore any suggestions. I would love to learn more about this.

I appreciate all the replies.

I am back in business! I finally got my old RAK831 working with Chirpstack 4.9. It is online and reviving the data from my node and the codec is successfully decoding it. Now to get InfluxDB working.

@Mohan_B , I am looking through your questions now.

I am using InfluxDB ver 1.8.10 so I am selecting InfluxDB v1 an my API endpoint is http://xx.xx.xx.xx:8086/api/v1/write.

The other three questions, Organization? Bucket? Token?, I have no idea what you mean. Where do I find these options?

ok seems like you are not using Influx DB ver 2 above question i asked are for version 2 .so give username , password , data base name and Retention policy name. if it doesn’t work try restarting influx DB and also try creating new database name and check if its working.

Currently my InfluxDB does not have a username nor password so I am leaving that blank. I am also leaving the retention policy blank because I want to choose the default even though I don’t know exactly how long that is. I have started from scratch on my gateway/server so the InfluDB integration is new. I have restarted InfluxDB and have already tried a new database name an still does not work.

I still feel my codec is missing something or does the server, once it is decoded, just send the data to InfluxDB?

codec is not the issue i think, because we can see the data in the events .where are you running influx DB?

I am running InfluxDB in a VM under ProxMox. I have other LoRa sensors already sending data to different databases in InfluxDB through TTN and Node-Red to get it there. I have never gone directly.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.