Sky Quality Meter using FDRS #175
-
Hi folks, After brainstorming for a while, I finally managed to put together a project that I had in my head for some time. Since I'm not a programmer, it was challenging for me to reach a point where I could at least understand how to piece together bits of code and make it work to some extent. The project involves a remote device that will transmit Sky Quality Meter (SQM) data as light pollution progresses in our local national park and, in general, on our island (Aruba). The data can eventually aid our local authorities statistically in taking proper action. As you can imagine, there is no internet connection in the local park, so the main idea is to use the FDRS platform and LoRa protocol to transmit data to a gateway located approximately 1-2 km away. The components used at the node side are a TSL2591 Light Sensor and a BME280. I've managed to merge codes from the following repositories:
The main concept is illustrated below: To test the code, I've made things a little simpler. The combined code is currently transmitting data from the sensor node to the first gateway via ESPNOW and then through UART to the front end with MQTT. The main issue I'm facing is with the new SQM data type that is being loaded into the FDRS platform. I'm not sure, but the issue might be related to the JSON structure not being allowed through MQTT. Here's the string of data being received by the ESPNOW gateway from the sensor node:
Here's the error output from the MQTT gateway:
I've tried to modify the file 'fdrs_datatypes.h' for the new SQM value, but not sure if that's the only file needing to be modified. As a reference, here's the combined code in the sensor node:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
I've seen the same error. For me it was due to the default MQTT packet size limit. I believe 256 bytes by default. Can be changed by a #define or the setBufferSize() function. Was having issues with MQTT messages not sending - just generating the error. Figured out that the Arduino PubSubClient default size is 256 bytes and need to increase the default buffer by using setBufferSize. https://pubsubclient.knolleary.net/api#setBufferSize By default, it is set to 256 bytes - as defined by the MQTT_MAX_MESSAGE_SIZE constant in PubSubClient.h. Should be able to use client.setBufferSize(1024); and see if that works. fdrs_gateway_mqtt.h in the begin_mqtt() function:
|
Beta Was this translation helpful? Give feedback.
-
In the code you posted, insert: This will increase the MQTT buffer size from the default of 256 to 1024 bytes. |
Beta Was this translation helpful? Give feedback.
-
This is awesome and a great cause... thanks Jairo! SKYGLOW_T will be coolest-sounding data type, although I understand it is not a good thing! You should be able to just add it to the fdrs_datatypes.h file and it will be good-to-go. Stay in touch! |
Beta Was this translation helpful? Give feedback.
In the code you posted, insert:
client.setBufferSize(1024);
On the next line, after the line that starts
client.setServer(mqtt_server, mqtt_port);
This will increase the MQTT buffer size from the default of 256 to 1024 bytes.