ESP8266 for remote sensors and points.

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

ESP8266 for remote sensors and points.

Post by Dagnall » 03.06.2016, 19:57

Hi, I have been trying to understand and follow the Esp8266 stuff in the German forum without success.
I have an ESp8266-12E module and use the Arduino interface.
I have downloaded "Liviu M" 's example code from "Re: Event (Rückmelder) per LAN in RR auslösen" "http://forum.rocrail.net/viewtopic.php? ... 39#p100403
I have also updated my ROCRAIL so I have the new "LAN" controller available.

I have the "LAN" command interface in ROCRAIL set as "PORT 1010", and the "decoders" option checked.

In the wifi2RR there are set-ups for:
IPAddress ipBroad(192,168,0,5); //I assume that this is the PC where I am running Rocrail?
const int port = 1010; I presumed this to be the same as the LAN interface set above?

The code compiles and tells me its connected to WIFI and
"Full sen addr: 10 Sensor AddrH: 0 Sensor AddrL: 10" (I set these in the code)

I have also set up a dummy locomotive with Code@ set at 192.168.0.22 (the ESP wifi address) and A short address of 10
When I change the throttle the server gives the following "19:50:35 unable to connect to 192.168.0.22:1010; check the network..."

I cannot see anything happening in the ESP8266 serial monitor window either after it says it is connected and sends the debug message with the address.

What I would really like to do is have a simple version of the interface that
(A) can receive throttle commands and functions, so I can put one ESP in a Locomotive
(B) another version of the software that can be used statically to send sensor signals back to ROCRAIL (for block monitoring), and also receive "switch" commands so that I can command remote points and block sensors at a distance from the main electronics, without having to run very long CBUS cables all over the garden...

I suspect that the answer to getting this running is blindingly obvious, but I would very much appreciate some help..

Thanks Dagnall

Liviu M
Posts: 942
Joined: 03.12.2011, 20:44

Re: ESP8266 for remote sensors and points.

Post by Liviu M » 04.06.2016, 08:59

Hello Dagnall,

you have the "LAN" in the thread's name wrong understood, at least from the point of view of the rfid2wifi interface. This interface tries to create a "wifi LocoIO" interface - a Loconet device connected to the PC not over USB, but over Wifi.
From the "LAN" point of view, in the interface implements an UDP client for the communication with Rocrail, and a TCP server for the interface's programming.
To speak with Rocrail, the rfid2wifi interface is using the UDP as "transmission medium", the "railroad protocol" it uses is Loconet (R). With other words, the interface sends/receives Loconet messages over Ethernet/Wifi as UDP packages. To use it, in Rocrail you should choose the Loconet -> LNUDP as central station (and should leave the default, broadcast - 224.0.0.1 - IP configuration).
As I said, the board tries to emulate a LocoIO interface. That means it needs board and sensors addresses to be programmed in it.
For a real LocoIO, these programmings are done over Loconet, direct from Rocrail. I've implemented this method in the rfid2wifi also, but I've implemented also the programming from a web browser, using the IP the board is printing at start.I've posted a screen-shot in another topic.
About your plans with the board:
- transforming the board in a "normal" (not rfid) sensors reporting interface shouldn't be to complicated (using the Loconet protocol, of course)
- transforming the board in outputs controlling unit - depending on outputs types (only on/off or PWM) more or less complicated (but complicated than the sensor interface)
- as throttle - theoretical possible, practical you should implement the whole Loconet protocol in it. The Loconet personal edition document should give you an overview about the complexity.

I hope I could help a little,
Liviu

PS In my signature are links to the last sketches' versions on github.

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: ESP8266 for remote sensors and points.

Post by Dagnall » 04.06.2016, 14:48

Many thanks for a very quick response.
I have downloaded your latest code, and I think I have advanced a little.
I started with my Rocrail with a Loconet LNUDP controller, with Hostname 224.0.0.1, port 1235, as advised.
The ESP8266 seems to set up ok, and sends data on the serial monitor and if I access it via the webpage. I copied both sets of text into the attached file.


When I go into Rocrail, I have followed the tabs: programming>loconet>locoio, and I come to a screen asking for "IID", "Low" and "Sub".
I had assumed these to be the board address (102 - 49) or sensor address (1648) as reported by the ESP8266 board, but none of the combinations I tried seems to get any response when I then go and click "query" on the "Addresses" tab.
In the server window on Rocrail, I get "timeout on reply..."

I have tried to change the Loconet LNUDP address (was 224.0.0.1) to one in the range of my network (192.168.0.50) with a corresponding change in the rfid2wifi arduino code, but I get the same results..

My ESP8266 hardware is simply a NODEMCU 12E, with nothing attached.. I plan to try and send sensor status simply by switching one of the inputs , and then when I have got the switch communications from rocrail working, use one of the boards output to drive a servo.
Is it necessary to actually have a RFID reader attached for the code to work? I was hoping I could get communications confirmed first and then try to change the RFID stuff to the simpler IO that I was looking for.

Many thanks again for your help with this,

Dagnall
You do not have the required permissions to view the files attached to this post.

rjversluis
Site Admin
Posts: 42037
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: ESP8266 for remote sensors and points.

Post by rjversluis » 04.06.2016, 15:04

