toblum / McLighting

The ESP8266 based multi-client lighting gadget
MIT License
1.05k stars 291 forks source link

McLighting Mesh ?? #147

Closed LeonVos closed 5 years ago

LeonVos commented 6 years ago

Hi Tobias, Reading about the Android app :-) Is it an (great) idea to implement a mesh for all Mclithing esp's ?? ESP8266WiFiMesh or Wifiudpclient/server (#ifdef) or even BROADCAST? Not sure yet if there need to be a mas of code to be changed (like Server.on /....... etc)

But know for sure many would like to control ALL there McLighting esp's without a Mosquito/mqtt server but from the buildin webpage.

to be cont.....................

Regards Leon

TechOnlyGamer commented 6 years ago

i think if u want to control all of them from the app i dont need to change anything on the esp. iam planning right know to implement more then one device in my app so that i could even call the function to post the http request to all of them. a mesh is more a way i think that all devices communicate with each other but the app can handlr more devices and chamge all of them so the work is done by tje app not the esp so we could keep the code on tje esp smaller and more efficient

LeonVos commented 6 years ago

When one has a Android phone, yes, but for iphone there's no app. LV

TechOnlyGamer commented 6 years ago

yeah but its the same thing, i think there is too much work for the esp to get this working the approach with an rpi running only mqtt is like 20 bucks??? and time beeing maybe we goet someone taking the same approach in creating an iphone app or something.

debsahu commented 6 years ago

A big TODO, not an easy implmentation! For now the recommendation is to use MQTT and all clients connect to same topic. Alternatively as mentioned here call multiple rest API from one place (like an app). I've no app building experience.

I think WiFiMesh is a great solution for adhoc wifi network. When I have time I will try to get some examples of painlessMesh working. https://gitlab.com/painlessMesh/painlessMesh/blob/master/examples/webServer/webServer.ino

toblum commented 6 years ago

Hi @LeonVos,

using a mesh network sounds interesting but is not easy to implement in such a way that it works flawlessly for all users. I'd like to have it as easy and stable as possible. @TechOnlyGamer approach to send the same command to a number of ESPs looks like a easier solution. I also started working on a alternative web UI that could talk to more than one ESP, but it will take some time to find a nice and stable solution.

Best regards Tobias

debsahu commented 6 years ago

Update: I have something working as of now,

@toblum It does not have the McLighing interface that you have here, but do you want me to create a branch for people to try?

TechOnlyGamer commented 6 years ago

if there is an RestAPI say Hello to my Android App

toblum commented 6 years ago

Hi @debsahu,

that sounds great. Can't wait to try that out. Will see if I can make the webinterface work for that. Is the API mainly the same?

Sure, create a branch as you like.

Regards Tobias

debsahu commented 6 years ago

@toblum RESTful API, Async Websockets and Async MQTT API are the same. RESTful API is working and is same as ws282fx example for now. How do you test WebSockets, i.e. your favorite client?

Currently working on WiFiManager to set WiFi for internet, for now it is hard-coded. Also exporting tickers to Task Scheduler. Work in progress!

debsahu commented 6 years ago

@toblum I created develop and experimental. Since this is experimental I will add my code there, not ready for public consumption yet. I cant delete any of your branches, I think only you can do that by going to 'settings'. I also recall that one can restore deleted branches, if needed as well.

toblum commented 6 years ago

Hi @debsahu,

I deleted some branches now. Much better overview. I hope I didn't delete too much.

I was using this chrome extension: https://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo It has all the basic features and "just works".

Best regards Tobias

debsahu commented 6 years ago

Anyone here willing to try the Meshy McLighting? https://github.com/toblum/McLighting/tree/experimental/Arduino/MeshyMcLighting

Meshy McLighting Server WiFi and MQTT settings are still hard coded (Any ideas of making use of something like WiFiManager or something you have come across is appreciated). WiFi channel of the router needs to be manually specified, usually its channel 6 in USA as default.

Meshy McLighting Clients Do not enable WEBSERVER for now, not being used. WiFi channel must be the same as the WiFi router and Server.

