how to wire an ESP-07 w/ FT232RL (?)
Posted: Fri Jun 12, 2015 6:04 am
This is what I have rigged up, as per the instructions here:
To summarize as best I can:
All resistors are 10kΩ. The slide switch changes between DTR and a pullup to GPIO0. Uploading works fine with the switch set to DTR. But I have a handful of questions:
Finally, below is the code I uploaded ("Zoltar.h" contains my SSID and password). Read a DHT22, connect to wifi, publish some crap to an MQTT broker. Again, I see maybe "Connecting to WiFi" and a few dots, but then everything grinds to a halt. Anything weird here?
thanks.
Chris
To summarize as best I can:
- 3.3V (FT232RL) to VCC (ESP-07)
- Pullup to CH_PD
- GND to GND
- Pulldown to GPIO15
- TX to RX
- RX to TX
- RTS to REST w/ pullup
- DTR to GPIO0
- .01μF between 3.3V and GND
All resistors are 10kΩ. The slide switch changes between DTR and a pullup to GPIO0. Uploading works fine with the switch set to DTR. But I have a handful of questions:
- Is there any easier way to do this?
- Why 10kΩ resistors? Would 4.7kΩ suffice?
- After uploading, do I have to reset manually?
- I attempted wiring DTR to GPIO0 w/ a pullup, as per the diagram on GitHub. This didn't seem to do what I thought it would, which was boot the program I uploaded. I think perhaps the title of the diagram is misleading, because I can only upload if wired this way. Hence, the switch. Is it even possible to wire this thing so it will run code and enable uploading at once?
- I see very few of my "Serial.println()" calls when viewing the port, either in the Arduino IDE or CoolTerm. Is this a bug, or have I wired something incorrectly?
- From what I understand, the module will reset when REST falls from HIGH to LOW. Can this be triggered via the FT232RL? I could wire a momentary switch, but right now I'm just yanking the wire out to reset.
- Does a reset actually work after uploading my firmware, or do I need to power cycle the thing?
- What CPU frequency and flash size should I be using for an ESP-07?
Finally, below is the code I uploaded ("Zoltar.h" contains my SSID and password). Read a DHT22, connect to wifi, publish some crap to an MQTT broker. Again, I see maybe "Connecting to WiFi" and a few dots, but then everything grinds to a halt. Anything weird here?
Code: Select all
#include <Zoltar.h>
#include <ESP8266WiFi.h> //ESP library from http://github.com/esp8266/Arduino
#include <MQTT.h>
#include <PubSubClient.h> // MQTT library from http://github.com/Imroy/pubsubclient
#include <DHT.h> // DHT library from http://github.com/adafruit/DHT-sensor-library
#define DHTPIN 14 // what pin we're connected to
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE, 15);
const char *ssid = BRIDE_OF_ZOLTAR_SSID; // cannot be longer than 32 characters!
const char *pass = BRIDE_OF_ZOLTAR_PASSWORD; //
long previousMillis = 0; // Timer loop from http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
long interval = 5000; //
IPAddress server(10, 0, 0, 5); // Update these with values suitable for your network.
PubSubClient client(server);
void connectToAP() {
Serial.println("Connecting to WiFi");
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
Serial.print('.');
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: " + WiFi.localIP());
}
void connectToBroker() {
Serial.println("Connecting to MQTT server");
while (!client.connect("thermostat")) {
Serial.print('.');
delay(500);
}
Serial.println("");
Serial.println("MQTT connected");
};
void setup() {
// Setup console
Serial.begin(115200, SERIAL_8N1);
connectToAP();
connectToBroker();
dht.begin();
}
void loop() {
client.loop();
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval) {
if (WiFi.status() != WL_CONNECTED) {
Serial.println("Lost WiFi connection");
connectToAP();
}
if (!client.connected()) {
Serial.println("Lost MQTT connection");
connectToBroker();
}
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius
//float t = dht.readTemperature();
// Read temperature as Fahrenheit
float f = dht.readTemperature(true);
float c = dht.readTemperature();
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
previousMillis = currentMillis;
return;
}
Serial.print("DHT sensor read F ");
Serial.println(f);
Serial.print("DHT sensor read H ");
Serial.println(h);
client.publish("digs/home/temperature", "{\"fahrenheit\": " + String(f) + ", \"celsius\": " + String(c) + "}");
client.publish("digs/home/humidity", "{\"humidity\": " + String(h) + "}");
previousMillis = currentMillis;
}
}
thanks.
Chris