Send dht11 data arduino nano to arduino nanoi over RS232(Serial port).)

Hi guys.
A tried to send dht11 data from arduino to arduino, but i only got the temperature.
We know that the dht11 datas are types of float we needed to convert them to string, and after that on the receiver side convert them back to float but i only got the temperature if some of you know some solutions pls contact me on facebook Facebook.
Thank you for your help.

Serial.print/println will transmit a float as text.

atof() will convert ascii to a float.

@tinkodev, your topic has been moved to a more suitable location on the forum.

I think that more people will benefit if replies are posted on the forum.

thank you :smiley:

Yeah i know this functions but i out both of them(temperature,humidity) to one string , but on the receiver side i only got the temperature if you know arduino codeing better than me :smiley: I think you are :)) Can you contact me to analyze my code?

Please post your code here. That way other people with a similar problem might find a solution.

@tinkodev - No one is going to contact you to ask you for your code. Post it here (Correctly - using the code tags) - for us to have a look at, but I suspect that you may need to work out a protocol similar to :
Send ‘hello’ - Serial.print("<");
Send Temperature - Serial.print(temperature);
Send seperator - Serial.print("#");
Send Humidity - Serial.print(humidity);
Send ‘close’ - Serial.print(">");

The on the receiving Arduino, reverse the process to give you char arrays with the correct data.

This is actually not mine but pls analye how can i do itt better(Transciever).

#include <DHT.h>
#define DHTPIN 10
#define DHTTYPE DHT11

char suhu_ch [10];
char kelembapan_ch [10];
char su_and_kel [10];
char sendstring_ch [10];

DHT dht(DHTPIN, DHTTYPE);

void setup() {
dht.begin();
Serial.begin(9600);
}

void loop() {

// first we measure temperature and humidity
float suhu_fl = dht.readTemperature();
float kelembapan_fl = dht.readHumidity();

// then we convert the floats to char strings named “suhu_ch” and “kelembapan_ch”
dtostrf(suhu_fl, 0, 2, suhu_ch); // (floatVariable, string_length_incl_decimalpoint, number_decimals, array_to_store)
dtostrf(kelembapan_fl, 0, 2, kelembapan_ch); // floatVar, minStringWidthIncDecimalPoint, numVarsAfterDecimal, empty array)

// now we are going to combine both strings into one string named “sendstring_ch” that is going to be serially transmitted to Arduino nr 2

strcat (sendstring_ch, suhu_ch); // add shuhu_ch to sendstring_ch
strcat (sendstring_ch, kelembapan_ch); // add kelembapan_ch to sendstring_ch

// check with Serial Monitor
Serial.print("sendstring_ch = ");
Serial.println(sendstring_ch);

// before the next iteration sendstring_ch needs to be emptied
memset(sendstring_ch, ‘\0’, 10); // empty sendstring_ch after serial print

delay(1000);

}

(Receiver) And i only can see the temperature with 10 digits.
// Fahli_Arduino_LCD_serial
// this sketch receives a 10-char long string via TX-RX serial comm
// this string contains coded two concatenated strings each 5 chars
// - a temperature string of two numbers - period - two numbers
// - a humidity string of two numbers - period - two numbers
// the 10 char ‘receivestring_ch’ is broken up into two strings of five chars
// Floris Wouterlood - July 20 1017
// public domain

String receivestring_ch;
String suhu_ch;
String kelembapan_ch;

void setup()
{
Serial.begin(9600);

}

void loop()
{

while(Serial.available()){
delay(10);
if (Serial.available() >0) {
char c = Serial.read(); // gets one byte from serial buffer
receivestring_ch += c; // construct the recievestring_ch
}
}

if (receivestring_ch.length() >0) {
Serial.print("receivestring_ch = "); // see what was received
Serial.println(receivestring_ch); // see what was received

// == expect a string like 15.0060.00 containing the suhu and kelembapan (tempo, humidity) ==

 suhu_ch = receivestring_ch.substring(0, 5);       // get the first five characters
 kelembapan_ch = receivestring_ch.substring(5, 10); // get the next five characters

 receivestring_ch = ""; //  
 Serial.print("suhu_ch = ");                       
 Serial.println(suhu_ch);                          // see what was received
 Serial.print("kelembapan_ch = ");                 
 Serial.println(kelembapan_ch);                    // see what was received
 Serial.println();                                 // clear the receivestring_ch


 float suhu_fl = 0.00;                             // declare float for temp
 float kelembapan_fl = 0.00;                       // declare float for humidity

 
 char carray1[6];                                  // magic needed to convert string to a number
 suhu_ch.toCharArray(carray1, sizeof(carray1));
 suhu_fl = atof(carray1);
 Serial.print(suhu_fl);

 
 char carray2[6];
 kelembapan_ch.toCharArray(carray2, sizeof(carray2));
 kelembapan_fl = atof(carray2);

{

}

suhu_fl=0; // cleear suhu_fl
kelembapan_fl=0; // clkear kelembapan_fl

delay(1000);

}
}