WiFiUdp.h no file wrong Lib D1 mini pro

Hello,
I think I’m making a total beginner’s mistake.
I’m trying to compile a D1-Mini-Pro (ESP8266) for an SD card program under platform.io.
I guess I don’t have the correct libraries.

But despite nights of searching and testing with various libraries, I can’t find the error.

Maybe any can help me with that.

Plaformio.ini

[env:d1_mini_pro]
platform = espressif8266
board = d1_mini_pro
framework = arduino
lib_deps = C:\Users\a2106\.platformio\exteren-libs\Arduino-master.zip

The Program start with

/*
  SD card datalogger

  This example shows how to log data from three analog sensors
  to an SD card using the SD library.

  The circuit:
   analog sensors on analog ins 0, 1, and 2
   SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4

  created  24 Nov 2010
  modified 9 Apr 2012
  by Tom Igoe

  This example code is in the public domain.

*/
#include <Arduino.h>
#include <SPI.h>
#include <SD.h>

const int chipSelect = 15;

void setup() {

My D1-Mini-pro have the
SCL = D5(14)
MISO = D6(12),
MOSI = D7(13),
CS = D8(15),

The Arduino-master.zip i get from there
ESP8266-Arduino-Lib’s

kind regards
Achim

All libraries in https://github.com/esp8266/Arduino/tree/master/libraries are already built into the framework and should be automatically found, no lib_deps statement needed.

Can you remove that line and show the current compilation errors?

1 Like

I can hardly believe it, I need nights and I get the answer here after half a second.
Wow, incredible.

Thanks alot.

This means that if I do something with SD cards, DNS or even with Dallast DS18B20 sensors, the libs are already included or does it throw out a clear error message when compiling, so that I realize, aha, I have to reload this library separately ?

I want to write a data logger for an SD card
and have the D1 Mini Pro

Does it then also recognize the other pins? Miso, Mosi, scl and CS, or do I have to change that in the source code?

Edit:
Compiling now ok but the terminal told me that

Assuming the SD chip select pin is: 15
Edit SD_CS_PIN to change the SD chip select pin.

type any character to start

SD initialization failed.
Do not reformat the card!
Is the card correctly inserted?
Is there a wiring/soldering problem?
Is SD_CS_PIN set to the correct value?
Does another SPI device need to be disabled?
SD errorCode: SD_CARD_ERROR_ACMD41 = 0x17
SD errorData = 0xff

type any character to start
``
I read the Pin-Out from that Board and there is the CS-PIN 15
`
  • the SD library is already in the framework and must not specially included
  • same for the DNSServer library or the WiFi.hostByName(const char* aHostname, IPAddress& aResult) function
  • A DS18B20 library is not included with the Arduino-ESP8266 core, you search the PIO Registry for one and include e.g. lib_deps = milesburton/DallasTemperature@^3.11.0 to get the DallasTemperature.h library.

If you reference a header file of a library that is not yet included in the build, it will throw a “header XYZ.h not found” error. PlatformIO also recognizes this and additionally prints output on what you should do.

So the principle should be: You only need to add libraries that are not in the Arduino framework you’re using, and you’ll be getting an error about them if you don’t include them.

The CS pin is just a regular GPIO pin, you can use any free one for that. The MISO, MOSI and SCLK pins must come from pins that are connected to a SPI peripheral. The ESP8266 basically only has one SPI bus.that you can use, the other is reserved for the SPI FLash (where code is loaded from). See here.

my configuration looks like this.
I connected the ESP8266 and pins 14,12,13 (SLC, Miso, mosi) to an MH SD card.
Pin 15 with the CS of the MH-SD card,
These pins (14, 12 and 13) are probably blocked if, for example, a program wants to load onto the ESP8266?
Sorry, that’s a bit complicated to understand… I read the website but I’m not sure if I understood everything

The wireup should be correct per https://microcontrollerslab.com/micro-sd-card-module-esp8266-nodemcu/.

okay, now I’m getting closer to the problem… there is an SPI and an HSPI interface. Ok, I’ll read up on it. Thank you very much… I’ll try to get it done.

Sorry Max, i need you.
I have to get this data logger ready by tomorrow morning because we can install it on a roof tomorrow.

I’m really under pressure and I can’t buy one any time soon.

I understand this to mean that I cannot use SD card and USB upload of programs at the same time

OK.
Now I thought I would do it this way

  1. I install Wifi so that I can flash the ESP via Wifi
  2. when connected to Wifi, I activate the SD card library so that it can use the SPI

The problem is just:
a) I upload the program via USB to get a wifi connection
) somehow platformio cannot find the D1-Mini
I’m completely on the line and can’t see the whale for the trees

That’s the code

#include <Arduino.h>
#include <SPI.h>
//#include <SD.h>

// WIFI-Connect
#include <ESP8266WiFi.h>

const int chipSelect = 5;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);

  Serial.begin(115200); //Baudrate
  Serial.println("ESP starts");
  WiFi.begin("ASUS","passxxx");
  Serial.print("Connecting...");
  while(WiFi.status()!=WL_CONNECTED){ //Loop which makes a point every 500ms until the connection process has finished
    delay(500);
    Serial.print(".");
  }
  Serial.println();
  Serial.print("Connected! IP-Address: ");
  Serial.println(WiFi.localIP()); //Displaying the IP Address

serial monitor

--- Terminal on COM1 | 9600 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp8266_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H

COM1 sounds like a hardware serial port of the motherboard. Connected dev boards usually have a higher COM number. Are you sure you see a new COM adapter in the Windows device manager when you plug in the D1-Mini? If not, you likely just don’t have the USB-to-Serial drivers installed that the D1-Mini uses, aka the CH340. Check out How to Install CH340 Drivers - SparkFun Learn or the original chinese manufacturer website.

Also this isn’t just “magically” activated. You have to include the ArduinoOTA library and add some code in setup and some code in loop for this to be flashable. Check out the official example for it, plus how to configure PlatformIO for OTA Uploading once the ESP8266 is in the WiFi.

the thing is

I can now upload a program via Wifi… that works now
But the moment I open the serial monitor nothing works.

--- Terminal on COM1 | 9600 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp8266_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+

he isn’t now connected to any Com port from PC… the power-cable from the D1 (USB) is connected to a 5V Power

edit.

ah ok i try it

Well if the device is in the WiFi now and no USB cable is connected between the D1 mini and the computer, how is the serial output supposed to reach the computer? Right now the Serial prints are physically output via UART to the USB-to-UART chip on the ESP8266, to which nothing else is connected. It screams into the void.

You have to add extra code to make the serial prints accessible via a network connection. You need “debugging over the air”. You could use the https://github.com/yasheena/telnetspy library for that, e.g. by following the basic example. BasicOTA_and_TelnetSpy.ino

Once a telnet server is opened on the ESP8266, you can tell PlatformIO’s serial monitor to connect to it using a monitor_port directive in the platformio.ini for a socket with address + port (23).

Yes, I understand that too and it’s only logical that it doesn’t work.
But I don’t understand that he can upload a program via wifi and then when I open the terminal… he uses the Com1 port even though he probably established the connection via wifi 10 seconds before

PlatformIO is not programmed to do that. “Serial Monitor” opens the serial monitor in accordance to what’s configured by default or via monitor_port: And the default is, open the serial port on the local machine. Everything else is “configure it” territory.

I have never created a connection to an ESP via Telnet…
Up to now I have always uploaded the entire program including the WiFi connection to the ESP… then disconnected it and I immediately had the ESP online…

But now that I’ve messed up with the SD card, nothing works anymore and I’m totally stuck in the woods

edit:
i check now my past ESP-Codes… and this ESP’s run in my network… and i can do all with there… but i not find any WIFI User and password there…
i don’t know why this works in the past time…

Crazy…
this is happen if not have any time to clear…

edit2:

is also not use any <ESP8266WiFi.h> realy i not use it there but al runs good… i donT know why

edit3:
that is sample what i includ there … also runs in my wife
without any wiwfi-configure

#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_TMP117.h>
#include "Adafruit_SHT4x.h"
#include "Adafruit_BME680.h"
#include <Adafruit_Sensor.h>


sorry Max for my crazy time … but i use the ESP last time from 1 year ago and there runs normyla… now i forget all… but i hope i reconfigure now right

Okay,

I have now reinstalled my COM port according to the instructions above so that I can get CH340 support.

I received and installed the CH341SER.

Now I see in the device manager (I had already seen it before, yes I did uninstall beforehand)
Silicon Labs CP210x USB to UART Bridge (Com4)

I don’t know why it doesn’t say CH350.

I can now upload my program to the D1-Mini-Pro

Dependency Graph
|-- ESP8266WiFi @ 1.0
Building in release mode
Retrieving maximum program size .pio\build\d1_mini_pro\firmware.elf
Checking size .pio\build\d1_mini_pro\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  34.4% (used 28188 bytes from 81920 bytes)
Flash: [===       ]  25.7% (used 268151 bytes from 1044464 bytes)
Configuring upload protocol...
AVAILABLE: espota, esptool
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: COM4
Uploading .pio\build\d1_mini_pro\firmware.bin
esptool.py v3.0
Serial port COM4
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: b4:e6:2d:72:3f:18
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Compressed 272304 bytes to 200292...
Writing at 0x00000000... (7 %)
Writing at 0x00004000... (15 %)
Writing at 0x00008000... (23 %)
Writing at 0x0000c000... (30 %)
Writing at 0x00010000... (38 %)
Writing at 0x00014000... (46 %)
Writing at 0x00018000... (53 %)
Writing at 0x0001c000... (61 %)
Writing at 0x00020000... (69 %)
Writing at 0x00024000... (76 %)
Writing at 0x00028000... (84 %)
Writing at 0x0002c000... (92 %)
Writing at 0x00030000... (100 %)
Wrote 272304 bytes (200292 compressed) at 0x00000000 in 17.8 seconds (effective 122.5 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
================================ [SUCCESS] Took 22.40 seco

However, after calling the terminal monitor I get this.

===>


--- Terminal on COM4 | 9600 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp8266_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
����/�

<===

something is still not right

I used different codes including the one recommended by Max
#include <ArduinoOTA.h>
including the setup () and loop() information. See code.
Everything didn’t help.

Could it be that the board I selected under platformio?


[env:d1_mini_pro]
platform = espressif8266
board = d1_mini_pro
framework = arduino

wrong is

The board is a D1-MiniPro with an external antenna

You need to specify the baud rate for PlatformIO serial monitor.

monitor_speed = <baudrate here>

You must set the same baudrate as you use in Serial.begin().

void setup() {
  Serial.begin(115200);
  // etc...    
}
[env:d1_mini_pro]
platform = espressif8266
board = d1_mini_pro
framework = arduino
monitor_speed = 115200

oh ok,
i try it to change the Baut rate from serial Monitor
to

Serial.begin(9600);

but he show me same same hex… ok i try now
the

monitor_speed = <9600>

what i have there to use… same same what stay in serial.begin(9600)
?

The ESP8266 will output a boot log at a “strange” baudrate of 74880.
I guess, that’s what you see.

Does your sketch print to serial?

Yes, at least under platformio I selected the serial monitor as the output and what I copied here comes from this monitor

I’ll try this baud rate right away

 Terminal on COM4 | 9600 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp8266_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
����/