Please help with IOT/esp8266 connection

Hello, I am very sorry to ask such a simple question but I am very lost and worried. I want an arduino code for an esp8266-01 that when a pin is read high it sends a signal to a nodemcu module that then outputs another pin high. I can not find any examples of these online and I am very new to IOT and the ESP modules, so if you could please link me to example code or a forum that has it that would be incredible. I have been working on this project as one of my introductory and have been stumped for at least two months and I just got a breakthrough on it and I really hope I can make this work
Thank you so much and sorry for a really dumb question

joshawatt:
code for an esp8266-01 that when a pin is read high it sends a signal to a nodemcu module

This sounds like nonsense. The Node MCU is a version of ESP8266, so what exactly are you trying to do?

As for the IOT connection, the best example should be from the IOT provider - one that specificalkly offers Arduino code…

the server connection would be the nodemcu board and it would wait for a signal sent by the esp8266-01 board (which it sends when it reads a high signal on one of its IO pins), I hope that clears things up for you, and do you think you could explain what you mean a little more, I am very sorry I am just really new to IOT, if it is any help I want something like this http://randomnerdtutorials.com/how-to-make-two-esp8266-talk/ but instead of nodemcu arduino and instead of outputting on the serial monitor outputting on a digital pin
Thanks, and I hope this helps sorry again for such a basic question

sorry again for such a basic question

We all learn, and I think

am just really new to IOT,

may be the problem - possibly even just a matter of proper nomenclature rather than technobabble.

I think you imply this:

signal-------->ESP8266-01------------->Node-MCU------------->router-------------------->IoT facility
...............wire......................................WiFi...........................................WiFi................................outside service

IF the above is true, the only explanation I can see is that ESP8266-01 is out of WiFi range from the router, i.e. Node-MCU is acting as an intermediate relay. IF NOT, it would appear that one of those devices is redundant, hence my comment. I don't know anything about the ESP8266-01 per se, but I understand the Node-MCU is just a tarted-up version of the same thing with more i/o. The ESP-8266-01 is just a couple of bucks but, if you have a Node-MCU to hand, it is more convenient to use and you might get by with that alone.

Looking at the randomnerdtuturials link maybe you mean more like

logic signal in ->ESP8266 in client mode -> Wireless connection to -> NodeMCU in Station mode (acts like a Wifi Access point) -> logic signal out

I'm unclear as to which bits you want to write in which languages. As far as I know you can flash the nodeMCU firmware onto any ESP8266 module (you dont need to have a branded nodeMCU board) and likewise you can flash the arduino firmware onto a nodeMCU-branded board. But you may need a USB to TTL converter for the programming depending on which boards you have.

Please let us know which of mine or Nick's diagrams are close to what you want to achieve.

joshawatt:
the server connection would be the nodemcu board and it would wait for a signal sent by the esp8266-01 board (which it sends when it reads a high signal on one of its IO pins), I hope that clears things up for you, and do you think you could explain what you mean a little more, I am very sorry I am just really new to IOT, if it is any help I want something like this How to Make Two ESP8266 Talk with each other | Random Nerd Tutorials but instead of nodemcu arduino and instead of outputting on the serial monitor outputting on a digital pin
Thanks, and I hope this helps sorry again for such a basic question

You need two ESP-01.

The NodeMCU that tutorial is talking about is the firmware not the board. There are NodeMcu boards. But again not what this tutorial uses. This tutorial uses two ESP-01 board!

Is there some reason you are unwilling to buy two ESP-01 which are very cheap especially when purchased from China?

In addition, do you have the FTDI adapter to program the ESP-01 that you have?

Buy the parts that the tutorial uses!!!!
The tutorial is very clear on what you need to do!

.

Yeah I have multiple esp8266-01 boards and I've gotten the tutorial to work however instead of just the serial output I want it to send a 5v output and on the client I want it to send a signal when it reads a 5v signal. I don't know how to do that on nodemcu,

As well as I was going for more of rw950431's diagram
Thank you guys again

joshawatt:
Yeah I have multiple esp8266-01 boards and I've gotten the tutorial to work however instead of just the serial output I want it to send a 5v output and on the client I want it to send a signal when it reads a 5v signal. I don't know how to do that on nodemcu,

As well as I was going for more of rw950431's diagram
Thank you guys again

Learn how to modify the Lua script to do what you want.

I don't use Lua, so over and out.

.

rw950431:
Looking at the randomnerdtuturials link maybe you mean more like

logic signal in ->ESP8266 in client mode -> Wireless connection to -> NodeMCU in Station mode (acts like a Wifi Access point) -> logic signal out

I'm unclear as to which bits you want to write in which languages. As far as I know you can flash the nodeMCU firmware onto any ESP8266 module (you dont need to have a branded nodeMCU board) and likewise you can flash the arduino firmware onto a nodeMCU-branded board. But you may need a USB to TTL converter for the programming depending on which boards you have.

Please let us know which of mine or Nick's diagrams are close to what you want to achieve.

Yes this is the diagram I plan on using, and I have all necesarry components (ie multiple esp8266-01 boards, two esp8266 nodemcu boards (incase somethings goes wrong), and an ftdi board that runs on 3.3v logic

OK, making progress now…

I’m not a lua programmer either but I found this https://blog.falafel.com/programming-gpio-on-the-esp8266-with-nodemcu/ that might give you a start. The critical bit to change on the nodeMCU end appears to be

conn:on("receive", function(conn, receivedData) 
        print("Received Data: " .. receivedData)         
    end)

Which might be replaced by something like ( the syntax might not be correct)

conn:on("receive", function(conn, receivedData) 
        if receivedData == "on" then gpio.write(2,gpio.high) end
        if receivedData == "off" then gpio.write(2,gpio.low) end 
    end)

Obviously you then have to modify the sending code to send “on” and “off” in response to the input pin changing. Are you writing the ESP8266-01 code in lua or using the arduino language?

rw950431:
Obviously you then have to modify the sending code to send "on" and "off" in response to the input pin changing. Are you writing the ESP8266-01 code in lua or using the arduino language?

Honestly I was hoping to do it all in arduino but I could settle either way, whichever is easier for you guys to help with. So I assume arduino

What you need on the arduino side is a TCP client. I seem to recall there is an example that comes with the ESP8266 libraries for arduino or you can look at ESP8266. How to connect to the WiFi network (ESP8266WiFi and ESP8266WiFiMulti) • DIY Projects

Looking at the randomnerd tutorial it isnt that clear to me where the value of 192.168.4.1 comes from in the code

cl:connect(80,"192.168.4.1")

So you will have to obtain the IP address of the nodeMCU server and use that in your client code instead.

Ok, apologies for another basic question but how would I do that, I assume there sketches for finding it or something along those lines, I think that is the last I need to do, but I am still a little confused, sorry again.

Usually the server (the nodeMCU end) has a fixed and well-known IP address. You would use the setIP() function in that code (see https://nodemcu.readthedocs.io/en/master/en/modules/wifi/#wifiapsetip). You can then program this value into your client (ESP-01) request.

That bit of infomation seems to be missing from the randomnerdtutorials site.