Send data to TTN

I hope you are well. I would like to ask for your help with a problem. I’m using a dragino lora la66 shield module to send data to TTN. But I’m having trouble and I’d like you to help me Here’s the code:

#include “PMS.h”
#include “SoftwareSerial.h”
#include <MICS6814.h>
#include <DHT.h>

SoftwareSerial Serial1(2, 3); // RX, TX
PMS pms(Serial1);
PMS::DATA data;

#define PIN_CO A3
#define PIN_NO2 A4
#define PIN_NH3 A5
MICS6814 gas(PIN_CO, PIN_NO2, PIN_NH3);

//Constants
#define DHTPIN 7 // what pin we’re connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value

// Definitions for SO₂ sensor
#define RL_SO2 4.63 // Resistor value for SO₂ sensor, ohms
#define m_SO2 -0.8146 // Calculated slope for SO₂
#define b_SO2 1.217 // Calculated intercept for SO₂
#define Ro_SO2 1.64 // Found Ro value for SO₂
#define MQ_SO2 A2 // SO₂ sensor is connected to analog pin A0

// Definitions for O₃ sensor
#define RL_O3 1 // Resistor value for O₃ sensor, 47K ohms
#define m_O3 0.4627 // Calculated slope for O₃
#define b_O3 -0.56 // Calculated intercept for O₃
#define Ro_O3 37.84 // Found Ro value for O₃
#define MQ_O3 A1 // O₃ sensor is connected to analog pin A1

void setup() {
Serial.begin(9600); // Initialisation du moniteur série
Serial1.begin(9600); // Initialisation du capteur PMS
dht.begin();

Serial.println(“Warming up…”);
Serial.println(“Ready to measure dust concentration.”);
Serial.println(“MICS-6814 Sensor Sample”);
Serial.print(“Calibrating Sensor”);
gas.calibrate();
Serial.println(“OK!”);
}

void loop() {

// Variables for SO₂ sensor
float VRL_SO2;
float Rs_SO2;
float ratio_SO2;
float ppm_SO2;

// Variables for O₃ sensor
float VRL_O3;
float Rs_O3;
float ratio_O3;
float ppb_O3;

// Measure SO₂ concentration
VRL_SO2 = analogRead(MQ_SO2) * (5.0 / 1023.0); // Voltage for SO₂ sensor
Rs_SO2 = ((5.0 * RL_SO2) / VRL_SO2) - RL_SO2; // Resistance Rs for SO₂
ratio_SO2 = Rs_SO2 / Ro_SO2; // Ratio Rs/Ro for SO₂
ppm_SO2 = pow(10, ((log10(ratio_SO2) - b_SO2) / m_SO2)); // Calculate ppm for SO₂
float SO2=40.9*ppm_SO2*64.06;

// Measure O₃ concentration
VRL_O3 = analogRead(MQ_O3) * (5.0 / 1023.0); // Voltage for O₃ sensor
Rs_O3 = ((5.0 * RL_O3) / VRL_O3) - RL_O3; // Resistance Rs for O₃
ratio_O3 = Rs_O3 / Ro_O3; // Ratio Rs/Ro for O₃
ppb_O3 = pow(10, ((log10(ratio_O3) - b_O3) / m_O3)); // Calculate ppb for O₃
float O3=0.0409*ppb_O3*48;

if (pms.read(data)) {

```
 hum = dht.readHumidity();
temp= dht.readTemperature();
//Print temp and humidity values to serial monitor
Serial.print("Humidite: ");
Serial.print(hum);
Serial.println(" %");
 Serial.print("Temperature: ");
Serial.print(temp);
Serial.println(" Celsius");

// Affichage dans le moniteur série
Serial.print("PM2.5 : ");
Serial.print(data.PM_AE_UG_2_5);
Serial.println(" ug/m3");

Serial.print("PM10  : ");
Serial.print(data.PM_AE_UG_10_0);
Serial.println(" ug/m3");

Serial.print("O3  : ");
Serial.print(O3);
Serial.println(" ug/m3");
Serial.print("SO2  : ");
Serial.print(SO2);
Serial.println(" ug/m3");

  Serial.print("CO: ");
Serial.print(gas.measure(CO)*0.0409*28.01);
Serial.println(" mg/m3");

Serial.print("NO2: ");
 Serial.print(gas.measure(NO2)*40.9*46.01);
 Serial.println(" ug/m3");
Serial.println("******************************************************************");
  delay(10000); // Délai de 1 seconde avant la prochaine lecture
```

}
}

When posting code, please use the controls at the top of the input box to format the post for readability.

What is the issue you need help with? Your message contains code, what does work, what doesn’t and what should it do that needs fixing?

Thank you. My problem is that I would like to write a code to retrieve the data displayed in the monitor on TTN. But I don’t know how to do it

erer

these are the results I get in the serial monitor. I would like to send this data to TTN with a la66 shield dragino module connected to arduino uno.

Have you tried the example Dragino makes available at Dropbox ?

If you followed the documentation, materials & examples to get you to the point of having the readings, then you repeat the same sort of process of looking at the docs & examples for the LA66 and integrate the example in to your code.

If you’ve done it for the sensors, then dive on in with the supplied info from Dragino!

I had a problem with the LA66 and DHT that sounded similar. The solution for me was to install the correct libraries: Adafruit_Unified_Sensor and DHT_kxn.

The OP has the sensors working, it’s the LW integration that they got stuck on.