sending sensors data to thingspeak

ANKIT KUMAR's picture

Offline

Joined: Oct 07, 2018

Replies: 2
sending sensors data to thingspeak
October 7, 2018 - 10:39pm
ANKIT KUMAR's picture

Offline

Joined: Oct 07, 2018

Replies: 2
i need help regarding the arduino code
October 7, 2018 - 10:40pm

Arduino: 1.8.7 (Windows Store 1.8.15.0) (Windows 10), Board: "Arduino/Genuino Uno"

F:\p\p.ino:12:14: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

 char*api_key="0UXHCZ777V0PAWPW";   // Enter your Write API key from ThingSpeak

              ^

F:\p\p.ino: In function 'void loop()':

p:51:6: error: 'class DHT' has no member named 'read11'

  dht.read11(DHT_dpin);

      ^

p:51:13: error: 'DHT_dpin' was not declared in this scope

  dht.read11(DHT_dpin);

             ^

In file included from F:\p\p.ino:1:0:

C:\Users\Ankit\Documents\Arduino\libraries\DHT/DHT.h:86:9: error: 'float DHT::humidity' is protected

   float humidity;

         ^

p:54:11: error: within this context

  humi=dht.humidity;

           ^

In file included from F:\p\p.ino:1:0:

C:\Users\Ankit\Documents\Arduino\libraries\DHT/DHT.h:85:9: error: 'float DHT::temperature' is protected

   float temperature;

         ^

p:59:11: error: within this context

   tem=dht.temperature;

           ^

F:\p\p.ino: In function 'void connect_wifi(String, int)':

F:\p\p.ino:100:27: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

       if(Serial1.find("OK"))

                           ^

Multiple libraries were found for "Timer.h"
 Used: C:\Users\Ankit\Documents\Arduino\libraries\Timer
 Not used: C:\Users\Ankit\Documents\Arduino\libraries\wiring_timer-2.5.0
 Not used: C:\Users\Ankit\Documents\Arduino\libraries\wiring-timer
 Not used: C:\Users\Ankit\Documents\Arduino\libraries\Timer-2.1
Multiple libraries were found for "DHT.h"
 Used: C:\Users\Ankit\Documents\Arduino\libraries\DHT
 Not used: C:\Users\Ankit\Documents\Arduino\libraries\Grove_Temperature_And_Humidity_Sensor-master
 Not used: C:\Users\Ankit\Documents\Arduino\libraries\Grove_Temperature_And_Humidity_Sensor
 Not used: C:\Users\Ankit\Documents\Arduino\libraries\DHT_sensor_library
exit status 1
'class DHT' has no member named 'read11'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Aswinth Raj's picture

Offline

Joined: Aug 16, 2016

Replies: 910
Multiple libraries Problem in Arduino
October 8, 2018 - 12:31pm

Hi Ankit Kumar, welcome to CircuitDigest Forums 

Multiple libraries were found for "Timer.h"

Multiple libraries were found for "DHT.h"

The error here is clearly mentioned in the console itself. That is there are multiple libraries installed for the Timer.h library and DHT.h library.

This because you should have added these libraries to the IDE more than once. And you IDE is now confused on selecting the right library  

If you are using windows go to My Documets -> Arduino -> Libraries

C:\Users\USername\Documents\Arduino\libraries

 

There you should find more than one folder for Timer.h and DHT.h delete all the duplicates and you should be good again.

Close the IDE and launch it again before compiling 

 

PS: Please post you questions in a single post avoid using multiple post for same same question. This way it will be easy for you to get answered. 

ANKIT KUMAR's picture

Offline

Joined: Oct 07, 2018

Replies: 2
codes
October 7, 2018 - 10:42pm

codes

#include<DHT.h>                      // Including library for dht
#include<LiquidCrystal.h>
LiquidCrystal lcd(14,15,16,17,18,19);
#include<Timer.h>
Timer t;
#include <SoftwareSerial.h>

SoftwareSerial Serial1(2, 3);
#define dht_dpin 12 
#define heart 13
 DHT dht;
char*api_key="0UXHCZ777V0PAWPW";   // Enter your Write API key from ThingSpeak
static char postUrl[150];
int humi,tem;
void httpGet(String ip, String path, int port=80);
void setup()
{
 lcd.begin(16, 2);
 lcd.clear();
 lcd.print("   Humidity   ");
 lcd.setCursor(0,1);
 lcd.print("  Measurement ");
 delay(2000);
 lcd.clear();
 lcd.print("Circuit Digest ");
 lcd.setCursor(0,1);
 lcd.print("Welcomes You");
 delay(2000);
 Serial1.begin(9600);
 Serial.begin(9600);
 lcd.clear();
 lcd.print("WIFI Connecting");
 lcd.setCursor(0,1);
 lcd.print("Please wait....");
 Serial.println("Connecting Wifi....");
 connect_wifi("AT",1000);
 connect_wifi("AT+CWMODE=1",1000);
 connect_wifi("AT+CWQAP",1000);  
 connect_wifi("AT+RST",5000);
 connect_wifi("AT+CWJAP=\"1st floor\",\"muda1884\"",10000);
 Serial.println("Wifi Connected"); 
 lcd.clear();
 lcd.print("WIFI Connected.");
 pinMode(heart, OUTPUT);
 delay(2000);
 t.oscillate(heart, 1000, LOW);
 t.every(20000, send2server);
}
void loop()
{
 dht.read11(DHT_dpin);
  lcd.setCursor(0,0);
  lcd.print("Humidity:");
 humi=dht.humidity;
  lcd.print(humi);   // printing Humidity on LCD
  lcd.print(" %    ");
  lcd.setCursor(0,1);
  lcd.print("Temperature:");
  tem=dht.temperature;
  lcd.print(tem);   // Printing temperature on LCD
  lcd.write(1);
  lcd.print("C ");
  delay(1000);
  t.update();
}
void send2server()
{
  char tempStr[8];
  char humidStr[8];
  dtostrf(tem, 5, 3, tempStr);
  dtostrf(humi, 5, 3, humidStr);
  sprintf(postUrl, "update?api_key=%s&field1=%s&field2=%s",api_key,humidStr,tempStr);
  httpGet("api.thingspeak.com", postUrl, 80);
}
//GET https://api.thingspeak.com/update?api_key=SIWOYBX26OXQ1WMS&field1=0
void httpGet(String ip, String path, int port)
{
  int resp;
  String atHttpGetCmd = "GET /"+path+" HTTP/1.0\r\n\r\n";
  //AT+CIPSTART="TCP","192.168.20.200",80
  String atTcpPortConnectCmd = "AT+CIPSTART=\"TCP\",\""+ip+"\","+port+"";
  connect_wifi(atTcpPortConnectCmd,1000);
  int len = atHttpGetCmd.length();
  String atSendCmd = "AT+CIPSEND=";
  atSendCmd+=len;
  connect_wifi(atSendCmd,1000);
  connect_wifi(atHttpGetCmd,1000);
}
void connect_wifi(String cmd, int t)
{
  int temp=0,i=0;
  while(1)
  {
    lcd.clear();
    lcd.print(cmd);
    Serial.println(cmd);
    Serial1.println(cmd); 
    while(Serial1.available())
    {
      if(Serial1.find("OK"))
      i=8;
    }
    delay(t);
    if(i>5)
    break;
    i++;
  }
  if(i==8)
  {
   Serial.println("OK");
        lcd.setCursor(0,1);
      lcd.print("OK");
  }
  else
  {
   Serial.println("Error");
         lcd.setCursor(0,1);
      lcd.print("Error");
  }
}