Using Arduino LoRa network on the sensor community project?

Hello everyone,

I have some equipment from an abandoned internal project at a French research institute.

Each pollution sensor kit includes:

  • an Arduino MKR WAN 1310 board
  • an SDS011 particle sensor
  • an HTU21D temperature/humidity sensor soldered to a PCBA (printed circuit board)
  • a LoRa antenna
  • a battery.

More information is available here:

I would like to know if it would be possible to reuse this equipment to integrate it into the Sensor.Community network.

Do you think it would be possible to integrate Sensor.Community compatible firmware directly onto the Arduino MKR WAN 1310 and transmit the data via the LoRa antenna over a paid network ( Couverture LoRa® Orange | Orange Business ) to then view it on the Sensor.Community board?

There seem to be many challenges (Arduino, LoRa, battery), but who knows!

All your advice and examples would be greatly appreciated. I found this project; are you familiar with it?

Thanks in advance for your advice,

— Mathias

Hi,

Have you tried to flash the SC code on the MKR with Platformio?

Maybe it works more or less directly.

Then you can check this code : GitHub - aircarto/ModuleAir_V2.1 at pj-new-wifi

But I don’t know how the LoRaWAN works on the MKR.

Have you ever used a LoRaWAN Platform ? I should ba able to provide you the codes for it.

What I did to get PM sensors working on TheThingsNetwork:

  1. Create a TTN community account
  2. Create an ‘application’ on the TTN account
  3. Implement a LoRaWAN stack on the Arduino, something like arduino-lmic or the LoRaWAN support in RadioLib. To connect a LoRaWAN device, you need a set of three identifying this: a) a device EUI, b) a “join EUI” and c) a “join secret”. You can usually derive a) from the hardware, then generate b) and c) on the TTN console and program them into your device.
  4. I wrote an backend application (in Java, but could also be python for example) that listens for LoRaWAN messages from TTN, then converts them to air quality values. Finally it forwards the measurements to sensor.community, basically emulating a normal sensor.community node. You need to have registered a node with sensor.comunity with the proper sensor types etc. This application also needs to know how the arduino application packed the data into a binary blob.

I think the coverage of TheThingsNetwork is not so great in France.

I have also been experimenting to get community science data through meshtastic and meshcore LoRa networks. I managed to get the basic mechanism working for meshtastic, need more work for meshcore. Meshtastic basically has internet-connectivity basically built-in, the meshcore community seems anti-internet-connectivity. These networks are still developing, frequencies are changing, algorithms and software is still changing, not everyone is using the same settings, so it’s a bit unstable still. I think that most boards that can do LoRaWAN can also do meshtastic/meshcore.

Hello,

thank you for your advice ! I finally installed the initial program and I’m getting good results in the Arduino IDE with the Serial Monitor.

17:24:32.371 -> Temp: 19.96 C		Humidity: 52.11 %
17:24:33.863 -> PM2.5 = 4.20, PM10 = 9.30
17:24:33.863 -> pm25: 4.20, pm10: 9.30
17:24:33.863 -> a8*************
17:24:33.863 -> 70******************
17:24:33.863 -> 15*******************************

Next, @bertrik I’m interested in your program for sending data to sensor.community via TTN. I have an antenna near my house; I’ll try to connect and if not, I’ll borrow one. If that works, I’ll connect to a paid network.

However, I am not a developer and do not know JavaScript and Python, do you have a tutorial or anything else?

Maybe Aircarto can help you. You will need a Registration on a LoraWan Platform. And then a webhook System

Hello, I’m using my own gateway and the connection between the sensor and the gateway is working fine. Here’s my latest version of the webhook, but it’s still not working. I found this discussion with this GitHub project; do you think it would be helpful for my situation?

https://forum.sensor.community/t/integration-ttn/1248/2

https://github.com/bertrik/sensor-data-bridge

<?php
// DevEUI du capteur à traiter
$allowed_dev_eui = '-----i hide it----';
// Lire le JSON envoyé par TTN
$input = file_get_contents('php://input');
// Débogage : sauvegarder le JSON brut pour vérification
file_put_contents('debug_ttndata.json', $input.PHP_EOL, FILE_APPEND);
// Décoder le JSON
$data = json_decode($input, true);
// Vérifier si uplink_message et frm_payload existent
if (!isset($data['uplink_message']['frm_payload'])) {
    http_response_code(400);
    echo "Missing frm_payload";
    exit;
}
// Vérifier que le DevEUI correspond
$dev_eui = $data['end_device_ids']['dev_eui'] ?? '';
if ($dev_eui !== $allowed_dev_eui) {
    http_response_code(400);
    echo "Unknown device";
    exit;
}
// Décoder le frm_payload (base64)
$payload_base64 = $data['uplink_message']['frm_payload'];
$payload_bin = base64_decode($payload_base64);
// Supposons que le payload contient 4 floats de 4 bytes chacun (ex: température, humidité, pression, autre)
$values = [];
if (strlen($payload_bin) === 16) { // 4 floats * 4 bytes
    for ($i = 0; $i < 4; $i++) {
        $chunk = substr($payload_bin, $i*4, 4);
        $values[] = unpack("G", $chunk)[1]; // "G" = float 32-bit big endian
    }
}
// Ici tu peux envoyer $values vers ta base ou Carto
// Exemple simple : sauvegarde CSV
$line = date('c') . ',' . implode(',', $values) . PHP_EOL;
file_put_contents('sensor_data.csv', $line, FILE_APPEND);
http_response_code(200);
echo "OK";
?>

Why php ?

Is it not js? Or can you choose?

Have you asked Aircarto ?

And Bertrik ?

Bertrik project was basically working with SC.

Of you get the data on the LoRaWAN Provider 9/10 of the Job is done.