Hi,
I uploaded an example program of esp8266 to my ESP-01 module. The program was to Scan for wifi networks, Here is the code
/*
* This sketch demonstrates how to scan WiFi networks.
* The API is almost the same as with the WiFi Shield library,
* the most obvious difference being the different file you need to include:
*/
#include "ESP8266WiFi.h"
void setup() {
Serial.begin(115200);
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
Serial.println("Setup done");
}
void loop() {
Serial.println("scan start");
// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks();
Serial.println("scan done");
if (n == 0)
Serial.println("no networks found");
else
{
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i)
{
// Print SSID and RSSI for each network found
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");
delay(10);
}
}
Serial.println("");
// Wait a bit before scanning again
delay(5000);
}
I got the output as network found but after that some address locations has started scrolling in the serial monitor and it is not stopping.How can I solve this? This is my harware setup
I suspect the problem is power supply. I take it you have the usb-serial adaptor set to 3.3V? The regulator on the adaptor won't be able to supply enough current for the esp chip. This will cause the voltage to drop too low when the esp demands high current. The esp chip then detects an error and what you are seeing on the serial monitor is the resulting memory dump.
You need a separate 3.3V supply that can provide ~300mA. When i use esp-01, i use a usb-serial adaptor that has both 3.3V and 5V outputs. I connect an ams1117 regulator's input to the usb 5V output and use the regulator's 3V3 output to power the esp.
Also i think you should have a pull-up resistor on gpio2. I'm slightly surprised you got the sketch to upload & run without it.
JoeSto:
You don't need a pull-up on GPIO2. You can use it as real GPIO.
Anyway in my project I have to use an arduino to collect data from different sensors
and send it to thingspeak.com using esp-01. That part of coding is still work in progress.
Harikishore:
I've cleared it now.The problem was the power supply.The regulator on the adaptor won't be able to supply enough current for the esp chip. This will cause the voltage to drop too low when the esp demands high current. The esp chip then detects an error and what I was seeing on the serial monitor was the resulting memory dump.
I made a separate 3.3V supply that can provide ~300mA.Now my program is working and there is no memory dump.
Thanks for your Support
Good to see you got it working all by yourself. And your explanation of the problem was also good. I couldn't have put it better myself.
PaulRB:
Sure you need the Arduino board? What sensors? How will Arduino & esp communicate?
I'm not sure about Arduino.My project is air quality monitoring and I have to use Dust sensor,CO sensor,Temperature and Humidity sensor,Which means I need atleast 6 analog input pins that collects data and send it to thingspeak.com . I have to try whether this will work with Arduino or not,What's your opinion?
Which of these sensors have you purchased already? Post links to what you have and what you plan to use.
If you can find sensors with i2c interfaces, you may be able to avoid the need for the Arduino. For example, i use htu21 (=sht21) and bme280 temp/humidity/pressure sensors connected directly to esp chips.
For sensors without i2c interface, an analog to digital pin with i2c interface may be an option.
I would seriously reconsider using a DHT11 temp-humidity sensor. There are MUCH better sensors out there like the one mentioned by PaulRB.
I have used Tiny85 chips as peripherals over I2C. Use their ADCs to measure voltage or get temp and humidity from a DHT22 and make the data available for the ESP to request, for instance.
Groundfungus is correct, dht11 is a very basic sensor, ideally suited to new Arduino users building their first basic circuits. Given the amounts you have/will spend on those other sensors, you might want to consider stepping up to something that will be less dissapointing in the longer term. Dht22 would at least be more appropriate.
However, dht22 would mean you would need an Arduino of some description to act as the interface between the esp and the sensor (this "Arduino" could be an attiny). This is because the dht11/22 use a non-standard interface that can't easily be shared with other sensors in the way that i2c devices can. The esp-01 has only two pins available, neither of which have analog capability, but can be used to interface with i2c devices. If you used one of those 2 pins for dht22, you only have one remaing, which would be of limited use.
Another approach would be to use an i2c temp/humidity sensor like htu21, plus an i2c analog-to digital chip which would allow the esp to read those dust & CO2 detectors.
groundfungus:
I have used Tiny85 chips as peripherals over I2C. Use their ADCs to measure voltage or get temp and humidity from a DHT22 and make the data available for the ESP to request, for instance.
Groundfungus, i am attempting to do the same thing but am experiencing difficulties with the i2c comms between attiny84 and Wemos/esp-12. Would appreciate any advice if you can please on this thread.