Hi,
When I go into Rocrail, I have followed the tabs: programming>loconet>locoio, and I come to a screen asking for "IID", "Low" and "Sub".
Just use Query:
http://wiki.rocrail.net/doku.php?id=locoio-addr-en
If your modules are not listed you cannot program them with Rocrail. (Your hardware must be LocoIO compatible.)

Liviu M
Posts: 942
Joined: 03.12.2011, 20:44

Re: ESP8266 for remote sensors and points.

Post by Liviu M » 04.06.2016, 15:08

Hi Dagnall,

the programming of the Loconet parameters (board and sensor addresses) should work like in the documentation for the rfid2ln interface,documentation to be found on the github.

Regards,
Liviu

Liviu M
Posts: 942
Joined: 03.12.2011, 20:44

Re: ESP8266 for remote sensors and points.

Post by Liviu M » 04.06.2016, 15:11

Hi Rob,
rjversluis wrote: (Your hardware must be LocoIO compatible.)
It is. :)

Regards,
Liviu

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: ESP8266 for remote sensors and points.

Post by Dagnall » 04.06.2016, 15:25

Hmm. Thanks for instant replies...
I am not getting any responses at all when I "query". I just get "timeout on reply..." from the Rocrail server monitor
Is it essential to have the RFID reader attached?
I thought that rfid2wifi produces a simulated (or real) LocoIO compatible interface?
Dagnall

Liviu M
Posts: 942
Joined: 03.12.2011, 20:44

Re: ESP8266 for remote sensors and points.

Post by Liviu M » 04.06.2016, 15:37

Hi,
the interface should work without a RFID reader attached. At least the one I have here is working.
I don't have any idea why isn't working. I should look if I find the original setup, to see if it is still working for me.

Meantime, may you post your rocrail.ini file?

Regards,
Liviu

PS Are both, the IP & the port the correct ones? Default they are

Code: Select all

IPAddress ipBroad(224,0,0,1); 
const int port = 1235;

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: ESP8266 for remote sensors and points.

Post by Dagnall » 04.06.2016, 16:04

Loconet is set to 224.0.0.1.. and 1235 according to the controllers...
Rocrail.ini attached..
Many thanks...
D
You do not have the required permissions to view the files attached to this post.

rjversluis
Site Admin
Posts: 42037
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: ESP8266 for remote sensors and points.

Post by rjversluis » 04.06.2016, 16:11

Hi,

you must set the correct IID before clicking on query because LOCONET is not the first one, default, CS in the list.
http://wiki.rocrail.net/doku.php?id=lnsv-en
If you let it empty the commands will go to the iid="GCA Canbus" instead of the iid="LOCONET".

Liviu M
Posts: 942
Joined: 03.12.2011, 20:44

Re: ESP8266 for remote sensors and points.

Post by Liviu M » 04.06.2016, 16:17

Hi,

from the rocrail.ini I can see you named the Loconet CS as "LOCONET". May you try to put the same name in the IID field of the General tab before doing a query?

Regards,
Liviu

PS Rob was, as always, faster. :)

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: ESP8266 for remote sensors and points.

Post by Dagnall » 04.06.2016, 16:40

I have deleted the Canbus interface for now, and renamed the loconet Interface ID as TEST in case the name "LOCONET" was reserved and causing problems.
something is now happening:
the serial monitor is giving me
"
LN rec mess: E5 10 50 00 01 00 02 00 00 00 00 00 00 00 00 59
16
Changed address. Full sen addr: 1648 Sensor AddrH: 38 Sensor AddrL: 55
"
When I press "query". but I get nothing on the rocrail display still...

PS, the webserver does not look like the version on the pages, and the code does not seem to be reading the "Index.html" file.. How does that get coded into the EsP8266?

I have added the rfid2wifi.ino in case I have corrupted it... (I have added the Nodemcu definition... and set the debug to 1 )
Where and what is the FS.h file? ?

Dagnall
You do not have the required permissions to view the files attached to this post.

rjversluis
Site Admin
Posts: 42037
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Re: ESP8266 for remote sensors and points.

Post by rjversluis » 04.06.2016, 16:45

Do you have more then one Network Adapter in your PC?

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: ESP8266 for remote sensors and points.

Post by Dagnall » 04.06.2016, 16:56

This PC (running rocrail) has ethernet and wifi.
it has a USb port used to program the NodemcuEsp8266

This pc is physically connected to my router. via Ethernet.

The ESP is wifi to the router,
The GAC CAnbus is accessed via another remote router, but as I have turned off the canbus presumably that does not matter.

The setup has now stopped giving me the "serial message ""
LN rec mess: E5 10 50 00 01 00 02 00 00 00 00 00 00 00 00 59
16
Changed address. Full sen addr: 1648 Sensor AddrH: 38 Sensor AddrL: 55"
that I had before when i pressed query .... and I have changed nothing apart from sending the response to the forum :?: :?:

this is what I get when I press query
17:07:11 timeout on reply...
17:07:08 could not send the packet!
17:07:08 sendto() failed[10065]
17:07:00 could not send the packet!
17:07:00 sendto() failed[10065]
"

Dagnall
Posts: 278
Joined: 15.05.2015, 14:41

Re: ESP8266 for remote sensors and points.

Post by Dagnall » 04.06.2016, 17:19

P.S. I found the FS.h file, but I still wonder why the Webserver is not picking up the /data/index.html file and if that is symptomatic of whats wrong?

Post Reply

Return to “DIY Hardware”