RHF76-052 (SEEEDUINO LORAWAN ) with DHT11

hello guys,
i am trying to set up my lora end node with the seeeduino RHF76-052 with the DHT11 sensor
image

i don’t know why i am having this error … please help me to solve it

kind regards

please don’t place screenshots , only your full formatted code

thank you

Probably an error your code.

The errors are often in the code you dont post.

here is my code :

#include <DHT.h>
#include <LoRaWan.h>

#define DHTPIN A0 // what pin we’re connected to
// Uncomment whatever type you’re using!
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);

unsigned char data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA,};
//unsigned char data[4];
char buffer[256];

void setup(void)
{
SerialUSB.begin(115200);
while(!SerialUSB);

lora.init();

memset(buffer, 0, 256);
lora.getVersion(buffer, 256, 1);
SerialUSB.print(buffer); 

memset(buffer, 0, 256);
lora.getId(buffer, 256, 1);
SerialUSB.print(buffer);
// void setID( char *DevAddr, char *DevEUI, char *AppEUI);
lora.setId(NULL, "F9C01FAA68E1D265" , "70B3D57ED00210F4");
//setKey(char *NwKSKey, char *AppSKey, char *AppKey);
lora.setKey(NULL, NULL, "3FB33E70EECACFB206D4589FFD44980E");


lora.setDeciveMode(LWOTAA);
lora.setDataRate(DR0, EU868);

lora.setChannel(0, 868.1);
lora.setChannel(1, 868.3);
lora.setChannel(2, 868.5);

lora.setReceiceWindowFirst(0, 868.1);
lora.setReceiceWindowSecond(869.5, DR3);

lora.setDutyCycle(false);
lora.setJoinDutyCycle(false);

lora.setPower(14);

while(!lora.setOTAAJoin(JOIN));

}

void loop(void)
{
bool result = false;
delay(200);
SerialUSB.println("-- LOOP");
//
//Reading the humidity of the sensor
// uint32_t humidity = dht.readHumidity(false) * 100;
uint32_t humidity = DHT.readHumidity(false) * 100;

//Reading the temperature of the sensor
uint32_t temperature = DHT.readTemperature(false) * 100;

//

//

byte payload[4];
payload[0] = highByte(temperature);
payload[1] = lowByte(temperature);
payload[2] = highByte(humidity);
payload[3] = lowByte(humidity);

//
SerialUSB.print("Temperatura: ");
SerialUSB.println(temperature);
SerialUSB.print("Umidade: ");
SerialUSB.println(humidity);

//

// result = lora.transferPacket(“Hello World!”, 10);
//result = lora.transferPacket(data, 10, 10);

if(result)
{
    short length;
    short rssi;
    
    memset(buffer, 0, 256);
    length = lora.receivePacket(buffer, 256, &rssi);
    
    if(length)
    {
        SerialUSB.print("Length is: ");
        SerialUSB.println(length);
        SerialUSB.print("RSSI is: ");
        SerialUSB.println(rssi);
        SerialUSB.print("Data is: ");
        for(unsigned char i = 0; i < length; i ++)
        {
            SerialUSB.print("0x");
            SerialUSB.print(buffer[i], HEX);
            SerialUSB.print(" ");
        }
        SerialUSB.println();
    }
}

}

1 Like

and the error is
expected primary-expression before ‘.’ token

And the error is in the code you first did not show us.

Arduino variables and definitions are case sensitive, so you define;

DHT dht(DHTPIN, DHTTYPE);

and then use DHT instead of dht;

uint32_t humidity = DHT.readHumidity(false) * 100;
uint32_t temperature = DHT.readTemperature(false) * 100;

#include <DHT.h>
#include <LoRaWan.h>

#define DHTPIN A0 // what pin we’re connected to
// Uncomment whatever type you’re using!
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);

unsigned char data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA,};
//unsigned char data[4];
char buffer[256];

