Hi,
I've a "strange" problem at least for me, a newbie).
I bought a so called "triple base" shield that allows for connecting several shields to a Wemos D1 Mini ( I'm using a clone based on ESP8266).
My actual configuration works with a STH30 shield, a DS1307 shield and an OLED 0.66" Oled screen (as you can see in the picture enclosed)
With this configuration I'm able to display at fixed intervals time, temp and humid, while in the other time periods the ESP goes to deep sleep (obtained connecting D0 and RST, the green wire in the picture).
But if I add to this configuration a SDcard shield the code cannot be any longer uploaded.
In fact here is the usual display Connecting..............._........________ and at the end the message A fatal esptool.py error occurred : Failed to connect to ESP8288: Timed out waiting for packet header.
I tried to make some research on Google and I've found some info on this topic but not related to this specific situation. I've also tried to connect D3 and GND as suggested in some discussion ( the yellow wire that is disconnected in the picture) but to no avail.
So at the present I'm completely stuck and I'd be very grateful if someone could help me to solve this problem.
By the way the same code works fine if I assemble on a perfboard an ESP8266, a DS2321, a SHT3x and an OLED screen and the SD card shield works if it's connected alone
Hi,
just an update now even the SD card shield alone doesn't wotk ( and I've tried two of them) with the message
Connecting......................................_____
A fatal esptool.py error occurred: Failed to connect to ESP8266: Timed out waiting for packet header.
I used an example code for the SD card and ESP8266 and I tried both D8 and D4 as CS.
Sounds like the ESP is not going into flash mode. This should happen automatically when you click upload. Perhaps something is preventing either GPIO0 (D3) or RST pins from being pulled low?
Hi,thx for your advice.
Now if I connect a SDcard module ( not the shield SDcard) to ESP8266 by choosing D1 or D2 as CS it works properly.
But I'm perplexed for three reasons :
in the example sketch it is written
/*
* Micro SD Shield - Read/Write
*
* This example shows how to read and write data to and from an SD card file
*
* The WeMos Micro SD Shield uses:
* D5, D6, D7, D8, 3V3 and G
*
* The shield uses SPI bus pins:
* D5 = CLK
* D6 = MISO
* D7 = MOSI
* D8 = CS
*
* The SD card library uses 8.3 format filenames and is case-insensitive.
* eg. IMAGE.JPG is the same as image.jpg
*
* created Nov 2010 by David A. Mellis
* modified 9 Apr 2012 by Tom Igoe
*
* This example code is in the public domain.
* https://github.com/esp8266/Arduino/blob/master/libraries/SD/examples/ReadWrite/ReadWrite.ino
*/
#include <SPI.h>
#include <SD.h>
// change this to match your SD shield or module;
//WeMos Micro SD Shield V1.0.0: D8
// LOLIN Micro SD Shield V1.2.0: D4 (Default)
const int chipSelect = D8;
File myFile;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.println("Writing to test.txt...");
Serial.println("Just checking if it works or not");
myFile.println("just checking if this works or not");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
/*
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
} */
}
void loop()
{
// nothing happens after setup
}
how can I use the SDcard shield that seems to have different (and not working ) connections ? they seem to be D5 D6 D7 D8
how can I use I2C pins for my SHT3X and Oled display if one of the two pins is used for SPI ?
May I use as an alternative pin for CS the A0 ? or which other pin ?
Thanks again for your help
Hi Paul,
thx for your quick answer but as I posted it seems that the problem is in using D8 pin for CS.
If I use D1 or D2 as suggested by Juraj an SD card module works but I'm still unable to use the shield SD card module that sems to have different connections, D5 D6 D7 and D8.
Moreover I don't know how to use my sensor and my Oled connected through I2C if D1 or D2 are used for SPI.
How can I solve this problem ? Where an I making a mistake ?
Thanks
On ESP8266, you can choose any 2 pins for i2c. Problem with shields is that they have fixed wiring. This is why I never use shields, either the Uno-style or the D1-mini-style.
No, A0 is an analog input only, not an output.
Most others could be used in theory, but, as you are finding out, is not so easy in practice.
Hi Paul,
sorry for bothering you again but as you have understood I am a newbie and maybe my questions are silly... apologize for this
However,
if I wish to use a Wemos D1 Mini ESP8266 with both I2C and SPI which pins have I to use ? or does this version not allow for a combined use of SPI and I2C ? ( I don't think so)
The strange fact is that when I assembled on a perfboard a configuration with ESP8266 in Wemos D1 Mini version with two sensors (BME280 and SHT3x), one 1306SSD Oled , a DS2321 RTC clock and a MH-SD card module with CS = D8 everything worked fine.
I do not understand why the "same configuration" seems not woking with shields (but maybe it's not the same)
However, I learnt the lesson and I'll follow your suggestion (no more shields).
SPI pins are (and must be, if you want to use hardware SPI) D7, D6, D5. The image above also shows D8 as CS, but since you are using the ESP as an SPI Controller (not an SPI Pheripheral) that's irrelavent - you can choose any pin for that.
I²C is (by default) D1, D2, but since there is no hardware i²c on the ESP8266, it's software i²c only and so it can be any pair of pins you like. Unless, of course, you are using a shield which doesn't let you choose.
There is no problem that I am aware of about using both SPI and I²C In the same circuit.
The problem here is that the "you can choose any pin you like" isn't really true. With ESP8266, you have to watch out for those boot-mode pins. To get your sketch to run, those pins have to be at certain HIGH/LOW levels at the moment of boot.
Personally, I would not use an RTC with ESP8266. Assuming it can connect to the internet over WiFi (and I would generally not use ESP8266 where it can't do that) you can use the software RTC that comes as part of the ESP8266 Core.
I also would not use an SD card with ESP8266 for similar reasons. Any data you want to store can be transmitted over WiFi to a server or IoT data service, or written to the relatively copious amount of flash memory that D1 mini has (4MB in most cases, but 16MB for the Pro).
Hi Paul
thanks really for your exhaustive answer and for the time you spent to help a rookie as I am.
From your post, I've got the feeling that ESP 8266 as I thought of using it is not a good idea.
I knew the ESP8266 pinout but when you try to use it in practice you find some unexpected problems ( as the problem with D8 shows).
So I'm going to rethink my project - may be with an ESP32 that I've already used without problems - and I'll let you know if the project runs.
Really a big thanks for your help and your time: I appreciate it.
Best
Bruno
PS Just a last question if I use D1 or D2 as CS which pins c an I use for SDA and SCL ? Are RX and TX a possible choice ? if not which else ?
Hi,
because I'd like to arrange a system that is supposed to work bothwith wifi available or not.
Since I'm a newbie it's really too difficult to learn how different MCU work and, after haveing started with Arduino Uno and Nano, I migrated to ESP because they are easier to use with deepsleep.
The best thing about the ESP32 is its onboard Bluetooth, none of the HC-0x to-do.
Howbeit, there's often more to "porting over" Arduino sketches than Copy & Paste.
Hi
you're perfectly right but at almost 73 years of age and having discovered this world just one year ago after a life spent as an ear and skull base surgeon you can understand also copy and paste... and for the present stll no Bluetooth
it says that 'boot fails, if pulled HIGH'.
It seems that D0=GPIO16=pin4 is the only suitable and even that is told to go high in the boot.
It seems that the designer of this D1 mini has been HIGH himself. The same goes with ESP8266-01. Of eight pins only two can be used for I/O
I cat the D8=GPIO15=whatever line and joined it to D0=GPIO16=pin4. Now I get very interesting error messages but no function.
BUT: now I do not have to remove the SD card every time I compile & upload a program.
ESP8266 is a rather general purpose MCU having so many pins.
ESP8266-01 is more like a WIFI module, but still II have built many rather complicated devices using it. Mostly home IoT, I admit, but still.
I was expecting this WEMOS D1 mini to be more usefull, but those destrictions using the pins are ridiculous.
Still. I have under work a rather complicated GPS tracker / Seatalk listener and so far this D1 has been a nice platform because of Wifi, I2C and UART before I move the project to some dual core chip.