ESP8266 makes me crazy.

I'm doing my first steps with Arduino + ESP8266, but I'm getting a little desperate... :frowning:
(I do have quite some experience with arduino and LCD's, serial communication, and the like)
I've read maaaaaaaany tutorials, saw maaaaaaaaaaaany video's, but all seem to say something different about using the 8266. I used different libraries, different arduino's (nano, uno, mega) but results stay out.
I tried to use "BLYNK" because it seemed to be much used. but again : no results.
For the moment I'm using an UNO and a a small ESP-01. The wiring is correct, I even used a 5-3.3V convertor board. The necessary supply 3.3V I get from the UNO. As long I don't use the wifi intensively , I guess that the UNO can supply enough current. (I never measured less than 3.27V) I read about "flashing" the 8266, but also there I find lots of contradictions.
Using BLYNK, I mostly I got the message "[1619] ESP is not responding"
The best thing I saw on the serial monitor (after reversing RX and TX) was
[14635] Failed to enable MUX [15646] Failed to set STA mode. So there should have been some kinda communication and it proofs that my wiring is OK.
I googled these errors, and found again lots of "solutions"... (that I tried but didn't work)
And now I only get the message [1619] ESP is not responding.

I there someone who can tell me where I can find a GOOD tutorial ? Or show me a working example ?
I checked websites/forums like Blynk, Everything ESP8266, Arduino, github etc etc... but I can't see the trees through the wood anymore.

My main goal is to have a NANO that collects a few data (prox 10 bytes) and send these (over wifi) to my phone and/or PC...
ANY info is more than welcome and will be highly appreciated ...

I used 2 brand new ESP-01 boards ... same results.

thanks in advance !

"ANY info is more than welcome and will be highly appreciated ..."

Get a WeMOS ESP8266 development board, usually about $4 from China or about $7 in the US. Directly mating an ESP chip to an arduino is a yesterday thing.

zoomkat:
“ANY info is more than welcome and will be highly appreciated …”

Get a WeMOS ESP8266 development board, usually about $4 from China or about $7 in the US. Directly mating an ESP chip to an arduino is a yesterday thing.

Agree with this.

However, if you insist on continuing with Uno +ESP-01, the first important decision you have to make is whether to leave the ESP-01’s default AT firmware or install the Arduino ESP8266 Core over it. Uploading firmware to ESP-01 is rather a pain in the neck in my opinion.

A reliable 3.3V power supply for the ESP-01 is important. I was getting unreliable results without it.

Get a WeMOS ESP8266 development board, usually about $4 from China or about $7 in the US. Directly mating an ESP chip to an arduino is a yesterday thing.

confirm.

Get an development board like Wemos or NodeMcu and get rid of the Uno.
Programm the ESP on the Wemos or NodeMCU directly with the Arduino IDE.
If you need more ports - use I2C port expanders. If you don't have portexpanders by hand ... use the UNO as I2C slave connected to the Wemos/NodeMCU.

First of all : Thanks to all of you for your fast replies.

Using a ESP01 on its own seems to me kinda impossible.
Here is a more detailed explanation of what I want to achieve :
I have data coming from a solar panel regulator through a 3.3V TTL serial connection. This data uses about 20 bytes (mixed bytes, integers and floats). I want to add these data to the readings of a BME280 sensor (temp+hum+ pressure). My experiments with the solar panel and the BME280 communications are working just fine. The position of this panel + BME280 is quite remote (buth within wifi range, but out of Bluetooth range) so a wifi connection is the best idea.
I’m quite sure that the ESP01 cannot take care of all these tasks (only 2 GIO’s and one serial), so I need some CPU power to combine and do a few calculations (e.g. go from floats and integers to bytes. I’m happy with e.g. 20°C instead of 20.12°C )
Because I’ll be using solar power, I want to keep the power consumption as small as possible. In the final project I’ll try to use a “pro micro 3.3V” arduino and probably can set it to “sleep” for 95% of the time or even just wake it up when I’m asking.
So in the mean time I try to have an arduino + 5 <-> 3.3V converter (I use an UNO because most of the video’s and tutorials are based on this UNO) to communicate with this ESP01.
When this communication works, then I can start to combine the sketches for solar and BME) one by one to my final sketch.
I didn’t try (yet ) to feed the ESP01 with a separate 3.3V PSU. but I’ll do that today or tomorrow and post the results here.

Meanwhile : remarks, questions are still highly appreciated ! :slight_smile:

long story short:

ESP12E has enough GPIO's for your purpose.

Long:

On the Wemos or NodeMCU you have the ESP12E, not the ESP01 - which by the way you didn't mention in your starting post. The ESP has a lot more "CPU power" than the UNO so anything you can calculate on the UNO will be very possible on the ESP also - And a lot more!

Regarding: "Low power Consumption" ... even the ESP is equipped with Deep Sleep capabilities. The deepsleep is better than the 8sec deepsleep from the UNO/Micro.
The power hungry part of the ESP is when using WIFI during WIFI activities. This will not change if you are using ESP with AT commands. So again, get one of this maker friendly Wemos/NodeMCU, and get your sketch done.

When everything is working, you can downsize from Wemos/NodeMCU to a plain ESP8266 - 12E module. If you really feel that your device is consuming to much power.

But trying to use the ESP via AT commands from an UNO is just a waste of time, imho.

noiasca:
long story short:
But trying to use the ESP via AT commands from an UNO is just a waste of time, imho.

I looked into those WeMOS boards a little closer, and I'm getting convinced that the solution for my project lies there since I couldn't find ANY clear explanation on how to use the combination Arduino - ESP... Think I'm gonna order one or two and come back here (with probably more questions :slight_smile: )

Meanwhile 1K thanks to all of you !

Would this be a good board ?

Sorry this post doesn't seem to allow me to post "links" ...

that's an ESP32. This is one step higher than the ESP8266. Even it has more AD inputs, bluetooth, more cores, I recommend to start with an ESP8266 board.

I guess I have mentioned Wemos D1 or NodeMCU already...

I prefer the smal NodeMcu with CP chip, but that's just personal taste,...

https://www.banggood.com/search/wemos-d1-mini.html

Thanks for the info, noiasca !

The most important reasons why I chose this ESP32 is that

  1. I can order it from the UK (ships FREE in 2 to 5 days) If I add the shipping fee from China to the price of their D1, it costs almost as much as the "big brother" ESP32. :slight_smile:
  2. For my final project, I'll probably use your suggestion and keep the 32 for further experiments...

I'm certainly not gonna say farewell to my "beloved" Arduino's :), but for this project it seems to me the right solution.

