Waziup / WaziGate

Waziup LoRa Edge gateway
21 stars 20 forks source link

problems with wazigate last version #168

Open teegwende opened 1 year ago

teegwende commented 1 year ago

Hello, I have installed the new version of wazigate on a RPI 3 model B. I have to some difficulties. 1- I have assembled a weather station and deployed it. The value of atmospheric pressure is negative and there many numbers after the decimal point in the value of wind speed. 2- I have tried to modify the value of an actuator I created. I used the API of wazigate to do that, but I wasn't able to do that. It is said that the actuator doesn't exist, but it does.

Find attached some snapshots that illustrate what I have explained. the term Pompe designates the device that contains the actuator.

Best regards !!

errorsofPoint1 errorPoint2

cdupont commented 1 year ago

@j-forster @24inch @SolomonGithu

SolomonGithu commented 12 months ago

@teegwende can you confirm that the weather station is sending different atmospheric and windspeed values that what appear on the WaziGate Dashboard.

teegwende commented 11 months ago

@SolomonGithu yes, the values are different. Sorry for late reply. Hope you are still going to help me fix the problem. I use raspberry pi 3 model B. Maybe this precision could helpful.

SolomonGithu commented 11 months ago

@teegwende can you use ChirpStack to check the uplink device data. Particularly the sensor values, and if they are different from the values on the WaziGate dashboard.

Also, which codec does your weather station use? Is it a custom codec or the ones available on the gateway (JSON, XLPP, LPP)?

From your screenshot, the sensor types are being received correctly but the values are different. Maybe the codec is doing some "conversion" with the sensor values

teegwende commented 11 months ago

Unfortunately, I have flashed the SD card with the version 2.2.0, So I am not able to provide you the data you want. Effectively, I didn't pay attention to the codec. I will try again the version 2.3.2 by making sure that I am going to select XLPP codec. I hope things are going to be OK now because I have some issues with the version 2.2.0. The gateway stops running after a period of time and does not emit the SSID.

teegwende commented 11 months ago

Hello guys, I have some details about the issues I have been explained at beginning. 1- about the codec. I have chosen XLPP but I still got the negative value. Please find attached pictures negativeValue.png and codecXLPP.png negativeValue codecXLPP 2-I can't access the actuator even I indicated the correct device ID and actuator ID. Please find attached for that pictures deivceID.png and deviceID2.png (it is to permit you to check that i have indicated the correct values), actuatorNotFound.png (the error i got) actuatorNotFound devicesID deviceID2

Hope this will help you to help me. Thanks in advance

SolomonGithu commented 11 months ago

Hello @teegwende

1) What is the weather station that you are using? Can you provide the brand/company and the product ID?

Maybe XLPP is not the correct codec for it

teegwende commented 11 months ago

I use the sparkfun Weather Meter Kit. the link of device description is : https://www.sparkfun.com/products/15901.

Find attached a snapshot of values collected when i use the version 2.2.0 of wazigate. Maybe it could be helpful. Screenshot from 2023-09-18 15-49-43

teegwende commented 11 months ago

the weather station is named stationMeteo. The atmospheric pressure is barometer 1

SolomonGithu commented 11 months ago

Hello @teegwende

  1. I think XLPP is not the correct decoder. I see that for this weather station you are free to select the microcontroller board that you want so the documentation of the weather station doesn't cover LoRaWAN. Correct me if am wrong.

This SparkFun documentation is a LoRaWAN tutorial for one of their LoRaWAN boards. In the tutorial they use the LMIC-Arduino Library and provide a simple decoder function at the section Decoding Your Data. If you have also used the LMIC-Arduino Library and added your sensor values to the payload, you can use the same TTN formatted decoder function on the WaziGate.

function Decoder(bytes, port) {
return {
    ASCII: String.fromCharCode.apply(null, bytes)
};
}

There is a WaziGate documentation on how to add your custom codecs. To add this SparkFun codec you can put the Decoder function to the JSON body in the POST codec request, that is:

const new_codec_script = `
function Decoder(bytes, port) {
return {
    ASCII: String.fromCharCode.apply(null, bytes)
};

}
`;

const jsonBody = {
  name: "SparkFun_Weather_Station_codec",
  mime: "application/javascript",
  script: new_codec_script
};

async function POST_custom_WaziGate_CODEC() {

  try {
    const POSTRequestResponse = await fetch("http://wazigate.local/codecs", {
      method: "POST",
      body: JSON.stringify(jsonBody),
      headers: {
        "Content-type" : "application/json"
      }

    });
    const POSTRequestResponseContent = await POSTRequestResponse.text();
    console.log("New codec id:", POSTRequestResponseContent);
  }
  catch (err) {
        console.error(`Error at POST_custom_WaziGate_CODEC : ${err}`);
        throw err;
    }
}

POST_custom_WaziGate_CODEC()

Afterwards run the JavaScript and the custom codec will be available in the device settings: Screenshot (4542) Screenshot (4306)

After adding the custom decoder to WaziGate, you need to ensure that there is a JavaScript runtime on the WaziGate(Raspberry Pi) like NodeJS. Please note that these instructions are for the latest WaziGate version WaziGate_V2.3.2

teegwende commented 11 months ago

Hello @SolomonGithu, thank you for your answer. You are right the documentation doesn't cover LoRaWAN. Please find attached the code I use for weather station. I am not really familiar with the codec neither. Where should I put the json code ? I mean in which file ? weatherStation.zip

SolomonGithu commented 11 months ago

Hello @teegwende I looked at your code and it is okay. Please use the latest WaziGate version, 2.3.2, and it should work fine. Also, the codec for the WaziGate Dashboard device should be XLPP.

Regarding the issue of not being able to see or modify actuator values this is because there is an issue with the endpoints being used by the Edge API Swagger Docs. Sorry about this. The actuator endpoints to set an actuator's value is /devices/{deviceID}/actuators/{actuatorID}/value

You can make the POST request to the WaziGate without using the Edge API DOCs by: 1) Get a token using a POST request to the url below. Headers = Accept: application/json", Default body credentials = { "username":"admin", "password":"loragateway"} http://localhost/auth/token 2) Make a POST request to /devices/{deviceID}/actuators/{actuatorID}/value with the Headers = WaziGate_headers_auth = { 'accept': 'application/json', 'content-type': 'application/json', 'Authorization': 'Bearer your_token' }

Make sure to replace value with the actuator value you want to set and your_token with the token that you received from step 1

Your can use curl or other codes to make the API requests.

teegwende commented 11 months ago

Hello @SolomonGithu, thanks for your support. I will give a try again.

Best regards !!