Elektroda.com
Elektroda.com
X
Elektroda.com

microLuna, this time egde AI in the electricity meter.

pixel7 2097 8
This content has been translated flag-pl » flag-en View the original version here.
  • microLuna, this time egde AI in the electricity meter.

    Good day.

    In reference to my previous construction Link I present another version of Luna.
    This time it was launched in 100% on ESP32 , with the task of fulfilling the assumptions of edge AI.

    The previous construction performed calculations on an additional device (rpi), now everything uses only the resources of the microprocessor.
    The software is based on the TensorFlow Lite library, which forced me to rebuild the network model (reducing the number of neurons).
    The layout has also changed slightly due to the SD card support, some of the ESP32cam pins overlap with those of the card. ADS was connected to the other legs.
    The system has a web interface in the form of a dashboard, with the possibility of reporting on events that have occurred.
    Refreshing the charts every 5 seconds, so basically a real-time preview.

    Model for a toddler

    Unfortunately, the ESP32 microprocessor has limited resources in relation to the "big brothers", which forces them to be properly managed.
    My network had to be drastically reduced and despite concerns about accuracy, I was able to reduce its size to 1208 neurons,
    while maintaining a decent detectability.

    Code: dos
    Log in, to see the code




    Instead of the previously analyzed 500 sec range, Luna now only sees 32.
    This causes differences in the time of indicating detected devices, sometimes it is simply too short a period to classify an unusual waveform.
    At the moment it is testing various layer topologies.
    According to the hint from the previous topic, I am trying to use a recursive LSTM network, so far without results - it does not achieve the same accuracy as the current one, and I have difficulties implementing it in tf Lite.

    Training - only for the big ones

    The network trains on pc. I don't know if it can be done on ESP, I'm afraid it would take quite a long time ...
    I did the learning in python using the previously built application and collected samples, but as it turns out they are too long [500] and the relevant data does not fit in the 32 sec range.
    I am not able to review and re-describe them, so I added to the software the functions of collecting new and saving them locally.
    After starting, a file is created with 32 samples of 32 values (full range is collected every second).

    microLuna, this time egde AI in the electricity meter.

    Swatches can be saved to existing ones or add a new category. Everything is stored on the SD card attached to the system.
    To make it easier, I added ftp support on the microprocessor which makes it easier to download data.
    Such a package can enrich the base for Luna and train her again.
    I also added a ready network uploader, which facilitates the upgrade, it is enough to select a properly generated .bin file (it can be done from the python level) and the system will start the new version after restart.

    microLuna, this time egde AI in the electricity meter.

    History with the flow

    I save the data every 120 seconds in the csv file - this window seems optimal at the moment, maybe a bit too long in relation to the 32 seconds of the buffer. I will see after a few days, I want to minimize the logs.
    Luna's website currently has a simple reporting system - a chart showing the above collected data.
    I am going to add filtering by period, device etc. If there was any sql or pandas on esp ...

    Screenshots showing the story below:

    microLuna, this time egde AI in the electricity meter. microLuna, this time egde AI in the electricity meter. microLuna, this time egde AI in the electricity meter.

    What's next?

    I will certainly develop both soft system and training.
    In line with the previous suggestions, I will add the MQTT protocol, so far I have focused on the egde AI technology development platform, which basically succeeded.
    I am already working on the next version, but it will be wearable ...

    p.

    Cool? Ranking DIY
    About Author
    pixel7
    Level 22  
    Offline 
    pixel7 wrote 481 posts with rating 61, helped 48 times. Live in city Warszawa. Been with us since 2007 year.
  • #2
    speedy9
    Helpful for users
    pixel7 wrote:
    The previous construction performed calculations on an additional device (rpi), now everything uses only the resources of the microprocessor.
    The software is based on the TensorFlow Lite library, which forced me to rebuild the network model (reducing the number of neurons).

    ESP32-S3 has support for neural networks. Have you thought about using this SoC version?
  • #3
    linuxtorpeda
    Level 26  
    Everything's fine, just:
    1) what for?
    2) did you know how other solutions regarding the classification of devices in the network are working? (e.g. using FFT)
    3) do you have an idea for commercialization of the above-mentioned devices?
  • #4
    khoam
    Level 41  
    pixel7 wrote:
    This time it was launched 100% on ESP32, with the task of fulfilling the assumptions of edge AI.

    " Edge AI is the deployment of AI applications in devices throughout the physical world. It's called "edge AI" because the AI computation is done near the user at the edge of the network, close to where the data is located, rather than centrally in a cloud computing facility or private data center . "

    The presented solution can hardly be called Edge AI. Rather, it is a system with an loaded, static ANN matrix with constant weight values. You might as well run it on an 8-bit processor (that's what I did over twenty years ago).

    pixel7 wrote:
    I don't know if it can be done on ESP, I'm afraid it would take quite a long time ..

    Can be. On each of the ESP series systems. It is best when it is S3 because it has the appropriate hardware acceleration (AI instructions). The manufacturer offers a library DL for the implementation of Edge AI projects. Network training usually takes place in a separate thread (and even on a dedicated core) during normal system operation.

    Little hint: In embedded environments, for serious applications using ANN, fixed-point arithmetic is used to represent ANN weight values. Calculations (network training) are then performed many times faster.

    Added after 17 [minutes]:

    pixel7 wrote:
    Swatches can be saved to existing ones or add a new category. Everything is stored on the SD card attached to the system.

    This is a misunderstanding. ESP systems may have sufficient NVSs available for this purpose.
  • #5
    pixel7
    Level 22  
    speedy9 wrote:
    ESP32-S3 has support for neural networks. Have you thought about using this version of SoC?

    Yes, but for now I'm building from what I have.

    linuxtorpeda wrote:
    1) what for?
    2) did you know how other solutions for the classification of devices in the network are working? (e.g. using FFT)
    3) do you have an idea for commercialization of the above-mentioned devices?


    1. For DIY presentations
    2. Yes, but for the moment I have to let go of my transformation.
    3. And there is such a chance?

    khoam wrote:
    "Edge AI is the deployment of AI applications in devices throughout the physical world. It's called" edge AI "because the AI computation is done near the user at the edge of the network, close to where the data is located, rather than centrally in a cloud computing facility or private data center. "

    The presented solution can hardly be called Edge AI. Rather, it is a system with an loaded, static ANN matrix with constant weight values. You might as well run it on an 8-bit processor (that's what I did over twenty years ago).


    At the beginning, as before, a request to add the sources of these quotes.
    The present one here comes from nvidia - Link

    Please indicate to me in the above where is the exclusion you are writing about? I mean "static ANN matrix with constant weight values". Nothing there describes topology, structure, or operation.
    In the margin: "computation is done near the user at the edge of the network, close to where the data is located" , in my case the transformers are located about 100 mm from the system ...

    In addition, if you scrolled through the source you quoted, and not take two sentences out of context, this diagram would appear to you:
    microLuna, this time egde AI in the electricity meter.
    You may not fully understand my description, forgive me.
    I will try to explain the explanation using the above (but from "right" to "left"):

    Pts. 4 - Luna on esp32 (instead of certified ... etc), supports ADC, counts streaming data, saves etc.
    Pts. 5-6 Luna saves and can transfer samples and results to DC - on an SD card (why - I'll explain further)
    The Data Center is my laptop and is also a Cloud - it supports points 1 and 2
    Using the built uploader (in the description), I send a CALCULATED network (with FIXED weights) to the ESP32, ACCORDING to point 3.
    We go back to point 4.

    Tell me where you see the error in my reasoning and why do you think that Luna does not correspond to these assumptions?
    You have now denied my statement, adding only your comments which are not reflected in the quoted text and its source.

    khoam wrote:
    You might as well run it on an 8-bit processor (that's what I did over twenty years ago).

    And so far we have not even seen a trace of this construction? It is a pity, I would have such an important point of reference.

    khoam wrote:
    pixel7 wrote:
    Swatches can be saved to existing ones or add a new category. Everything is stored on the SD card attached to the system.

    This is a misunderstanding. ESP systems may have sufficient NVSs available for this purpose.


    I understand that you were preparing training sets, working with databases and you were forced to easily browse, sort, filter, draw, correct and modify them? Certainly, the data in closed NVS memory is easier to play, for example, with pandas or excel or other tools than using a csv file on an SD card transferred from the prototype in a second.
    I usually make my tasks easier, but I can see that others prefer to build breakneck interfaces with the database versioning system (eps32 data = pc data).
    Really. This is a misunderstanding.
  • #6
    linuxtorpeda
    Level 26  
    pixel7 wrote:
    Yes, but for the moment I have to let go of my transformation.

    Which of the two solutions gives the best results, FFT or neural networks? I ask out of curiosity.

    pixel7 wrote:
    And is there such a chance?

    No, that's a rhetorical question :) That is why I personally gave up dealing with electronics after hours - you will earn as much as in any other industry, and the chances of your own business are zero.

    From myself I would like to add that in this type of projects I see more dangers than benefits. It's the perfect way to track our behavior with no apparent benefit to ourselves.
  • #7
    khoam
    Level 41  
    pixel7 wrote:
    At the beginning, as before, a request to add the sources of these quotes.
    The current one here comes from the nvidia website - Link

    True, but NVIDIA also borrowed this term.

    pixel7 wrote:
    You may not fully understand my description, forgive me.

    Perhaps, the description of this software on ESP32 is practically none. You have to guess many things.

    pixel7 wrote:
    And so far we have not even seen a trace of this construction? It is a pity, I would have such an important point of reference.

    At that time, I did not have an account on Elektroda yet, and besides, it was part of my job ...

    pixel7 wrote:
    Certainly, the data in closed NVS memory is easier to play, for example, in pandas or excel

    This memory is not "locked". Data can be sent in both directions via BLE or WiFi, as in the picture you posted in the last post - there is also no SD card reader on it. In contrast, communication between system components is two-sided and up to date .
    As a last resort, even USB can be used if:

    pixel7 wrote:
    By the way: "computation is done near the user at the edge of the network, close to where the data is located", in my case the transformers are located about 100 mm from the system ....

    Okay, so we're dealing with Desk Edge AI ;)

    I really don't want to argue. If you are satisfied with your project, this is the most important thing. EOT.
  • #8
    aadeer
    Level 14  
    How did you rate the accuracy of the network? You could describe it more precisely, because e.g. from what you have posted here you can see that the last layer has 8 neurons, or 8 outputs. It would be natural to treat them as equivalents of individual devices, but from the interface you can see that you only have 6 devices ... What does the probability mean for a given device? Do you convert it somehow? Are they just values for these output neurons scaled to the range 0 ... 100%? What happens when you connect a new device that you have not taught the network?

    On esp32 you rather have enough internal memory, partition sizes can be changed if necessary, there is the SqlLite3 library in the Arduino version that works on esp, although with proper column and tag / naming thought the use of csv files may be faster and sufficient, but what who likes ...

    I can see that there are also disputes about the names in this topic, unfortunately, colleagues who are "clinging" are right again :D

    And after adding MQTT, you can make a nice toy out of it and after integration with, for example, Home Assistant, you can set notifications that the water has boiled, washing started / finished or counted how many hours the wife watches TV :P
  • #9
    sweter_007
    Level 14  
    Hello.
    Old wolves bark at young wolves.
    There are five milling machines in the factory. Find a broken drill, please.
    Here you will need a shaft position sensor, a current sensor, a sound sensor.
    We also offer our production, a super expensive image processing sensor, for increased security, of course.
    We will interfere with the machine, a friend has a company who will study health and safety, write standards or a broken sensor will turn into a rocket by falling into the gears.
    But it will not be cheap, but it will be safe.
    Lubricants, temperature, difficult conditions, additional costs.
    Five machines a simple bill, four detectors times five costs.
    Old wolf how much together. How many zeros?

    Pukpuk, who's there. Young wolves, we're cutting costs. How many times. Ten times, sit down and talk.
    A contact box here, a g-code cable there.
    Five machines a simple bill, one can of a straight cable.
    Twenty machines simple bill ...

    Please detect the open refrigerator door in the supermarket ... etc etc. etc.
    Wolf to wolf to wolf. A new one is coming.