Hello,
Recently i have been having a programming problem with my Arduino Mega 2560.
I have connected a Wemos D1 Mini to an Arduino Mega 2560 via the 2nd Serial port on the mega.
MEGA/WEMOS
TX (pin 16) / Logic Level Shift Converter / RX
RX (pin 17) /TX
5v/5v (It is stepped down on the Wemos)
Gnd/Gnd
Here is a sample code
void setup() {
// put your setup code here, to run once:
Serial2.begin(115200);
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial2.available()>0) //Checks is there any data in buffer
{
Serial.print("We got:");
Serial.print(char(Serial2.read())); //Read serial data byte and send back to serial monitor
}
else
{
Serial2.write("AT\r\n");
delay(1000); // Wait for a second
}
}
Attached is the way it is connected
When i have only the Arduino Mega plugged in, i get this through the serial monitor
Nothing.
When i only plug in the Wemos D1 Mini i get this:
WIFI CONNECTED
AT
OK
AT
OK
WIFI GOT IP
AT
OK
AT
OK
AT
OK
AT
OK
AT
OK
AT
OK
AT
OK
AT
OK
AT
OK
AT
OK
I am really stuck here, any help would be greatly appreciated!
Thank you soo much.
John
EDIT:
Sorry:
I should of said that i have the ESP8266 Flashed with AI thinker.
I wanted to have the Mega send data to the ESP8266, then the mega print what the ESP8266 responded with
The part that says "EDIT:"
I just clarified what i was doing and tried to use the serial basics code.
Do you think there is a problem with the logic converter?
Thanks
John_Sak:
The part that says "EDIT:"
I just clarified what i was doing and tried to use the serial basics code.
For the future please add that sort of thing as a new Reply in the correct chronological order. It makes it so much easier to follow the conversation in the Thread.
Do you think there is a problem with the logic converter?
You did not respond to my request for a readable diagram of your connections.
And you have not said exactly happened when you tried my tutorial code?
Well i have two seperate usb cables, one plugged into the wemos and the other in the arduino. I only plug in one at a time because i hear that if you plug in both it may damage your computer or the wemos/mega.
And yes, the example code was in the edit
There will be no problem if you connect the two boards with USB cables to the same PC. And it will help if you can see the output of both boards at the same time.
My ability to help is greatly limited because I don't have your hardware.
Are you sure you have the voltage converter connected properly? Post a link to its datasheet.
Please draw (with a pencil or pen) a diagram showing how you have everything connected with clear labels on all the connections and post a photo of the drawing.
My suspicion is that you have wrong connections to the converter - but I can't be certain with your Fritzing diagrams.
Dont mind my awful paint schematics.
I forgot to include the regulator i had in the last drawings.
I tried to make sure everything had a common ground.
Also just changed Wemos to run off a 9600 baud rate.
Thanks for the help
I know I probably seem like a PITA, but you have not shown the labels on all the pins on the level converter - and that is what I really need to see now - so I can compare it with the online info about the device.
And what is the "step-down" thing that was not shown at all in your earlier diagrams.
Is the diagram in Reply #13 complete? Or are there other parts or other connecting wires that you have not shown?
No, i just cant easily describe the pinouts.
I have added pictures to the same or similar devices to better show how its connected
Also as shown in the first post,
MEGA TX = 16
MEGA RX = 17
WEMOS TX = GPIO1
WEMOS RX = GPIO 3
I added the step down to deal with the current draw rather than having it directly plugged into the arduino.
Thanks.
Thank you for the better diagram. It would be nice if we could find a proper instruction document for the logic converter. As it is all I can do is guess - so I may be wrong.
I thought I had a sensible guess, but when I re-considered it did not seem sensible.
Sorry, I don't know how the thing works or whether you are using it correctly.
Why not replace it with a pair of resistors wired as a voltage divider - like this
For some reason, all of these models are discontinued. Maybe it dosent work?
I was considering making some kind of decoder/encoder to send signals through analog pins.
like this:
letter a -> 0.5v -> letter a
MEGA SIGNAL WEMOS
But i dont think it is very practical considering software serial.
Thanks
I currently do not have those resistors so i cant really try it.
I will look for a datasheet.
Thanks for your help!
Those resistor values should work fine.
If the system is not working with them then there is another problem.
Can you write programs for both the Arduino and the Wemos so that you can test one-way communication in both directions - maybe everything works in one direction but not the other?