logo elektroda
logo elektroda
X
logo elektroda

Selection of the environment for sensors on the ESP8266 in a home network.

abyss 2823 3
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16201402
    abyss
    Level 14  
    Such a project for winter evenings - to still be intellectually active in the second half of my life, while not pushing the subject into serious science and professionalism. I haven't been in practical electronics for very long - enough to know the basics.

    Application:
    I want to put some sensors in and around the house. Various ones - from locking doors and windows, to checking if the dog or cat is sleeping in the shed to whether someone is roaming "behind the barn" for me or if the water tank is starting to get empty ;) . I have CCTV but it's not that and night IR lighting is a lot of power - it won't go on batteries. Ultimately the sensors are to run on a Li-Ion 18650 with DC-DC stepdown and an ESP8266 which will be woken up from deep-sleep by a signal from a still running sensor - as this one takes about 0.1mA .

    Current status:
    At the moment the ESP8266-01 communicates correctly with AT commands via FTDI232 (realterm @ Windows 7), the connection to the AP is established, I can change the IP etc. The module has NOT been updated, I bought 3 pieces for testing. I also supply 3.3V to the selected sensor, not yet connected.

    I want to recognise the sensor state change (and/or activate the ESP via GPIO15), send a message via LAN to the RPi and sedate the module until the next wake-up. On the Raspberry-Pi to process (I have no idea with what or how unfortunately) and generate a response - either in the form of a physical activation of e.g. the "alarm light" and bell, or in the form of an executive command to another ESP (e.g. activating a light, activating the unlocking of the cat door if RFID has been used on the sensor in the last 30s etc). I have a poorly stable WAN connection - maybe only as a remote 'view' of events, so all the 'services' fall away, so I need to think of a local solution. I saw a thread about "sockets" - but there someone wanted to do it commercially, had experience and didn't have the doubts as mine. There are a lot of different tutorials on the internet, but they are totally mixed up and usually out of date - both in terms of content and (expired) links, and unfortunately for me they mostly refer to cloud services which for me are out of the question.

    Doubts and questions:
    I have a problem with which environment to choose. I know that C, Phyton, LUA, Basic and Arduino are available for the ESP8266
    I don't know any of these languages, 30 years ago I used to write myself simple tools in BASIC on a ZX Spectrum, I very modestly programmed in Z80 assembler - unfortunately that was a long time ago and in the meantime I didn't use programming languages at all. On the one hand, the latter two are probably the simplest - on the other hand, I guess that both Arduino (IDE?) and Basic, due to the compiler/interpreter, can put unnecessary energy strain on the ESP module. Then there is the issue of availability of tutorials and the question - which updates and with what is best to upload? Unfortunately, it is not clear to me - this has changed a lot since the 8266 came out and gives the impression that some of the information is outdated. Without following it to the beginning, I get lost in this mass of content and don't know which one to look for.
    And for this, the "other side" would have to be matched - i.e. some server with a web interface (R-Pi ?) that will handle these events and "respond". Here I am completely out of ideas - maybe there are some LAN "ready-made" ones?

    I know I've done a lot of writing and no one will make the decision for me - but maybe they will at least put me on the right track.
  • ADVERTISEMENT
  • Helpful post
    #2 16201441
    tmf
    VIP Meritorious for electroda.pl
    Let's start with the end in mind, which is the platform. As I understand it, you want a system of distributed battery-powered cuzjs that can communicate with the server. If this is the case, there is a serious problem. The ESP takes a lot of power when running, as much as 200-300 mA. The battery will not last long. Another problem is temperature - LiIon do not work very well at low temperatures. In addition, most of them have a high self-discharge rate, so the battery may discharge itself after a few weeks. Of course, you can buy batteries that can operate at low temperatures, based on a different chemistry - e.g. LiFePO4, but this will still not solve the problem of current consumption. Hence, ZigBee was invented for such purposes, which takes microwatts and can run on batteries for years. Unfortunately the price is definitely higher.
  • ADVERTISEMENT
  • #3 16202676
    abyss
    Level 14  
    Power supply:
    tmf wrote:
    the problem is temperatures - LiIon don't work very well at low temperatures.
    I don't have a big problem here - I live in Ireland. I do almost continuous - as in every 10 mins temperature measurement and last year I had ~10 events(!) - that is less than 2 hours a year with temperatures below 0°C measured at a height of about 4 metres. It's cooler near the ground, but without checking in practice it's not easy to estimate by how much, snow or ice doesn't actually occur - I live not far from the ocean.
    If I were to use the popular 18650 then, using the HT7333 regulator (averaging about 0.42PLN per unit on ali), I have a supply voltage drop of 150mV after the regulator - to the needed value in the range of 3.2-3.4V, the regulator itself uses typically 4µA in "sleep", and the example PIR sensor HCSR501 (powered "in the middle of the board" 3.3V, so omitting its own 7133 regulator) - certainly below 50µA. If only a reed switch would be used as a sensor - this is already zero. ESP8266 in deep-sleep - supposedly about 15uA - so up to the order of 70µA in total in sleep and with 70mA during periods when it wakes up and communicates with the AP (that's how much I measured in working order, but without a hulking program). Let's say waking up and communicating is 20s. And this can be, for me, on average 1 event/hour, i.e. per day 24*20s=480s=8min=0.13h per day, i.e. the system will "consume" about 0.13h*70mA=9mAh per day+those "little things" of 2mAh in sleep. Even if this is 2-3 times more it will still be acceptable. Moisture and self-discharge - more likely the cause of the actual trouble.
    tmf wrote:
    you want to have a system of distributed battery-powered sensors that can communicate with the server. If so, there is a serious problem. The ESP takes a lot of power when running, as much as 200-300 mA. The battery won't last long.
    I wanted to wake up the detectors only at times when an event occurs - e.g. a door reed switch triggers, or a PIR puts out an H. That is, each ESP contacts the AP in the house. I wasn't thinking of a constantly running sensor mesh network, as that would actually be a battery killer. And definitely beyond my scope of knowledge at the moment.
    Wake-up:
    I want to solve the communication with something akin to some of the ideas shown by Andreas Spiess https://www.youtube.com/channel/UCu7_D0o48KbfhpEohoP7YSQ is his channel - especially in #101 @ 2:50-5:10. He uses the appearance of voltage on the switch as an "alarm clock" for the system - there is a sustained power supply using a MOS-FET, communication and once the task is done the system falls asleep until the next event. This would be ideal - I don't think I would have very many events - say with an average of one per hour. In #58 he also mentions a sketch that tells you when the battery needs replacing - which could be useful.

    However, for now, as I already have an ESP8266-01 communicating on the table (i.e. the simplest, blue one without a lot of GPIOs plugged in to wake it up - although I know it can be soldered) I want to focus on picking some environment in which I'll start combining something programmatically with the actual communication and "get around" the chip a bit. Maybe it would be able to save events sequentially in some sort of file on a network drive - I have a working 'USB drive' in my router for internet with samba, ftp, NAS connectivity.
  • Helpful post
    #4 16212105
    avrkwiat
    Level 10  
    For the ESP8266 you have several firmWare's. If you don't want to program then I guess the ESP Easy one is the easiest to use, because it is configurable from the website. But unfortunately I haven't tested it myself. I know that people configure it and hook it up to the RPI using what is called a Demoicz. I've never done that, because I'm a person who can program and doesn't mess around with some door-opening stuff.

    But as if you were tempted to do some programming and have more knowledge about processors and ESPs, here are my videos with free courses:

    Videos on ESP version 12 (currently the latest, later to be replaced by version 32):
    https://www.youtube.com/playlist?list=PLZQKTfr7_vvQcrrFVsnXTmXIBSDS9o1e2
    There you have everything on the specific firmware. AT command handling, how to upload firmware, how to write a desktop program, website, mobile app and probably at the weekend I'll show how to pick it up via an Atmege16 proxy.

    If you want to start programming processors, here's a list from AVR (atmega16) and arm (stm32f4xx) processors:
    https://www.youtube.com/playlist?list=PLZQKTfr7_vvQ32WG-JeBtw8Uq6G39n3mY

    If you want a C course, here's one:
    https://www.youtube.com/playlist?list=PLZQKTfr7_vvT7q8fuKLAJn_QN11ffyR3b

    Electronics basics here:
    https://www.youtube.com/playlist?list=PLZQKTfr7_vvRfyFuxuVbj3hGok2l7toAy

    I hope I have helped. Good luck in emigration ;)
    I've currently relocated/worked and have nothing to do at weekends, so I'm shooting video courses, with new ones popping up every now and then.
ADVERTISEMENT