picaxe to picaxe via ESP-8266?

jims

Senior Member
I have a Picaxe 08m2 communicating successfully with a Picaxe 20m2 using 2 Picaxe ERF modules. I want to try a less expensive RF module...the ESP-8266. Have any of you FORUM folks used the ESP-8266 to communicate between 2 Picaxe m2 chips? If YES then I'll try to do it, and will probably be back to get some help if/when necessary. Thank you for any responses to this query. JimS
 

jims

Senior Member
Since there were no responses in the 4 days since April 4th; I'm assuming that the answer is NO. JimS
 

rossko57

Senior Member
The module works with Picaxe, as you'll know from other threads. The question is really, can you "pair" these modules so that serial into one comes out of the other? Will that work without a WAP inbetween? Questions for the 8266 forum I think, but do let us know if you find out
http://www.esp8266.com/
 

beb101

Senior Member
You may be able to do this with the Lua firmware. I haven't found any code to do a bi-directional
serial-WiFi-serial bridge, but I think the key to doing this is the Lua UART module together with
a TCP server on each ESP. The API is described here,

https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en

Setup the UART on each Picaxe ESP. Then use the callback event, uart.on() data function to hold
the TCP socket functionality to send to the other Picaxe ESP. Something like this,

Code:
init on both ESPs (runs on soft restart or hard reset)
gets router DHCP assigned ipaddress
======================================================
--init.lua
print("set up wifi mode")
wifi.setmode(wifi.STATION)
wifi.sta.config("ret13x","XXXXXXXXXX")
 --here SSID and PassWord should be modified according your wireless router
wifi.sta.connect()
tmr.alarm(1, 1000, 1, function() 
    if wifi.sta.getip()== nil then 
    	print("IP unavaiable, Waiting...") 
    else 
    	tmr.stop(1)
    	print("Config done, IP is "..wifi.sta.getip())
	print("ESP MAC Address: " .. wifi.sta.getmac())
    	--dofile("yourfile.lua")
    end 
 end)

Data Sent from ESP1 to ESP2 (same for ESP2 to ESP1, diff. Ipddress below)
===============================================

uart.on("data", 4, 
      function(data)

	local conn1 = nil
	conn1=net.createConnection(net.TCP, 0) 
--connect 
	conn1:connect(port,'Ipaddress_ESP2')
--send data
	conn1:send("data")
--close connection
	conn1:socket:close()
  
      end, 0) --end function

Server on both ESPs 
===================
-- start server (the ESP knows its the Ipaddress from init)
    srv=net.createServer(net.TCP) 
    srv:listen(5666,function(conn) --port 5666
--receive from other ESP
	conn:on("receive",function(conn,payload)
--show what was received
        print(payload) -- out serial port on this ESP
	end) -- conn:on("receive" ...

-- Close server connection and continue to Listen for request
	conn:close() conn = nil
end) -- srv:listen(5666,function(conn)
So, the way I see this working is:

(1) one Picaxe sends data out the serial port
(2) uart.on( ...) receives the data and sends it out via the TCP connection
(3) the server on the other Picaxe ESP receives the TCP data and
sends it out to the Picaxe serial port (a Lua print("...") just goes out on the TX connection)

I am going to try this and will report back.
 

jims

Senior Member
I thank all of you who responded to my questions. At this point I'm going to get more Picaxe ERF modules to expand my system. I believe that I have neither the skills, the time, nor the inclination to "tackle the challenge" of learning how to make multiple ESP8266 modules communicate with each other. I'm confident that I can expand my system by using my existing skills and modifying the code that I've already developed. It was quite easy getting "up to speed" using the ERF modules. Thanks, JimS
 

rossko57

Senior Member
Multiple modules? That puts a different complexion on it again. The ethernet modules wouldn't be well suited to "one broadcasts, all listen" techniques, if that is the kind of scheme you have planned. They'd do well in master-slaves setups though.

You are going to have to have some kind of "management layer" for more than one or two paired direct radio links. If you can outline what you have in mind - a master with several slaves perhaps, or an maybe any-to-any peer to peer scheme - there are more than likely wheels you won't need to reinvent.
 

jims

Senior Member
Multiple modules? That puts a different complexion on it again. The ethernet modules wouldn't be well suited to "one broadcasts, all listen" techniques, if that is the kind of scheme you have planned. They'd do well in master-slaves setups though.

You are going to have to have some kind of "management layer" for more than one or two paired direct radio links. If you can outline what you have in mind - a master with several slaves perhaps, or an maybe any-to-any peer to peer scheme - there are more than likely wheels you won't need to reinvent.
rossko57...Here's an overview of the system that has evolved using ERF modules. JimS
 

Attachments

jims

Senior Member
I'm not sure how to rotate the system overview so that it can be viewed as "landscape. Sorry about that. JimS
 

veewee77

New Member
Serial with ERF Modules

I have a Picaxe 08m2 communicating successfully with a Picaxe 20m2 using 2 Picaxe ERF modules. I want to try a less expensive RF module...the ESP-8266. Have any of you FORUM folks used the ESP-8266 to communicate between 2 Picaxe m2 chips? If YES then I'll try to do it, and will probably be back to get some help if/when necessary. Thank you for any responses to this query. JimS
Jim, I have tried to get them to talk completely unsuccessfully. I was going to try the WiFi method and see if it would work for me. I would gladly go back to the ERF modules if I could get it to work.

Similar setup to yours except that the slaves are going to take commands, do something, watch for an event and tell when the event has occurred.

Would it be possible to see your code for your project that is working so maybe I can get on with my project as well?

Thank you!

Doug
 
Top