OMG THANK YOU!!!!!!! Seriously, I have been trying on and off for months to get a working arduino socket.io setup going. I have most of the MEAN stack finished for my security system server but couldn't get away from REST for the arduino itself.I can't believe nobody has commented on this. This has saved my life man. Your code is so simple and easy to understand which is important to me as a beginner/intermediate programmer. When I couldn't get it to work I just skimmed your.cpp and.h and it all made so much sense.Now my arduino can connect to my server via socket.io and I can arm/disarm my alarm remotely (in a better way than I was before).This made my day. Nay, my month.
![]()
Keep working on this and get that git-hub working. People should flock to this, it's so extremely useful. I did edit your.cpp code a bit though.So, as you know, the send function accepts three strings; one for the socket.io '.on' identifier (not sure what its called), one for the key and one for the value. Then it makes an object out of it and sends it off.I modified it to accept a string that is in JSON format. This way instead of a single key:value pair I can now send an entire object with multiple key:value pairs.Then in my arduino code I made a quick little function 'jsonBuilder'.
Hit there, I know it's been a while but I'm trying to do the same and having a problem with the software serial. My ESP8266 works fine alone without serial, as well when it's running software serial without wifi but when I try to combine both, it stops the wifi communication with computer.
I run it whenever I want to send data over the socket and it constructs a string out of my data and sends it off with the modified send function.Works great! I am able to send my entire security system status in a single object in one single send call. Sorry my reply is so late now haha!
I was out of town for military stuff since November and have had ZERO 'fun time' (programming, electronics, etc.) since then!Now the hard part is pulling all my code back up and remembering what is what! God I hate when I have to take a long break from these things.Anyways, definitely an awesome library man. I can't say enough how much you saved me here. I searched for months and months and months before finding your library. I think part of why you haven't gotten many replies is that this is still new stuff. I mean, sockets like this have been around forever, but you just don't see that many people who are working on socket.io with arduino, and when they do it's all hard wired USB and just other things that I don't want.I am an amateur with all this (experienced amateur I suppose at this point) and the only reason I took the dive to start learning socket.io, node.js, angular.js, mongo etc was because my buddy highly recommended it. And he is a 'cutting edge' type software developer.
He spends most of his time working with beta tech stuff like the virtual reality stuff right now for example. He turned me onto all these javascript based socket connections and said they will be more popular later when more is done with them. They definitely improved my security server dramatically.
This is a pure transparent bridge between Wifi and serial using any ESP8266 device. It's very useful for debugging or talking to remote serial device that have no network connection.
I'm using it on WeMos target, you can find more information on WeMos on their site, it's really well documented.I now use WeMos boards instead of NodeMCU's one because they're just smaller, features remains the same, but I also suspect WeMos regulator far better quality than the one used on NodeMCU that are just fake of originals AMS117 3V3.
This project is mainly based on excellent @me-no-dev ESPAsyncWebServer library and great JQuery Terminal done by Jakub Jankiewicz.
Once uploaded SPIFFS data (web page) you can connect with a browser to http://ip_of_esp8266 and start playing with it.The main
index.htm web page include a full javascript terminal so you can type command and receive response.
The main web page can also be hosted anywhere and it's not mandatory to have it on the device (except if device and your computer have no access on Internet). I've published the fully fonctionnal WEB page from github so you can access it from here and then connect to your device on wich you flashed the firmware.
Some commands will be interpreted by the target (ESP8266) and not passed to serial, so you can interact with ESP8266 doing some variable stuff.
Test web page without ESP8266
You need to have nodejs and some dependencies installed.
webdev folder is the development folder to test and validate web pages. It's used to avoid flashing the device on each modification.All source files are located in this folder the ESP8266
data folder (containing web pages) is filled by a nodejs script launched from webdev folder. This repo contain in data lasted files so if you don't change any file, you can upload to SPIFFS as is.
To test web pages, go to a command line, go into webdev folder and issue a:
node web_server.js then connect your browser to htpp://localhost:8080 you can them modidy and test source files such index.htm
Once all is okay issue a:
node create_spiffs.js this will gzip file and put them into data folder, after that you can upload from Arduino IDE to device SPIFFS
See comments in both create_spiffs.js and web_server.js files, it's also indicated dependencies needed by nodejs.
![]() Terminal Commands:
Commands once connected to remote device:
Every command in file
startup.ini are executed in setup() you can chain with other files.
I'm using this sketch to drive Microchip RN2483 Lora module to test LoraWan, see the boards I used.
For example my
startup.ini file contains command to read microchip RN2483 config file named rn2483.txt
startup.ini
rn2483 configuration file for my WeMos shield
rn2483.txt
By the way I integrated the excellent @me-no-dev SPIFFS Web editor so you can direct edit configuration files of SPIFFS going to
http://ESP_IP/edit Your computer need to be connected to Internet (so may be your ESP8266 device) and authenticated for this feature, default login/pass are in the sketch (admin/admin)
See all in action
http://cdn.rawgit.com/hallard/WebSocketToSerial/master/webdev/index.htm Known Issues/Missing Features:
Dependencies
Misc
See news and other projects on my blog
![]() Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2023
Categories |