10K thanks noiasca !!

and now : let’s play the waiting game …

thanks again !

Another point of using a ESP32 over a ESP8266 is when using WiFi, the WiFi thingies will be loaded to Core0, on a ESP32, and the program you write will be loaded to Core1. Meaning that your program will have its own 250Mhz processor to run the code. With a 8266 the operations of WiFi and running your program are shared by the same CPU.

I have an ESP32 sitting in the backyard running on Solar with battery backup. The battery is a 188650 26000mAh. For a test I disconnected the solar cell and let the project run for 27 hours before reconnecting the solar cell. I use deep sleep and wake once every 6 minutes.

I use a 20 watt solar cell that is partially shaded during the day. Typically the battery is recharged by 11AM and charging starts about 7AM.

I tried a 10 watt solar cell., it was unable to fully recharge the battery during the day, with WiFi on.

Whiles waiting, you might look at freeRTOS, which is the built in OS of the ESP32.

Here is a bit of code using freeRTOS on a ESP32

#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <PubSubClient.h>
#include "certs.h"
#include "sdkconfig.h"
#include "esp_system.h" //This inclusion configures the peripherals in the ESP system.
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/timers.h"
#include "freertos/event_groups.h"
#include "esp_sleep.h"
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"
////
EventGroupHandle_t eg;
SemaphoreHandle_t sema_ReadBME680;
////
WiFiClientSecure secureClient = WiFiClientSecure();
WiFiClient wifiClient;
PubSubClient client(mqtt_server, 1883, wifiClient); // 1883 is the listener port for the Broker
////
Adafruit_BME680 bme( GPIO_NUM_15); // hardware SPI
///
void setup()
{
  eg = xEventGroupCreate();
  SPI.begin();
  sema_ReadBME680 = xSemaphoreCreateBinary();
  xTaskCreatePinnedToCore( fDoBME, "fDoBME", 20000, NULL, 3, NULL, 1 ); // assigned to core
  //start this task last
  xTaskCreatePinnedToCore( fDoTheThing, "fDoTheThing", 40000, NULL, 5, NULL, 1 ); // assigned to core
} // end setup()
////
void mqttCallBack( char* topic, byte* payload, unsigned int length )
{
  log_i( "received topic: %s", topic);
  //log_i( "incomming... topic %s payload %s", Topic, payload );
}
////
void connectToMQTT() {
  if ( client.connect(clientID, mqtt_username, mqtt_password) )
  {
    log_i("Connected to MQTT Broker!");
  } else {
    log_i("Connection to MQTT Broker failed...");
  }
  log_i("MQTT Connected");
}
//
void connectToWiFi()
{
  log_i( "Connecting to WiFi " );
  WiFi.begin( SSID, PWD );
  vTaskDelay( 750);
  while ( WiFi.status() != WL_CONNECTED )
  {
    log_i(".");
    vTaskDelay( 800 );
  }
  log_i( "WiFi Connected - ");
}
////
void fDoTheThing( void * pvParameters )
{
  xEventGroupWaitBits (eg, evtSetupBME_Complete, pdTRUE, pdTRUE, portMAX_DELAY ); //
  connectToWiFi();
  connectToMQTT();
  while (1)
  {
    xEventGroupSetBits( eg, evtDoBME ); // trigger tasks
    xSemaphoreTake( sema_ReadBME680, portMAX_DELAY ); // wait for task to be done
    log_i( "entering deep sleep" );
    client.disconnect();
    WiFi.disconnect(true);
    WiFi.mode(WIFI_OFF);
    esp_sleep_enable_timer_wakeup( (60000000 * 6) ); // set timer to wake up every 60000000uS (1 minute) * 6
    // esp_sleep_enable_timer_wakeup( (60000000) ); // set timer to wake up every 60000000uS (1 minute)
    esp_deep_sleep_start();
    //
  } //while(1)
  vTaskDelete ( NULL );
} // void fDoTheThing( void * pvParameters )
////
void fDoBME ( void *pvParameters )
{
  while (!bme.begin())
  {
    log_i("Could not find BME680 sensor!");
    vTaskDelay( 10 );
  }
  bme.setTemperatureOversampling(BME680_OS_8X);
  bme.setHumidityOversampling(BME680_OS_2X);
  bme.setPressureOversampling(BME680_OS_4X);
  bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
  bme.setGasHeater(320, 150); // 320*C for 150 ms
  // float SEALEVELPRESSURE_HPA = 1013.25;
  float Temperature = 0.0f;
  float Pressure = 0.0f;
  float Humidity = 0.0f;
  float gas_resistance = 0.0f; //in K ohms
  String sTemprature = "/Temperature";
  String sPressure = "/Pressure";
  String sGas_Resistance = "/GasResistance";
  xEventGroupSetBits( eg, evtSetupBME_Complete ); // trigger tasks
  for ( ;; )
  {
    xEventGroupWaitBits (eg, evtDoBME, pdTRUE, pdTRUE, portMAX_DELAY ); //
    Temperature = (bme.readTemperature() * 1.8f) + 32; // (Celsius x 1.8) + 32
    Pressure = bme.readPressure() / 133.3223684; //converts to mmHg
    Humidity = bme.readHumidity();
    gas_resistance = bme.gas_resistance / 1000.0f;
    log_i( "Temperature %f C, Pressure %f hPa, Humidity %f, Gas Resistance %f KOhms", Temperature, Pressure, Humidity, gas_resistance );
    client.publish( "Home/oTemperature" , String(Temperature).c_str() );
    vTaskDelay( 12 ); // gives the Raspberry Pi 4 time to receive the message and process
    client.publish( "Home/oHumidity" , String(Humidity).c_str() );
    vTaskDelay( 12 ); // no delay and RPi is still processing previous message
    client.publish( "Home/oGas_Resistance" , String(gas_resistance).c_str() );
    vTaskDelay( 12 );
    xSemaphoreGive ( sema_ReadBME680 );
  } // for loop
  vTaskDelete ( NULL );
} // void fDoBMP ( void *pvParameters )

