Проблема в связке ESP8266 - 01 и SD карты

Здравствуйте, уважаемые разработчики и все блинкеры!

Столкнулся с проблемой взаимодействия модуля SD карты в связке с ESP01 и Blynk.
Аппаратная часть:
Arduino UNO,
TREMA-POWER SHIELD от iARDUINO.RU
ESP8266-01, подключенная через DC-DC MP1584EN
SD модуль от Амперки.
Программная часть:
локальный blynk-сервер (0.31.0) на bananaPI
последние библиотеки blynk и клиент на android.

Локальный сервер замечательно работает, ESP-шка коннектиться и видится приложением.
SD- модуль отдельно работает (видит список файликов и читается).

Подключаю все вместе. SD-модуль инициируется (на 10 пине). LED в приложении загорается зеленым.
Все ОК до того момента когда я непосредственно хочу открыть файл оператором SD.open.
Происходит отключение ESP-шки и ее перезагрузка. В приложении значок подключения временно становится красным. Потом восстанавливается, но затем опять отключается. Как только я убираю блок чтения файла, то все ОК. Соединение есть, карта проинициализирована, коннект не падает.
Вначале думал, что все из за питания, что ESP-шка проседает после начала чтения файла. Поставил отдельное питание с понижающим модулем MP1584EN. Но проблема осталась.
Цель - вывести в виджет table список файлов с SD карты. Но до работы с table еще не доходит.
Мой скетч (как только раскомментариваю работу с файлами, все, дисконнект):


    #define BLYNK_PRINT Serial

    #include <ESP8266_Lib.h>
    #include <BlynkSimpleShieldEsp8266.h>
    #include <SPI.h>
    #include <SD.h>

    #define SDCARD_CS 10

    char auth[] = "мой ID"; // LocalServer
    char ssid[] = "gtwifip";
    char pass[] = "Globusguest";
    char server[]="192.168.43.25";


    #define EspSerial Serial
    #define ESP8266_BAUD 115200
    ESP8266 wifi(&EspSerial);

    WidgetLED led_sd(V0);

    File myFile;

    void setup()
    {
       //Set ESP8266 baud rate
      EspSerial.begin(ESP8266_BAUD);
     
        
      if (!SD.begin(SDCARD_CS)) {
          Blynk.setProperty(V0,"color","#cc0628");
          led_sd.on();
          return;
        }
        else {
          Serial.println("SD OK");
          Blynk.setProperty(V0,"color","#33ba04");
          led_sd.on();
             }


     /* myFile = SD.open("datarec.txt");
      if (myFile) {
        Serial.println("datarec.txt:");

        while (myFile.available()) {
          Serial.write(myFile.read());
        }
        // close the file:
        myFile.close();
      } else {
        Serial.println("error opening datarec.txt");
      }*/
         
      
      Blynk.begin(auth, wifi, ssid, pass,server);   
    }
      
     void loop()
    {
       Blynk.run();
    }

Couldn’t you just hook up the SD card to a sub $3 WeMos clone and cut out the Arduino and nightmare ESP-01?

1 Like

Costas,
ESP I use as a WIFI shield for ARDUINO + POWER SHIELD, to which later servos will be connected. In the future, I plan to record the movements of the servo motors on the memory card.

На левой картинке лог когда данные из файла всётаки считываются, но потом происходи диссконект. На правой все ОК, но я закоментарил работу с SD картой.

The least I would consider would be to replace the ESP-01 with a real ESP.

Shouldn’t make any difference as a WiFi adapter… just a bit harder to initially setup.

@Maxendra It has been awhile since i used SD cards… but I seem to recall that they often required specific pins, and that sometimes setting those pins disabled the PWM abilities of other pins, basically a hidden trap for new players.

I have quite a standard connection SD card attached to SPI bus as follows: MOSI - pin 11, MISO - pin 12, CLK - pin 13.
And at the same time everything works. The question is why the blynk falls off? Can I see the local server logs? In the …logs/blynk.log - nothing, no errors.

I already ordered esp-12, esp-32 but for my project it’s like shooting a cannon on sparrows.

Most while() loops are blocking until they get what they want… so while waiting for that to happen, Blynk heartbeat could be missed and thus disconnecting occurs.

The problem of disconnection begins when I even just leave

myFile = SD.open("datarec.txt");
myFile.close();

This is what most of all surprises me…

No, infinitely more difficult to set up and keep running. '01’s kick out lot’s of interference unless you add all the extra components seen on a decent board.

Wise move as they cost the same as the horrible '01’s.

I wasn’t aware of any issues like that?.. only the benefit of adding smoothing capacitors… but that is just for power and avoiding brownouts.

I have two ESP-01s, an ESP32 and a Wemos D1 Mini, all running withing the same 1/2 square meter of my workspace, and am getting good connections and RSSI ratings to/from each one. Router is 9 meters away and blocked by some internal walls… granted they are wooden motor-home walls :stuck_out_tongue:

@Gunner has rebooting an ESP-01 never affected your other WiFi devices including your phones?

Not that I am aware of…

I spend most of my time in a very small space and most of my stuff runs 24/7 (but yes, lots of rebooting as I try new code etc.).

I am also surrounded by my own other WiFi devices, and all my cameras, phones, BT headsets, tablets and MCUs all work well… the only issues I run into is a tired router needing the occasional reboot or the RV parks stupid multi channel WiFi system stepping on my channel… but so far that has been only a one time thing.

Glad it’s not just my WiFi that’s affected by the nasty '01’s https://www.reddit.com/r/esp8266/comments/4bosdx/esp8266_interfering_with_laptop_wifi/

Not saying it can’t happen… many different manufactures out there… just saying that I thankfully don’t have any trouble with them, and that I don’t promote generalisation that they are crap. Cantankerous to hookup, yes… and I do wish many new users would stop asking how to hook them up and just read the many repeated directions out there… but otherwise they do what they are designed to do and a a very compact and fairly economical way of getting Arduinos online.

I just checked to see if they are available for less than 50 cents and no the very best price is about $1.70.
Waste of money for me when you can buy a real ESP for $2.50.

I agree… wouldn’t promote someone going out to buy them… but if they already have them, then waste not want not. I know I am appreciative of the first one I got… and will keep using it with my Mega as long as I can.

Near as i can tell, this OP isn’t having a problem whit the ESP-01 itself… so I am focusing on the code or something with the use of the SD card pins, etc… I just don’t have any standalone SD card modules to test with.

I do but I know I would waste lots of time trying to set it up with an Arduino and an ESP, especially ESP’s that are not plug and play.

We will have to agree to disagree on that. I don’t throw out my rubbish as one day they might be useful but until a real ESP costs at least $20 more than those beasts I’m not going to waste any more of my time with them :slight_smile:

1 Like

Tata Nano (approx $2000) or Rolls Royce Ghost with same fuel consumption as a Nano available for less than $3000 (regular price $250,000). Which do you buy and which one gets put in the garage never to be seen again?

Neither would survive long in truck country, where real work gets done :stuck_out_tongue:

1 Like