void setup(void)
{
SerialUSB.begin(115200);
while(!SerialUSB);

lora.init();

memset(buffer, 0, 256);
lora.getVersion(buffer, 256, 1);
SerialUSB.print(buffer); 

memset(buffer, 0, 256);
lora.getId(buffer, 256, 1);
SerialUSB.print(buffer);
// void setID( char *DevAddr, char *DevEUI, char *AppEUI);
lora.setId(NULL, "F9C01FAA68E1D265" , "70B3D57ED00210F4");
//setKey(char *NwKSKey, char *AppSKey, char *AppKey);
lora.setKey(NULL, NULL, "3FB33E70EECACFB206D4589FFD44980E");


lora.setDeciveMode(LWOTAA);
lora.setDataRate(DR0, EU868);

lora.setChannel(0, 868.1);
lora.setChannel(1, 868.3);
lora.setChannel(2, 868.5);

lora.setReceiceWindowFirst(0, 868.1);
lora.setReceiceWindowSecond(869.5, DR3);

lora.setDutyCycle(false);
lora.setJoinDutyCycle(false);

lora.setPower(14);

while(!lora.setOTAAJoin(JOIN));

}

void loop(void)
{
bool result = false;
delay(200);
SerialUSB.println("-- LOOP");
//
//Reading the humidity of the sensor
// uint32_t humidity =DHT.readHumidity(false) * ;
uint32_t humidity =DHT.readHumidity(false) *100 ;

uint32_t temperature =DHT.readTemperature(false) *100 ;

//

//

byte payload[4];
payload[0] = highByte(temperature);
payload[1] = lowByte(temperature);
payload[2] = highByte(humidity);
payload[3] = lowByte(humidity);

//
SerialUSB.print("Temperatura: ");
SerialUSB.println(temperature);
SerialUSB.print("Umidade: ");
SerialUSB.println(humidity);

//

// result = lora.transferPacket(“Hello World!”, 10);
//result = lora.transferPacket(data, 10, 10);

if(result)
{
    short length;
    short rssi;
    
    memset(buffer, 0, 256);
    length = lora.receivePacket(buffer, 256, &rssi);
    
    if(length)
    {
        SerialUSB.print("Length is: ");
        SerialUSB.println(length);
        SerialUSB.print("RSSI is: ");
        SerialUSB.println(rssi);
        SerialUSB.print("Data is: ");
        for(unsigned char i = 0; i < length; i ++)
        {
            SerialUSB.print("0x");
            SerialUSB.print(buffer[i], HEX);
            SerialUSB.print(" ");
        }
        SerialUSB.println();
    }
}

}

the same problem

Note this bit I said;

and then use DHT instead of dht ;

Meaning you used DHT but you should have used dht

As far as I can see the original code on the Seeduino WiKi is correct, so maybe you changed it ?

thank you i am sorted out there is no more error

but how to make the payload data human readable? , we should code some line of code to the payload format …can you help with that?

image

I closed your other topic with the same question.
please don’t use screenshots for code and don’t ask everything twice (and do some ‘homework’ yourself.

thank you :sunglasses:

hello BoRRoZ
i did my homework like you said and am able now to send data( temperature , humidity and moisture ) to the things network

#include <TheThingsNetwork.h>

//#include <TheThingsNetwork.h>
#include <DHT.h>
#include <LoRaWan.h>

#define DHTPIN A0 // the pin we’re connected the temperature and humidity sensor

#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
#define moisture A2 // the pin we’re connected the moisture sensor
int moistureval;
//#define sensorValue float

unsigned char data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA,};
//unsigned char data[4];
char buffer[256];

