• Hi all, I just got into this espruino yesterday and I am so excited and loving it. this is amazing. It completely open up my possibility on building cool stuffs that I never thought about. Thanks for building such a great community. Anyway, back to my project. so I am planning to build something like the Belkin Wemo. an advanced ver of the wemo.

    My Goal:
    I want to automate my fish tank on refilling water whenever the water level drops to certain level. I m using one water level sensor, one temperature sensor and two switch to turn on/off the water pump and a heater. and of course the esp8266 board itself.

    Main features:

    1. sends the water level/temperture to my webserver every 30min/hour
    2. monitor the realtime water level and temperature from my browser(phone or app).
    3. be able to turn on/off the water pump from my browser (send a request to my esp8266 from my browser)
    4. when connected to the espruino from broswer, the temperature/water level value update itself on webpage as soon as the actual value changes. Not via refreshing the page manually or doing a pull to the esp8266. I would like the esp8266 push to the browser whenever the value is changed.

    My Roadblocks - I got stuck at 3 main issues. I am not sure what to do here. Hope you have some suggestion for me.

    1. since I don't have a static IP with my home internet, how do I get the correct ip address whenever my ip is changed? because I need to send the new ip address to my server and store it to db so I can send request to back the esp8266 to turn on/off the water pump and monitor the realtime water level/temperature value.

    2. how do I get the realtime temp/water level update by itself without doing a pull from browser? I am guessing I need to use socket right? if so, please provide some reference on this. if not, what would you do to achieve this goal?

    3. How do I update the wifi login info without hard code it to the code using the IDE? I want to be able to update the wifi login info using my phone whenever the wifi password is change. I want to make this board as portable as possible.

    Thanks for reading and Hope you have some tips for me to solve my two issue.
    Thank you.

  • 1) Many routers let you reserve an IP based on MAC address. I've used this facility on a Netgear router on an Espruino/ESP8266 project of my own.
    2) WebSockets if you can connect directly to the ESP8266 over LAN, MQTT if you need to be remote/WAN and don't want to open your firewall to your home network.
    3) ESP8266 Espruino build has facility to save WIFI credentials independently of your sketch/code. Check out the documentation.

    Good luck

    Edit: If you can't assign an IP based on Mac address go with MQTT. This negates the issue of a dynamically changing IP address, lets you use remotely without firewall compromise (which is often unsafe DMZ), and is great for two way communication.

  • Thanks for your reply, Ollie.
    Actually, my goal is to make esp8266 as portable as possible. I tried to eliminates all the manual configs that might need on my routers. Just like using a wemo, I never really have to mess with the router setting to get it to work. All I need is to turn it on, login to the wemo and setup the wifi login info and done. this is what I am trying to achieve in this proof of concept design. then expend it from there.

    By the way, I am having hard time to get the external ip(the public ip of my modem). when I do wifi.getIp(), it only returns the local ip(192.168.x.x). How do I get the external ip from esp8266? bcuz I want to get the the real ip and post it to my web server whenever it changes so I can access from outside.

  • On Espruino WiFi boards you can use wifi.setHostName to set a host name, so that if DNS is working properly on your home network you can just access the device via that name. http://www.espruino.com/Reference#l_Wifi­_setHostname

    Unfortunately I don't think that's on the ESP8266 yet as we're trying to get a more general-purpose solution using JS, but there is some info and a gist on https://github.com/espruino/Espruino/iss­ues/1376 that might work.

    However if you have a server that you know the IP address of or that is available via DNS, I'd just POST your IP (which you can get with wifi.getIP(...)).

    I am having hard time to get the external ip(the public ip of my modem)

    You'll find that when you post it to your web server, the web server itself should know the IP address of the client that is connecting to it, and you can get it that way.

  • Unfortunately I don't think that's on the ESP8266

    This does work on the ESp8266. It's the ESp32 that it has not been implemented on.

  • Thanks! I misread my own comments on that page: "This is only available in ESP8266 boards running Espruino and Espruino WiFi boards"

    So yeah, that'd be the way to do it.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Trying to make a wemo like project - need help/suggestions

Posted by Avatar for coyu1314 @coyu1314

Actions