Idahowalker:
Here is a bit of code using freeRTOS on a ESP32

wow… impressive !
But for now, I think I’m gonna stay with the more easy arduino sketches. I’m not a “skilled/educated” programmer …
There should be an easy beginners sketch/setup, right?
My final goal is : gathering about 20 bytes from RS232, add 2 or three local analog inputs and outputs of e.g. BME280. Gather up all these bytes and send 'em over wifi to e.g. my cellphone when I ask for it (from my cell.) I guess it can’t be THAT complicated ?
I’ve done communication with 2 x Serial. (2 x sending data up and down) ->OK
I’ve done communication with BME280 etc ->OK
I’ve done analog readings ->OK
But now : send these data over Wifi … ???
SHouldn’t be thàt difficult ? :slight_smile:

but again : thanks for your time and info !
and let me first wait till I get the ESP32 and do some experiments with that in an easier language that I know (more or less…) I might “steal” some lines from you !
:slight_smile:

Meanwhile I received the ESP32 module and did a few (easy/basic) experiments. I managed to get an BME280 to work, together with a 096 OLED display. Also, I get time and date from the internet over WiFi I can gather the info from my solar panel through 3.3V serial, and get all this info on the (tiny) 096 OLED. (Very glad now that the ESP 32 works with 3.3V, cause I don’t need a level converter → saves space on my pcb !)
I’m working now to

  • get make a PWM signal and a temperature sensor (I’ll probably just use an NTC) to monitor and regulate the inside temperature of the box with a small ventilator).
  • an automatic start of a charger in case the sun isn’t available to charge my batteries (and power a few “consumers”)
  • an automatic start for a few extra consumers when there’s still enough sun after my batteries are fully charged.
    When those things all work (and put on a PCB!), then the BIG challenge will be to get all the data sent over Wifi …
    Day after day I’m getting more excited (partly :slight_smile: ) because of the help I got here…
    So again : thanks for all who are interested in my “case” and gave me good and useful advice.
    Maybe/probably/most likely I’ll be back here with more questions about the WiFi connection.
    BUT … if anyone is really interested in this project, I’ll be more than happy to share what I’ve achieved till now.
    Cheers !