Post topics, source code that relate to the Arduino Platform

User avatar
By Lucas neill
#62795
gdsports wrote:There are two sets of ssid/password. ESP-DHT has the DHT sensor and it must connect to ESP-AP. ESP-AP is an AP with its own ssid/password, different from your home wifi router ssid/password. When the ESP-AP sends data to thingspeak on the Internet, it must connect to your home wifi router so it must know that pair as well.

1-For the ssid part should I put my own network's ssid?

In the AP mode INO file look for the function setupStMode. Inside this function modify WiFi.begin() so it has the ssid/password of your home wifi router.

Code: Select allWiFi.begin("myhomessid", "myhomepassword");


2-And there are sections with stars like(*********) which of them I must edit?

In the AP mode INO file modify the following lines. The ssid must be different from your home router ssid.

Code: Select all// Internet router credentials
const char* ssid = "ESPAP";
const char* password = "ESPAPsecret";


The ESP-DHT client must connect to the ESP-AP so the ssid/password in the client program must match the ssid/password in the AP program.

Code: Select all// AP Wi-Fi credentials
const char* ssid = "ESPAP";
const char* password = "ESPAPsecret";


3-For example wifi.begin() has stars. It ll stay with stars or I must enter my ssid and password there?

Change the stars as described above.

I have never used these programs so this is just a best guess. You will just have to try and see if these changes work or not.


first of all thanks

i think i could do it right. but i still have a question.

1- whats the time interval this porject sends data to thingspeak? because when i check thingspeak and refresh page it doesnt refresh the temperature but if i reset the module it gets the new data.?
2- i couldnt check this because the temperature is still above 20, it needs to be below 20 to check if the AP side works well so my question is this code send the updated temperature to AP side continuously or in specified intervals?
User avatar
By Lucas neill
#62824
martinayotte wrote:It is not clear what is your question.
Is it only to add gpio code to turn on relay ?
if yes, is it according to the temperature send to handle_feed() callback ?
Maybe something like this from your AP :

Code: Select all// Handling the /feed page from my server
void handle_feed() {
  String t = server.arg("temp");
  String h = server.arg("hum");
 
  server.send(200, "text/plain", "This is response to client");
  setupStMode(t, h);

  // new code added here for the relay
  long temp = t.toFloat();
  if (temp < 20.0)
    digitalWrite(2, HIGH); // Turn ON Relay on GPIO2
  else
    digitalWrite(2, LOW); // Turn OFF Relay on GPIO2
}

You also need to add in setup :

Code: Select all  pinMode(2, OUTPUT); // Make GPIO2 as an OUTPUT to drive Relay MOSFET

from client’s serial monitor i can just see these below once and nothing else more, what does it mean? Is this the reason why I can't get the data updated? Is the code stuck here? It doesn't return to the beginning?

“ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld

**************************
**************************
******** BEGIN ***********
– start DHT sensor
– set ESP STA mode
– connecting to wifi

……- wifi connected
– read DHT sensor
– temperature read : 21.10
– humidity read : 38.90
– build DATA stream string
– data stream: temp=21.10&hum=38.90
– send GET request
This is response to client
– got back to sleep
**************************
**************************

ets Jan 8 2013,rst cause:5, boot mode:(3,6)

ets_main.c “