So I had an ESP8266 ESP01 module programmed to post to the web and it did so for the longest time without issues all while being powered from the 3.3V pin on an UNO (and the dht22 was powered from the 5V pin.)
Alas, after some power fluctuations which are quite common in my country, something must have happened and the esp01 started hanging and missing posts. So I took the module and plopped it onto a programmer usb to my laptop and it worked just fine (I mean I could see the response in the serial monitor as if it was posting, but it was sending garbage data as posted below since the dht22 wasnt connected to the esp01 anymore).
I decided it might be a power issue (from a damaged UNO powering the module) and i built a small 3.3V power supply with a LM1117. I just moved the esp01 module over to that power supply and realized i was still powering my dht22 from the uno's 5v pin. So I was wondering about the best way to make a power supply for both voltages since I also have 7805 lying around. But no sooner did I start writing this post and I just noticed that my google home and laptop just got kicked off my wifi. It seems whenever I have the esp01 connect to my wifi, it messes with something. It actually makes it so my laptop no longer sees the wifi and kicks it off the wifi. This is very reproducible behavior. 30 seconds after i power up the esp01 module I see the Google Home & laptop get knocked off. I unplug the esp and I can see my google home and laptop connecting to my ssid.
Any ideas what the issue could be?
Here is the code on my esp:
#include <ESP8266WiFi.h>
#include <dht.h>
#define DHT22_PIN 2//#define DHTPIN 2 // what pin we're connected to
dht DHT;
const char* ssid = "ssid";
const char* password = "mykey";
const char* host = "myserver.com";
unsigned long previousMillis = 0; // will store last time was updated
const long interval = 180000;
char tempString[20];
char humString[20];
void setup() {
Serial.begin(115200);
delay(100);
// We start by connecting to a 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");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
int value = 0;
void start_test () {
int chk = DHT.read22(DHT22_PIN);
float h = DHT.humidity;//dht.readHumidity();
float t = DHT.temperature;//readTemperature();
dtostrf(t, 4, 2, tempString); //convert flat to char
dtostrf(h, 4, 2, humString); //convert flat to char
}
void loop() {
///////////INSERTED millis-sample code
unsigned long currentMillis = millis();
if (currentMillis - previousMillis <= interval) { //when time elapsed is LESS than interval of 30 mins
} else { //if deltaTimeElapsed is GREATER than target interval, sample and post...
previousMillis = currentMillis; //sets previous-0 to current-3600
start_test(); //sample
//now post
delay(5000);
++value;
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
String url = String("/emoncms/input/post.json?apikey=mykey&node=fortnite&json={\"t\":") + tempString + ",\"h\":" + humString + "}";
Serial.print("Requesting URL: ");
Serial.println(url);
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(500);
// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
}
}
USB Programmer Response in SM
connecting to santiapps.com
Requesting URL: /emoncms/input/post.json?apikey=mykey&node=fortnite&json={"t":-999.00,"h":-999.00}
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 27 Sep 2019 00:58:43 GMT
Content-Type: text
Transfer-Encoding: chunked
Connection: close
X-Powered-By: PHP/5.4.162
ok
0closing connection