I am playing a bit with NodeMCU.
Please may you kindly troubleshoot this code? I am trying to adapt it from a tutorial:
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
#include <dht.h> // Includes the libraries for the sensor
#include <ESP8266wifi.h>
#include <ThingSpeak.h>
#define DHTPIN D5
#define DHTTYPE DHT22
dht DHT; // Creates a DHT object
const char* ssid = "WiFiName";
const char* password = "Password";
WiFiClient client;
unsigned long myChannelNumber = 174314;
const char * myWriteAPIKey = "JQPT38EM56K0MJM1";
uint8_t t, h;
void setup()
{
Serial.begin(115200);
delay(10);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Print the IP address
Serial.println(WiFi.localIP());
ThingSpeak.begin(client);
}
void loop()
{
static boolean data_state = false;
float t = DHT.temperature; // Gets the values of the temperature
float h = DHT.humidity; // Gets the values of the humidity
Serial.print("Temperature Value is :");
Serial.print(t);
Serial.println("C");
Serial.print("Humidity Value is :");
Serial.print(h);
Serial.println("%");
// Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different
// pieces of information in a channel. Here, we write to field 1.
if ( data_state )
{
ThingSpeak.writeField(myChannelNumber, 1, t, myWriteAPIKey);
data_state = false;
}
else
{
ThingSpeak.writeField(myChannelNumber, 2, h, myWriteAPIKey);
data_state = true;
}
delay(30000); // ThingSpeak will only accept updates every 15 seconds.
}
I received the error "WiFi was not declared in this scope" so I added the WiFi library from the list. I changed the board from "Arduino" to "generic ESP8266" (I also tried NodeMCU 0.9 and NodeMCU 1.0
Now I receive the following error:
Arduino: 1.8.1 (Windows 7), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck, Disabled, None"
C:\Users\mario\Desktop\Arduino to the Web project 0317\WI-FI codes\NodeMCU_v1\NodeMCU_v1.ino: In function 'void setup()':
NodeMCU_v1:30: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
WiFi.begin(ssid, password);
^
In file included from C:\Users\mario\Desktop\Arduino to the Web project 0317\WI-FI codes\NodeMCU_v1\NodeMCU_v1.ino:1:0:
C:\Program Files (x86)\Arduino\libraries\WiFi\src/WiFi.h:79:9: error: initializing argument 1 of 'int WiFiClass::begin(char*, const char*)' [-fpermissive]
int begin(char* ssid, const char *passphrase);
^
exit status 1
invalid conversion from 'const char*' to 'char*' [-fpermissive]
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
NOTE - If I change const char in char* it becomes lot worst with weird error that I do not have absolutely a clue about 
such as:
Arduino: 1.8.1 (Windows 7), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck, Disabled, None"
In file included from C:\Users\mario\Documents\Arduino\libraries\dht\dht.h:19:0,
from C:\Users\mario\Documents\Arduino\libraries\dht\dht.cpp:41:
C:\Users\mario\Documents\Arduino\libraries\dht\dht.cpp: In member function 'int8_t dht::_readSensor(uint8_t, uint8_t, uint8_t)':
C:\Users\mario\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\cores\esp8266/Arduino.h:226:63: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in initialization
#define portInputRegister(port) ((volatile uint32_t*) &GPI)
^
C:\Users\mario\Documents\Arduino\libraries\dht\dht.cpp:121:29: note: in expansion of macro 'portInputRegister'
volatile uint8_t *PIR = portInputRegister(port);
^
exit status 1
Error compiling for board Generic ESP8266 Module.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Please help guys 