void setup(void)
{
SerialUSB.begin(115200);
pinMode(moisture,INPUT);
while(!SerialUSB);

lora.init();

memset(buffer, 0, 256);
lora.getVersion(buffer, 256, 1);
SerialUSB.print(buffer); 

memset(buffer, 0, 256);
lora.getId(buffer, 256, 1);
SerialUSB.print(buffer);
// void setID( char *DevAddr, char *DevEUI, char *AppEUI);
lora.setId(NULL, "xxxxxxxxxxxxxx" , "xxxxxxxxxxxxxxxx");
//setKey(char *NwKSKey, char *AppSKey, char *AppKey);
lora.setKey(NULL, NULL, "xxxxxxxxxxxxxxxxxxxxxxxxxxxx");


lora.setDeciveMode(LWOTAA);
lora.setDataRate(DR5, EU868);

lora.setChannel(0, 868.1);
lora.setChannel(1, 868.3);
lora.setChannel(2, 868.5);

lora.setReceiceWindowFirst(1, 868.3);
lora.setReceiceWindowSecond(869.525, DR0);

lora.setDutyCycle(false);
lora.setJoinDutyCycle(false);

lora.setPower(14);

while(!lora.setOTAAJoin(JOIN));

}

void loop(void)
{
moistureval = analogRead(moisture);
bool result = false;
delay(3000);
SerialUSB.println("-- LOOP");
//

//Reading the humidity of the sensor
// uint32_t humidity =DHT.readHumidity(false) ;
uint32_t humidity =dht.readHumidity()*100;

uint32_t temperature =dht.readTemperature(false)*100 ;
//float h = dht.readHumidity();
//float t = dht.readTemperature();

// read the value from the sensor:

//

//

byte payload[6];
payload[0] = highByte(temperature);
payload[1] = lowByte(temperature);
payload[2] = highByte(humidity);
payload[3] = lowByte(humidity);
payload[4] = highByte(moistureval);
payload[5] = lowByte(moistureval);


//
//SerialUSB.print("Temperature: ");
//SerialUSB.println(temperature);
//SerialUSB.print("humidity: ");

//SerialUSB.println(humidity);
SerialUSB.print("moisture = " );
SerialUSB.println(moistureval);

SerialUSB.print("Temperature: "+String (temperature));
SerialUSB.print("humidity: "+String (humidity));

result = lora.transferPacket(payload, 6, 10);

















if(result)
{
    short length;
    short rssi;
    
    memset(buffer, 0, 256);
    length = lora.receivePacket(buffer, 256, &rssi);
    
    if(length)
    {
        SerialUSB.print("Length is: ");
        SerialUSB.println(length);
        SerialUSB.print("RSSI is: ");
        SerialUSB.println(rssi);
        SerialUSB.print("Data is: ");
        for(unsigned char i = 0; i < length; i ++)
        {
            SerialUSB.print("0x");
            SerialUSB.print(buffer[i], HEX);
            SerialUSB.print(" ");
        }
        SerialUSB.println();
    }
}
 delay(5000);

}

but i want to go far with the application , i opted to use cayenne dashboard
i did find this code for the node

#include <TheThingsNetwork.h>
#include <CayenneLPP.h>

// Set your AppEUI and AppKey
const char *appEui = “xxxxxxxxxxxxxx”;
const char *appKey = “xxxxxxxxxxxxxxxxxxxxxxxxxxxx”;

#define loraSerial Serial1
#define debugSerial Serial

// Replace REPLACE_ME with TTN_FP_EU868 or TTN_FP_US915
#define freqPlan TTN_FP_EU868

TheThingsNetwork ttn(loraSerial, debugSerial, freqPlan);
CayenneLPP lpp(51);

void setup()
{
loraSerial.begin(57600);
debugSerial.begin(9600);

// Wait a maximum of 10s for Serial Monitor
while (!debugSerial && millis() < 10000)
;

debugSerial.println("-- STATUS");
ttn.showStatus();

debugSerial.println("-- JOIN");
ttn.join(appEui, appKey);
}

void loop()
{
debugSerial.println("-- LOOP");

lpp.reset();
lpp.addTemperature(1, 22.5);
lpp.addBarometricPressure(2, 1073.21);
lpp.addGPS(3, 52.37365, 4.88650, 2);

// Send it off
ttn.sendBytes(lpp.getBuffer(), lpp.getSize());

delay(10000);
}

where and how to start changing this code( converting the payload to lpp cayenne) , in the purpose to visualize data to cayenne dashboard

kind regard

1 Like