I am trying to create a data collector for my garden. I currently have a DHT11 hooked up (will add more externals later) to my Arduino Uno and would like to send data to ThingSpeak through the ESP8266-01S.
I would like to use libraries to keep my coding simple. Thinking it through, I would need the ones below:
#include <SoftwareSerial.h> //will be used to connect the ESP8266 to the Uno
#include <WiFi.h> //will be used to connect to the internet
#include "DHT.h" //will be used to collect data from the DHT11
#include "ThingSpeak.h" //will be used to send data to ThingSpeak
I think I need to connect the SoftwareSerial to the WiFi since I need to be able to transmit data. Then once that is established I'd have to use that with ThingSpeak so it can send data to the proper channels.
I tried breaking everything down as simple as possible for me to just connect to the internet and send data out:
#include <SoftwareSerial.h>
#include <WiFi.h>
#include "ThingSpeak.h"
char ssid[] = "network";
char pass[] = "password";
int status = WL_IDLE_STATUS;
SoftwareSerial esp(2,3); // RX,TX
void setup() {
Serial.begin(9600);
esp.begin(9600); //SoftwareSerial
Serial.print("Attempting to connect to internet ");
WiFi.begin(ssid, pass); //so this starts the WiFi but how does it know to connect to esp?
while (WiFi.status() != WL_CONNECTED) { //Obviously this code never gets me out of this loop
delay(5000);
Serial.print(".");
}
Serial.println("\nConnected.");
ThingSpeak.begin(); //need to connect ThingSpeak to the ESP which should be connected to the internet. But how??
delay(5000);
}
void loop() {
//delay(5000);
//use ThingSpeak to write to data out
}
Any suggestions? Thanks!