@toblum created a favicon.ico, I dont know if you like it? It is there for me to see if an icon is displayed on chrome, we can change it because I spent a whole 3 minutes to create it! And what I need help with is it correctly implemented in the webpages <link rel='shortcut icon' type='image/x-icon' href='favicon.ico' />? I dont see the icon thats why I'm asking.

toblum commented 6 years ago

Hi @debsahu,

I hope I'll find time at the weekend to try it out. So little time at the moment. I'm also working on an alternative UI for McLighting (https://github.com/toblum/McLightingUI). I'm trying to have a first version ready soon.

MeshyMcLighting seems to have a similar API, so it should be possible to build a UI that works on both. Did I see this right? So both together could be the new and improved v3 of McLighting. What do you think?

Regarding Favicon: I like it. But if we choose an icon we should have also bigger versions of it, so that we can provide homescreen icons for mobile devices. I havn't done that so far, because I didn't find a cool icon. Maybe some of the users has also some skill to create one.

All I can say again is that I'm totally impressed with your work. You can do in a short time what would have cost me months and years. Thanks again for your contribution.

Best regards Tobias

debsahu commented 6 years ago

Thank you for your kind words, all the framework was present making my task easier.

Regarding WebUI development, my knowledge is 2000's HTML and basic JS! If I have a working example, I can maneuver around to figure things out. Now that you have a separate project for UI I can fiddle around a bit.

MeshyMcLighting has exactly same (MQTT and WS) API as McLighting, only difference being websocket is hosted here ws://HOSTNAME/ws (port 80) instead of port 81. McLighting's UI uses websockets but the version I have in there, uses RESTfulAPI. Regarding RESTfulAPI, yesterday I added everything that was in McLighting except for /set_speed, /set_brightness and /all which can all be done directly in /set_mode. I'm in touch with awesome developers at painlessMesh as well and trying to figure some kinks out regarding mesh networking. I also have to warn that running mesh network makes ESP8266 power-hungry, so a powerful power-supply is recommended or USB 3.0 or powered USB 2.0.

debsahu commented 6 years ago

A video on MeshyMcLighting, still experimental!

MeshyMcLighting

toblum commented 6 years ago

Hi Deb,

this looks great. I like how reliable the sync happens. This is a much better approach than my experiments with websocket calls to multiple nodes. This isn't really reliable as the ESP struggles with many WS connections open. I see that the master node can also work standalone. I first thought that you always need at least two nodes, but this is great. So this version could easily replace the current implementation. Regarding power consuption: I don't think it's a problem in most cases, as the strips draw the most power. But is it possible to turn off mesh functionality if you don't need it to save power? I didn't see that. As the API is almost similar, I will try to make the new UI work with your implementation. Should be easy. I had to order fresh ESPs and strips to have a meshy setup in parallel to my existing one. I hope they will arrive soon.

Greetings Tobias

debsahu commented 6 years ago

@toblum A few things to note,

  1. WS2812FX + painlessMesh + TaskScheduler causes crashes. Even with setting no delays on loop there is some interference of SDK call espShow() in NeoPixels library. NeoAnimationFX + painlessMesh + TaskScheduler has no issues.
  2. From my numerous experiments, IwIP 1.4 higher bandwidth (default settings on platformio, not default on ArduinoIDE) is reliable and IwIP 2.0 is a mess.
  3. For using McLightingUI (also in the video), ws calls are exactly the same so I replaced ":81" with "/ws", very minimal code change.
  4. I have a Server without Mesh (uses native TaskScheduler and not painlessMesh's stripped down version) working non-stop (300LEDs), still testing on WS2812FX and NeoAnimationFX settings. I am having trouble with mDNS and DNS for some reason. I will iron this out when I have time and create a #define DISABLE_MESH_SETTINGS that can be toggled in definitions.h. Or I can upload what I got and someone can pitch in with creating this definition.

EDIT: painlessMesh devlop version is just fantastic. no more sdk calls, no blocking which means MQTT reconnects are more reliable (can get rid of unreliable STA_IP change check that I use now). I am moving towards that and have to iron out some issues (DNS is not working).

LeonVos commented 6 years ago

Jep, looks like the mesh was a good brainer of me , @debsahu GOOD JOB. @toblum, nice job on the new controls.

And some new thing about the wifimanager, checkout ; https://github.com/kentaylor/WiFiManager#portal-continues-to-exist-after-configuration Ken has leveled this up, now when on dhcp you get feedback from the wifimanager on connection status and addresses, great idea.

toblum commented 6 years ago

Hi @debsahu,

I tried today with two nodes. Server works, but I could not get the client to sync. It always shows white and in Serial I see "----- WiFi Mesh Setup complete -----", but no sync. I set WiFi to my Wifi routers channel.

On the server I see: CONNECTION: stationScan(): ap_name CONNECTION: espWifiEventCb(): SYSTEM_EVENT_SCAN_DONE CONNECTION: scanComplete():-- > scan finished @ 73868592 < -- CONNECTION: scanComplete():-- > Cleared old aps. CONNECTION: scanComplete(): num=1, err=0 CONNECTION: scanComplete(): After getting records, num=1, err=0 CONNECTION: found : ap_name, -52dBm CONNECTION: Found 1 nodes CONNECTION: findConnection(1834281390): did not find connection CONNECTION: connectToAP():CONNECTION: connectToAP(): Already connected using manual connection. Disabling scanning.

Do you have an idea what's wrong here?

Regards Tobias

debsahu commented 6 years ago

@toblum use IwIPv1.4 Higher-Bandwidth

debsahu commented 6 years ago

Also what is the serial output on the client side? It should say connected to AP. On the server Serial output, it should say the WiFi channel that the clients needs compiling, does it match the WiFi channel on the router? I see that in your output you posted it says it's connected to 1 node, so I'm guessing client is connected? Could you change color or something ok the server to trigger a broadcast and see if syncing with client happens?

toblum commented 6 years ago

I had already selected this. But after reflashing multiple times it works now. I don't know what was wrong.

I have now one server with two clients. They all sync, but it takes always about 5 seconds until a change is reflected at the clients. In your video it was a instant reaction. Do you know that behaviour?

debsahu commented 6 years ago

Ha yes. My local version is different only in that aspect, sorry I'll upload the my version with changes once I get to my computer. What you can do is replace all if(!taskSendMessage.isEnabled()) taskSendMessage.enableDelayed(TASK_SECOND * 5); with taskSendMessage.enableIfNot(); taskSendMessage.forceNextIteration(); through out in server sketch.

debsahu commented 6 years ago

Also mesh syncing and network stablilty takes time (5-10min). Make sure to keep them fairly far apart, 1.5m or so.

toblum commented 6 years ago

Ah! That explains it. Works great with the change. I think that I also have problems with the power. The ESP is getting fairly hot and flashing via USB often leads to restarts of the ESP. That could also be a problem. I have to look for a powered USB hub. That makes setup a bit harder for ma at the moment. I also noticed that the webpage isn't served very reliable, often the ESP just don't returns anything and the browser keeps loading.

LeonVos commented 6 years ago

Great job DEB !!! I will try a setup this weekend.

thundergreen commented 6 years ago

Will mesh be implemented now ?

debsahu commented 6 years ago

Most probably not, but you can try the experimental branch. Other avenues of getting the same results are being explored.

aidbish commented 6 years ago

@debsahu Hi Debsahu, could you elaborate on what may take it's place? i have a project coming up that would benefit from the mesh style setup.

debsahu commented 6 years ago

@aidbish ArtNet or some implementation like that.

aidbish commented 6 years ago

Cool, look forward to it.

aidbish commented 6 years ago

Hi Debsahu, just a quick question regarding the mesh. i am currently using it till a new version is developed and it does actually work pretty well. what i do a have a problem with is turning them off. for some reason the off doesn't seem to function from the web page.. any ideas?

debsahu commented 6 years ago

@aidbish which web UI are you using?

aidbish commented 6 years ago

Im using the index.html one from mclighting experimental, couldn't see one in the meshmclighting folder.

it does look different to the standard one though. i even tried the standard one, but it didnt appear to change

aidbish commented 6 years ago

@debsahu which UI should i be using

yashodeepk commented 3 years ago

@debsahu I am unable to use mDNS with the example provided need a help here