I have been stuck for 3 weeks... Buying things, trying things, googling the heck out of it... Even hired a guy "Arduino Expert" on Freelancer... Still no communication between the devices.
Is this even possible?
If yes, How?
I would tell you everything I have tried but you don't have time to read all of that.
So, I am hoping I can submit to you "Apollo 13" style - the problem, identify what I have, then hopefully you can propose a solution.
Problem: "NodeMCU 1.0 ESP 12E" communicate (anyway at all - but only 1-way required from ESP12E to Arduino) with Arduino (Nano, Uno, or Mega 2560)
Resources:
"NodeMCU 1.0 ESP 12E"
ESP13 Shield (note: something has to host a website - I know the ESP12E can, not sure about this)
Arduino Nano R3
Arduino Uno R3
Arduino Mega 2560
Breadboards
Power supplies
4-Channel IIC I2C Logic Level Converter, Bi-directional 5v to 3.3v
FT232RL 3.3V 5.5V FTDI USB to TTL Serial Adapter Module
And, I really do appreciate the help! So much so, that, if you are the first person to solve this (walk me through step-by-step) so that my project can move beyond this communication problem, I will GLADLY send you $50 USD of Bitcoin.
Of course possible. Most commonly done either through I2C (can handle multiple devices on a single bus, short distance) or Serial (one on one only).
Serial should be the easiest. Software wise a Serial.print() on the NodeMCU; Serial.read() on the Arduino side. Three wires: GND-GND, TX-RX and RX-TX.
It's too late at night for me to grab a NodeMCU and a Pro Micro clonet to wire it up and get some basic code working but that's all there should be to it for the most basic communication between the two.
The esp is a much more powerful chip than an Uno/Nano/mega. It does not have as many I/o, but there are ways around those problems. Adding more I/o to an esp is usually easier than getting two Arduino/esp to communicate & cooperate reliably. So ditch the Uno/Nano/mega and use the esp as the "Arduino".
My favourite is the Wemos Mini. Pretty much as easy as a Nano to upload a sketch to. Tell us what is connected to the Mega and we can suggest ways of connecting that to the esp instead.
The esp is a much more powerful chip than an Uno/Nano/mega. It does not have as many I/o, but there are ways around those problems. Adding more I/o to an esp is usually easier than getting two Arduino/esp to communicate & cooperate reliably. So ditch the Uno/Nano/mega and use the esp as the "Arduino".
My favourite is the Wemos Mini. Pretty much as easy as a Nano to upload a sketch to. Tell us what is connected to the Mega and we can suggest ways of connecting that to the esp instead.
I tried using only the ESP12E but the project overall is the Arduino drives a CNC machine. The CNC machine, thus far, was not able to be driven by the ESP12E - even going through a level shifter. But, if you can get it to work, I will gladly use and reward your instructions. I have not tried a WeMos. I guess I can order one, I have tried everything else except a water clock.
WeMOS and NodeMCU are highly equivalent. Minor differences in pinout, the core is the same: the ESP8266 microprocessor.
No idea how to control your CNC machine. I assume it's 5V levels, so level shifters should work - assuming you have it all wired correctly. Some level shifters are one direction only, that may be a problem.
Another way to do this is to use a port expander such as the MCP23008 or PCF8574 and run that chip on 5V, then the outputs of it are at 5V levels. No need for additional level shifters. You do need a level shifter in I2C bus between the NodeMCU and the port expander.
wvmarle:
Another way to do this is to use a port expander such as the MCP23008 or PCF8574 and run that chip on 5V, then the outputs of it are at 5V levels. No need for additional level shifters. You do need a level shifter in I2C bus between the NodeMCU and the port expander.
or Nano with Firmata?
is there a Firmata client for esp8266? yes, client? google didn't help
Juraj:
or Nano with Firmata?
is there a Firmata client for esp8266? yes, client? google didn't help
I do not have a Firmata. It looks a lot like the insides of a PuckJS (which I do have but it only has Bluetooth, not wifi). I do not want to buy even more components though until I am certain it must be that way and it works.
what did you try from the software perspective? the ESP13 has the SDK firmware? did you try AT commands examples with it? or WiFiEsp library on Uno/Mega side?
try some web client or telnet server examples.
connect ESP13 serial to Mega Serial2 and make in Mega sketch debug prints to Serial for the Serial Monitor
As usual quite impossible to see from such images what you really did, so I decided to build a test rig myself. And 15 mins later: one NodeMCU sending "1" and "0" characters over Serial through a level shifter to a Pro Mini, which dutifully switches an LED on upon receipt of a "1", and off on receipt of a "0". I knew those level shifters would sooner or later be useful
Code on the NodeMCU is basically a modified Blink:
Connected to the level shifter: RX to LV2, TX to LV1, GND to GND and 3.3V to LV.
Then the Arduino Pro Mini (clone). Code:
#define LED 12
void setup() {
pinMode(LED, OUTPUT);
digitalWrite(LED, HIGH);
Serial.begin(115200);
Serial.println("Blinking on GPIO pin " + String(LED));
}
void loop() {
if (Serial.available()) {
char s = Serial.read();
if (s == '1') {
digitalWrite(LED, HIGH);
Serial.println("on");
}
if (s == '0') {
digitalWrite(LED, LOW);
Serial.println("off");
}
}
}
Connected to the level shifter: RX to HV1, TX to HV2, GND to GND and VCC to HV. LED is connected to pin 12 and a 1k resistor to GND.
The NodeMCU RX-LV2 and Arduino TX-HV2 connections are not necessary, as it's a one-way communication.
I'm by no means an Arduino expert. I've never done this before, yet built it in barely 20 mins including digging for the components and uploading the sketches and so. That your "Arduino expert" couldn't get such a simple link to work makes me wonder what he and me missed.
For starters: are you sure your level shifter is bidirectional, or at least unidirectional in the LV to HV direction?
wvmarle:
As usual quite impossible to see from such images what you really did, so I decided to build a test rig myself. And 15 mins later: one NodeMCU sending "1" and "0" characters over Serial through a level shifter to a Pro Mini, which dutifully switches an LED on upon receipt of a "1", and off on receipt of a "0". I knew those level shifters would sooner or later be useful
Code on the NodeMCU is basically a modified Blink:
void loop() {
if (Serial.available()) {
char s = Serial.read();
if (s == '1') {
digitalWrite(LED, HIGH);
Serial.println("on");
}
if (s == '0') {
digitalWrite(LED, LOW);
Serial.println("off");
}
}
}
Connected to the level shifter: RX to HV1, TX to HV2, GND to GND and VCC to HV. LED is connected to pin 12 and a 1k resistor to GND.
The NodeMCU RX-LV2 and Arduino TX-HV2 connections are not necessary, as it's a one-way communication.
I'm by no means an Arduino expert. I've never done this before, yet built it in barely 20 mins including digging for the components and uploading the sketches and so. That your "Arduino expert" couldn't get such a simple link to work makes me wonder what he and me missed.
For starters: are you sure your level shifter is bidirectional, or at least unidirectional in the LV to HV direction?
I will try this shortly. With a Nano. I do not have a Pro Mini...
So to take it to your CNC machine, loads of questions come up.
As I understand it, the machine is operated by some software running on that embedded Nano and two stepper motor boards, which are operated by sending certain commands to it, and then it does the milling.
How are those commands sent to your Nano now? Over USB or otherwise?
What are those commands exactly - as in protocol, encoding, etc?
Where do the commands originate?
How do you think to get these commands onto the NodeMCU so it can transfer it to the Nano?
How time critical are those commands?
For connecting the NodeMCU to your stepper motor boards directly: for lack of info, I will assume that these boards require 5V power and 5V level signals to do their job. I don't see any problem in connecting them through a level shifter, provided that the shifter is wired correctly (most importantly that both sides have the Vcc and GND connected, or you can never get the correct levels on the receiving end).
To get those stepper motor boards to work, best would be to take one, connect it to the NodeMCU via the level shifter, power it all up, and start doing experiments with it. Just some simple software that moves the motor one step at a time or so, whatever is easy, just so you can see it works. That way you can get the NodeMCU to do the controls - that is, provided the 11 available digital pins are enough for your rig.
Be aware that if timing of the stepper motors is sensitive, you may be better off sticking to the Arduino for that part of the control. The moment the ESP gets to handle a web request it may "stutter" as it's busy doing other things, not running your sketch. That's the nature of the board. Usually no problem - you can even switch off the whole networking part in code - but you have to be aware of it.
Fear of screwing up the solder job with my one level shifter turns out to have been the whole problem!
THANK YOU!
Now, I need your Bitcoin address wvmarle! I absolutely want to reward you for making me believe it works with the components I have which forced me to the soldering solution.