-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP wifi module #118
Comments
Hi, I love EventGhost and used it many years ago! I had know idea it was still going strong. I would love to do what you are describing. I've already prototyped a bracelet that uses the $20 Particle Photon. The Photon's are nice because they are very easy to program. I've written an example program that uses the low-bandwidth MQTT messaging with FIND and it works great. I would however be interested in doing something with the ESP8266's, as they are cheaper. I can certainly assist with this. You mention that firmware can be written to them with Arduino IDE - does this refer to $15 SparkFun ESP8266 Thing? I'd like to know if its possible to program the chip directly instead of buying $15-20 boards. |
Yessir you just have to use an ftdi USB to 3.3 TTL serial. The only thing is during the flashing process you don't want to use a cheap wall wart. For a couple of reasons. They consume just over an amp during flashing. And cheap wall wart the voltage will drop will cause issues. As well as A/C bounce the esp's don't like it to much. You can flash them directly using the Arduino IDE and the firmware to be written in C++ and the base "software" is keyed to network comms and is made specifically for the esp. So yeah order up some they are 1.50 USD online. I would for sake of constant flashing probably get one that is mounted on a breadboard compatable PCB with pins. For learning. And playing with. But use the really small one with a couple of coin cells and encase the thing in plastic with a strap or a necklace type thing. It should be really simple to make. If you take a 3/4 inch screw in plug for an electrical box. Put the coin cells on it and the esp on top of that put it in a form and pour in some urathane. Let it set. You now have one encased with a removable battery cover. |
I do have some questions about the API though. Does your software only report to your webserver? Because I have someone that wants to use this. But the information he has is to get the data from a website. Now I don't want to make something up for him and run a polling loop to your server. Is there a mechanism in place have it send a notification to a specific IP and port?? And if so point me in the direction of an API for this. I would like to make one suggestion. And that would be to expand the functionality to handle the wifi location. As you have. But make it so you can specify an AP name to listen. And if not connected to that AP have it flip to getting positional data from GPS and marry that with GeoFencing. So you cover total location awareness in one app. That would be awesome. And allow for multiple fences. And send a notification when entering And leaving a fenced area. If you couple that with EG Home Automation has truly become automatic. Because to date everything requires you to pick up the phone and press a button. How Bout if I cross fence 1 turn the heat on. And when I cross fence 2 turn the outside lights on. And when leaving shut everything down and lock up the house. :D |
Thanks a lot for your advice on the ESPs, I am excited to give that at try 😄. As to your questions:
Yes, it uses polling like you said. In the future I would like to use websockets or something smarter.
This would be a great addition! I am actually working on this - I was thinking about IFTT or Pushbullet which would give novice users a lot more control. Both can actually be used for doing Geofencing, I think. As for GPS data, I'm also working on integrating those coordinates as an option so you can actually "see" yourself on a map.
As for the home-automation, there are people using HomeAssistant.io and OpenHab which are designed to turn heat/lights on/off and they work well with FIND. I think this is the coolest feature of FIND, and what I'm most interested in doing. |
Hi Guys, some time ago, i ask the same question, i glad to read someone else its interest in to use a ESP8266 with find, the esp8266 is a beautiful board an very cheap to!!! LoL, you can use a arduino UNO to program them, i wrote how to a: hackster Regards |
i see there is a place to change the server find reports to. is there an API for this? or is the only way at the moment to poll your web server. i just think that in order for the thing to be semi accurate that the polling interval needs to be kind of high and some smoothing needs to take place. and i don't want to make a plugin for EG and have it beat the snot outta your servers. LOL. is there is a way to get the app to report directly to EG and not have to deal with a "middle man" i much prefer this method. because it will keep all the traffic local. and if someone forgets to pay their internet bill. it won't stop working. or if something changes outside of my control it causes support issues for me. and I already have enough on my plate rewriting almost all of the EG code. but i do still like to help out the neighbor in need. and this could also prove useful to me as well. I have a setup that is kind of similar but using bluteeth, raspberry pi's and virtualhere. but the hardware is rather costly compared to the ESP modules. and this seems to be a much better solution |
The API for FIND is here: https://doc.internalpositioning.com/api/.
Yes, sorry this is the current state, the web server is sent fingerprints constantly. However the polling interval is limited to how fast the phone can scan. In my experience scanning faster than 2 / second can cause the phone to crash. Polling 2 / second is really not bad at all, and unless you are tracking > 50,000 people, it will not affect the server, since the payload is very small.
No, currently the app doesn't have any of the code needed to make the computations itself. In theory, you could, but it would require a lot of porting Golang code to Android (which I'm not capable of), and also a way to distribute the learning set among devices. However, you can setup the server locally and have everything work from LAN. I would recommend this actually, since its for home automation. In this case you just run the server on a Raspberry Pi and set your app to the address:port of the Pi. It is still polling. |
@hulkco, Thanks for the link to the tutorial! |
do you have an icon i could use??? I have made a plugin for EG and would like to add an icon for the plugin. tho at the moment EG is very limited in the icon department at the moment (has already been updated in my text release). it has to be 16x16 LOL. and if you would like to provide a description of the FIND app i will use that as well and any help information you might want to provide. once i get everything tested and functioning properly. you are more then welcome to add a link or add EG to a list of programs that currently work with FIND. we are trying to get together a plugin repository of sorts for EG and put together a list of supported devices, software. it's actually a massive undertaking because it has never been monitored and EG has been around since 1997. so do it now while the program is young because putting together a complete list now is going to be impossible for us. |
Very cool! I've never used EG, but it looks neat, I'd like to give it a try. I just made an icon for you: https://raw.githubusercontent.com/schollz/find/master/static/img/FIND_icon.png . Let me know if that doesn't work! As for description, just use the README.md description (you are free to edit/condense it as you see fit!). |
ok now i am going to make ya work. only because EG is going to overlay that icon on top of an icon indicating a plugin i think it's not going to look so hot being a white square LOL any way you could make it with a transparent background. and it doesn't have to be 16 X 16. make it 320 X 320 and i can do the resize. . This is because the version of EG i am working on allows for any sized png to be used as icons and does all the necessary conversions and re sizing internally. And by using a larger raw version it allows for larger size to be used without it looking like doodoo. LOL also if you can outline the non transparent bits in some color. This will help to make it more noticeable when layed on top of the plugin icon. because the plugin icon is a dark blue and being that your icon is black i think it will get lost in the shuffle. I have to learn how to use the PIL library to do an outline and have it calculate what is background and turn it transparent. some dayyyyy. |
Well here is something new I found. A Python 3 interpreter for the esp8266 https://docs.micropython.org/en/latest/esp8266/esp8266/tutorial/intro.html Cool beans. It runs slower then writing in C++ but from what I have read it's not a problem usually. But does allow for coding C++ just like desktop Python anyways. But you can also run code right from a webpage hosted by the esp. Thats awesome. I just picked up a breadboard compatable esp8266 What I would like to know is. What is the API for sending fingerprint data? Is there something written up for this that is correct for 2.3? I can have something written up by tonight for the esp8266. The awesome thing is the sending code to the esp via a webpage. Super simple updates and no need to connect anything to the esp beyond the initial flash for the interperter. |
That is cool! Here is the API for sending fingerprint data if you haven't seen it. The API is frozen, so it did not change in 2.3. |
ok cool. it might take a couple of days to code something up. I have to learn how to use the micro python. I am in the middle of making a custom wx widget (float slider) I am drawing it from the ground up. with the value label that tracks with the thumb. it's kinda cool i have to deal with event generation and making the thumb have an actual point to it. and that's all that's left. so maybe another day and I will be able to get to play with the esp. |
I have a question about the API. The API explains how to learn a new fingerprint. But i do not see anywhere in there about having a device report the mac's and signals. the only API reference is what is below. and that is for both learn and track. and both require a location. I understand that when you want to learn a new location or add to a location the device must be told to do so. and the name of the location is handed to the device. and when the device transmits new fingerprint data to the server this would contain that location name. and if it does not exist the server will create the location. but if the device is in tracking mode shouldn't it just pass the mac and signal data and the server does the rest? this is probably a typo and it doesn't need the location in there i just want to make sure or get clarification of what is needed if it is supposed to be there.
thanks again K |
Currently, the client needs to send a POST request with the data you show. However, I could easily make a server to "do the rest" so the client just has to send along mac and signal data. This server would be a lot like https://lf.internalpositioning.com where it would simply forward on the fingerprints as a /track or a /learn fingerprint depending on the user setting. That way you would only need to send the following: {
"group":"some group",
"wifi-fingerprint":[
{
"mac":"AA:AA:AA:AA:AA:AA",
"rssi":-45
},
{
"mac":"BB:BB:BB:BB:BB:BB",
"rssi":-55
}
]
} The group is still required because the server would be public and needs a way of distinguishing your fingerprints from someone else. Do you think that would be useful? |
please tell me if i am wrong in this. I may not be understanding it properly. but essentially the current setup runs like this. each device has it's own database containing all of the fingerprint data that it has been told to learn and it has to do all of the calculations to figure out where it is and then pass that information to the server. and the server is just a go between to hand off any reported data to whoever is asking. I am basing this all off the premise that I do not know a thing about IOT or programming and how to move data files between things. I know how to pick up my phone and dial the number and i know how to open microsoft word . is basically the limits of my knowledge. LOL if the above assumption on how the current setup works. wouldn't it be far easier to deploy and maintain a system that worked like this. if you decide to implement security for the server. then you could have the server tell each specific device what to do. either track, learn, or to do nothing. however the means in order to put the device into a learning state it would have to be furnished with the group name and the location name so that information can be included in the data sent back to the server to add the data to the proper group and make the location if it doesn't exist. add the data if the device is in tracking mode. it would have to be furnished with a devicename or username and a groupname. and the device passes the current wifi readings the devicename/username as well as the groupname back to the server. the server does all of the number crunching based off the data that has been learned for that group and associates a location to the devicename/username. this kind of a setup makes it easier to maintain. If you make a change to something like the way the calculations are done or if you make a change that allows further access to specific bits of data, then all the user has to do is upgrade the server. unless for some reason the way the readings get read or the format in which the data is sent back to the server changes then the software on the devices will never need to be upgraded. I personally think this would also make you life a whole lot easier as well. far less code to maintain and then you have backing up the data as well. that's easier because there is only one version of it and it is stored in one location. Not to mention that IOT devices by nature are very handicapped in the department of storage space, ram, and processor speed. and also are going to be flash based storage and having data written to and from it ll the time is going to lessen the life of the device buy a lot. it seems logical because of the limitations of IOT devices to move anything that can be off of it and have all the processing and storage done centrally. this will open the doors to what can be used as a device for reporting it's location. the code footprint becomes super tiny. maybe a couple hundred lines of code. again I really do not know the exact process of how Find currently runs. but i am assuming that each device is responsible for it's own data and has to do all it's own calculations. if set up to be a central type of system then porting the code for the reporting devices becomes a snap. |
@kdschlosser Yes, you are wrong in how it works currently. However your idea for a central type of system is how it currently works. This is a quick rundown on how it works:
At this point, the device (phone / esp8266 / laptop) forgets everything it knew, and saves no information. The rest of the magic happens in the server.
I hope that misconception is now corrected! Please let me know if you had another question or if this doesn't make sense to you. I am really happy to answer any questions :) |
OK i get it now. this is where my assumptions on how it operated came from. because the only way i could see it knowing that information is if it housed the data to look it up. |
Yes, this is a good question. The phone and the laptop can easily send a location name since it can be part of the phone App or the laptop command line program and is visible to the user. The problem is with the esp8266, since it doesn't have a user interface, the user cannot toggle them. I think there are two solutions for this:
|
OK... we are getting a little fumbled up here. Let me rephrase the question My question is not with the POST /learn I understand that the device has to be provided the location name for this. With the POST / track. |
And the ESP can be provided a web based GUI to be able to toggle the track and learn. So no worries there. |
Ah! Okay. For POST /track the "location" in the payload is ignored if it is sent. Sorry, this is not clear, I will try to clear that up! |
so just leave it blank. |
👍 Yeah, thanks for pointing that out. Let me know if you have more questions |
I should be good to go at this point. if you want to do up an access page of sorts? or maybe someone else might be wiling to. it has to be written for python most easiest solution would be a class that i can pass callbacks to so it can request specific data I am thinking something along these lines. a page for for actual wifi connection settings. the usual things. AP names and signal strengths and if it is encrypted or not. there can't be anything in the forum of graphics. so anything done would have to be done in code. have to see what space is left and if enough possibly put the find logo or icon. |
For the page with actual wifi connection settings / entering any encryption password - what is this for? If it is for telling the ESP to connect to a certain WiFi network, it won't be able to work because it needs to be connected to a WiFi network before it can communicate with this server. The rest should be easy to do. |
the pages are going to be housed on the actual ESP. and the ESP will be set up as an Access Point for first time use. You would use like a cell phone to connect to the ESP and bring up the setup page for the WiFi settings and IP settings. then once set up to connect to a local network these pages can still be accessed if you need to change the ESP's Connected Wifi or any IP settings. |
@kdschlosser Okay, I'm on the same page now. I'm going to take a stab at this. I am going to test it on my own ESP8266 after I figure out how to use it. What kind of ESP8266 do you have and what do you use to program it? Currently I have this one but it seems pretty expensive to buy a bunch of these, but its nice cause it has lots of pins. |
Oh and here is a link to what i just purchased for development purposes |
Awesome! Thanks for that info. I got the Sparkfun Thing working pretty well, although I'm having trouble with the Micropython installation - the installation works but it never shows up as an access point so I'm thinking its not flashing correctly. I got the server working with Arduino IDE, though. Are you set on Micropython, or open to using the Arduino IDE instead? |
I am really not all the proficient in C++. I am more familiar with python. But either or is fine by me. I do not know if there is a way to get RSSI data from the ESP using the Arduino IDE. I would have to check into it. Also the arduino IDE with the ESP has all kinds of odd anomalies. I am not sure about micropython. But I really do like how you can ability to bring up the interpreter right from a webpage and just copy ans paste code to update the thing or make changes if using micropython. I am going to solder the header pins right now and play around with the thing. |
I think you can. Try using WiFi.RSSI() |
My ESP is running fine. no worries there. but it is useless to connect to the thing after first flash. the WebREPL is turned off by default. so you have to connect via serial. then this is kind of a goofy process if you didn't build your own flash for it. then you can edit the boot.py file directly. but you would have to get REPL into paste mode by pressing ctrl+e
then you would press ctrl+d to run the pasted code this will write the "bootScript" into the boot.py file and reboot the esp. then it should connect. if you want to enable WebREPL (accessing REPL via a browser) then uncomment the 2 lines at noted in the code above |
do you know if you can change the clock speed of the esp on the fly using the Arduino IDE. i think you can only set it at flash time. and it stays that way. I am not 100% sure tho. micropython allows for dynamically changing the clock. so if you have some pretty intense code then you can bump up the speed to 160 mhz just before that code segment gets run, and after that code segment is done turn it back down to 80mhz. this would be extremely useful if you needed a way to conserve battery life |
ok so here is the basic code for sending fingerprint data if tracking.. this is just a test version of it. I do not have my AP plugged in at the moment so i will not be able to test until later today. had to move some wiring.
super simple... this would be written to main.py in the same manner that the boot.py is written. all you would have to do is in the while loop add any code for other things. like handling HTTP requests or changing from tracking to learning mode. setting the username and or groupname |
well here is a sample of the output. it didn't want to run from the main.py. not sure why i will have to investigate. i forgot that pulling time from the ESP is not going to be time since epoch. but will be time since ESP start. so we will have to put in some kind of means to get the time. if using DHCP and a time server is specified use that. otherwise nist.time.gov always works. that is if the person has internet. another question.. does the mac address formatting have to be hex:hex:hex: and does it have to be uppercase as well?
|
you did erase the flash on the ESP yes??? is this the command you used?? also is your board a NodeMCU Board? also you need to check and see how much flash space you have. since the flash is dependent on who made the card. it could be from 512k to 16mb. and if it's 512k then you will need to flash the thing with an alternative micropython. like the one i just got has 4mb all the other ones i have purchased in the past had 512k |
Yep, I"ve used those commands. Specifically:
which both perform without errors. After I wait 2 minutes I do see the AP. However when I try to connect via REPL I get garbage:
and when I try to connect via WebREPL it will Disconnect the websocket immediately (though I am able to connect to the access point itself). I've tried googling a lot, but it seems that the Sparkfun Thing is not a popular board for using with Micropython... Edit: I got it working! |
@kdschlosser as to your question:
The mac address can be anything you want - its simply a name that the server uses to distinguish APs. The name could really be anything you want but MACs are useful because they are often unique. Your payload looks good - don't worry about the timestamp, the FIND server will fill that in as well if its not there. |
cool the server will deal with the time instead of having to code it in. that saves some effort. I think it will be far easier to to make something up in micropython. and also be far easier to maintain. and instructions are really simple. I should have mentioned that when you connect with micropython i went thru 3 terminal emulators due to the garbage coming in from the ESP and the emulator disconnecting before REPL showed. LOL it also helps if you press Enter a couple of times |
Hello guys, I am reading all the messages to get myself informed, and I want to share the ESP8266 card I am using, it has USB (CP2104) and 16MB FLASH, for only $ 5.00, this is the link: I'll start testing with MicroPython |
Sorry but due to the holidays I stalled on developing anything for the ESP. I will get back to work on it today. I just wanted to give an update |
which esp are you using. they have varying antennas but also who is the manufacturer. I have found that generics don't work as well. the adafruit huzzah has a huge amount of range. i would say about 150 ft through 3 walls. it works at the end of my driveway. I was testing this out for location data in my yard as well. something like this would be easily hooked up to something like a 12 volt supply for outdoor lighting. and I could use it as a dual purpose item. it can get temp and humidity reading. i can also use it for PIR sensors. all kinds of things at the same time. I have set a bunch up to be Access Points because where i live i only had one reference.. my own AP.. so in order to dial in the accuracy these things are great.. but also I would suggest that you create a new user for the ESP or any device for that matter. because of differing antennas and wifi chips and quality of reception is not the same on every device. so you would have to do a learn routine under a new username for each device added. this will ensure that the data being learned is for a specific device. they are not really interchangeable. this is what I have done. and it works like a champ. |
another thing that will also affect the ESPis the power supply. these things are wicked voltage sensitive. when it states 3.3 it means 3.3 not 3.2 or 3.4. so if you are powering it from a wall wart (the brick you plug into the wall) if it's a cheap one you will have fast voltage drop under load. but the worst is the ac bounce.. easiest way to check is by how much it weighs. if it's light it's not a good one. but if you want some hard numbers. slap a volt meter on the 3.3+ and the gnd while the ESP is powered up and running. and look at the voltage. but also look at whether the voltage is stable.. the bounce is easy to fix with a good sized cap.. but low voltage is not so easy. the adafruit ESP's have a regulator built onto them. so you can connect 5 volts to it as a power source with no issues. and because the regulator acts as a filter no bounce.. and since you are dropping the voltage from 5 down to 3.3 it will not have a low voltage issue either |
For anybody interested: Repo with the code for the ESP |
See the one in that link is from AliExpress. And is most likely a generic. But also because of the external antenna connection they will usually skimp on the onboard one. If there is one. In your picture there is an onboard but the antenna on it looks nothing like the one that is on mine. I bet if you connect an antenna to it. It would function a whole lot better. |
An little update for anybody interested: |
@TheMegaTB |
Looks like EventGhost has quite a few plugins listed up there. Even though I do not have any use for it since I migrated to Linux only machines (hatching my own little windows inside a VM with its own GPU 😄) it is looking interesting. Actually, I am currently working on a project to use the so-called state of devices (e.g. your position, the cloud cover or current sun angle) to predict what you as a human would do when you enter the room by "watching" your behavior over an extended period to preempt you touching the light switch. I'll let them know 👍 btw if you run the program on your ESP I'd appreciate any kind of feedback. Currently the README is a big mess so I'll clean that up in the coming days and add some small features and fixes but overall it "should" works. |
Hi, ESP32 has a lot more power than esp8266 and the dev board recently hits the 8USD mark, including shipping. Maybe this is a better solution to include learning on the client side. |
Hello everyone, I´m woriking on ESP8266 with Arduino IDE, and I would like to implement the FIND Tracker with them. As I have A LOT of esp's, it would be great to use it as a Server and as a Client. Tks! |
@jbrand88 it's is not made for the Arduino IDE but works on the ESP8266: #152 |
@TheMegaTB Tks for fast reply! Let me explain my application, than u can visualize what exactly i'm looking for: I need to Track the positioning of animals in open field without GPS. As my knowledge in programming is very low, I started with Arduino IDE and youtube to learn how to program and manipulate the ESPS (thats why i'm looking for something already made on Arduino - but i can try to learn another language too). The initial ideia was to use trilateration (using 3 ESPs as Anchors) and 1 ESP as node (this one I wanna track). But its pretty difucult to make (cuz signals arent precises), so im trying to use some thing already made (or almost made). With that beeing said i got some noob questions: 1 - The fingerprint is obteined by measuring signals around the pleces - so actually these signals dont need any further configuration (is that correct?) 2 - Do you think FIND would be applicable to this situation (as the places the animal is gonna pass arent all the same - and its not viable to register a lot of places). 3 - Am I in the right direction? If not, can u recomend some similar project or further reading? Tks! |
First off: I am no expert in any way everything that follows are just thoughts that came to my mind ;)
EDIT: May I ask what you want to use the tracking data for? Just curious ;) |
Hi Kdschlosser, I am having the same issue as you experienced when accessing the terminal with the Sparkfun Thing. How did you fix it? You wrote: Yep, I"ve used those commands. Specifically: esptool.py --port /dev/ttyUSB0 erase_flash which both perform without errors. After I wait 2 minutes I do see the AP. However when I try to connect via REPL I get garbage:
port is : /dev/ttyUSB0 Terminal ready
and when I try to connect via WebREPL it will Disconnect the websocket immediately (though I am able to connect to the access point itself). I've tried googling a lot, but it seems that the Sparkfun Thing is not a popular board for using with Micropython... Edit: I got it working! |
I ended up flashing the thing with the Arduino IDE (ESP version) I just picked some random sketch to flash onto it. once i did that then i flashed micro python onto it and it started working just fine. I do not know why that works. But i have done this with more then one of them and it fixes the problem each and every time. what was your solution?? |
I have Interest in this as I am very evolved in the EventGhost community. the only downside is that you would have to carry your phone with you at all times. I am interested in making software for an ESP8266 WiFi module. these Wifi modules are about the size of a dime and can run on 2 coin cells. have an 80mhz RISC processor with 512K of memory. and also have an unbelievable range. firmware can be written to them using the Arduino IDE and the code is written in C++. the Wifi Module is really geared to Telnet communication but can be adapted to do more then that. but it also does support sending and receiving web page data. I would like to know if this is of interest? and if I would be able to get some assistance in this project?
The text was updated successfully, but these errors were encountered: