logo elektroda
logo elektroda
X
logo elektroda

Creating 24h and 7 Days Sensor Data Charts Using Arduino, ESP8266 and DS18B20

pyton 7122 12
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16580092
    pyton
    Level 21  
    Hello

    I know Arduino not very well and WWW even less ... I'm not asking if it is possible but how to do it ...

    Namely, the heart of the system is Arduino, which I have TFT + SD display connected to, sensors e.g. DS18B20 and others, ESP8266, ...

    I know that ESP8266 is faster than Arduino but not everything at once ... (I work on ESP as an independent system but this is not my goal)

    I did this:
    I go to the address, for example: 192.168.1.1 I see a page where I have data from the sensors, the page refreshes itself automatically at a given time. It's OK but I wanted to expand it.

    I want to add charts from the last 24h and from e.g. 7 days. (interval is probably not a problem)

    Knocks what I got (excerpt):

    Code: C / C++
    Log in, to see the code


    I have the page title, it refreshes, it draws the frame nicely and the sensor data in it.

    However, I would like to include a graph of sensor data next to it.
    The problem is that Arduino is learning recently and WWW while doing a "project" ...

    I apologize in advance for not giving all the code but knocks what I can not ...

    At the beginning I wanted to save data on the SD card as a series of data readable for Excel ... then I could open the data from the SD card by Excel on a computer ...

    However, I would like to create a chart on the web depending on [t / x] and I don't know how to send it via ESP8266 to the browser ...

    Please help me some links ... anything ...

    best regards
  • ADVERTISEMENT
  • Helpful post
    #2 16581591
    TechEkspert
    Editor
    It would be simpler if ESP has access to the Internet, then you can send measurement data "to the cloud" and using free services on sites like https://thingspeak.com/ view generated charts on devices with internet access, examples here: http: / /www.elektroda.pl/rtvforum/topic3357545.html

    You can also send to your solution also providing data on the Internet, e.g. https://www.elektroda.pl/rtvforum/topic3294262.html

    Another solution might be to use google charts: https://diyprojects.io/esp8266-web-server-part-5-add-google-charts-gauges-and-charts
    http://www.instructables.com/id/Online-Graphs-Using-Nothing-but-an-Arduino-Etherne/
  • ADVERTISEMENT
  • Helpful post
    #3 16581716
    Anonymous
    Level 1  
  • Helpful post
    #4 16581883
    korteksik
    Level 10  
    Quote:
    ... However, I would like to create a chart on the web depending on [t / x] and I don't know how to send it via ESP8266 to the browser ...
    Please help me some links ... anything ...


    In Elektronika Praktyczna no. 3/2017 on pp. 117-118 you have described step by step how to do it on one ESP8266 module.
  • #5 16582401
    pyton
    Level 21  
    Thank you all for your interest.

    About https://thingspeak.com/ I read a cool thing, however, you need internet access and you do not expect such ... At least for now ... However, I will not fail to test it one day.

    I also started reading about Google charts, but I haven't explored it yet.

    drobok
  • ADVERTISEMENT
  • #6 16588670
    TechEkspert
    Editor
    @drobok are there any examples of using this solution? This could be useful in some LAN applications and would work even without internet access.
  • ADVERTISEMENT
  • #8 16589256
    JacekCz
    Level 42  
    Yeah ... serving extensive AJAX (JS) data based on a few kilos of RAM, yeah ... this will work "very well". I built a makeshift booth and I can see how to turn it into a skyscraper.
  • #9 16589533
    Anonymous
    Level 1  
  • #10 16589544
    pyton
    Level 21  
    In general, I mean that. I want ESP to be as an AP without internet access. Maybe later I will implement it more, I will change it ... I haven't covered this canvas yet but it looks promising initially.
  • #11 16589793
    JacekCz
    Level 42  
    drobok wrote:
    Note that what you serve for canvas is the text itself - where is the extensive data? It is known that this is not a server, but one / two clients should handle this.


    I think that one pixel (also a larger structure, square, diagonal line, etc. ...) in text format costs more than an element that is part of the JPG / PNG chart. Sending via HTTP 1.1 without the length known in advance causes "chunking", "chunking" many libraries are missing or have errors etc. ... (HTTP 2 I don't know what's new - I don't think it went into simplification)

    Optimistically it can be presumed (ask the author for details) that the chart is XY, i.e. it can be analyzed from left to right (and never come back), which is not a fairy tale if / how it is described. Yes, but at the expense of something.
    In any other case, the input and output buffers will compete fiercely for RAM.

    EDIT: the memory of a "veteran", if it was a bitmap, this archaic PCX format has an extremely simple compression algorithm operating only on one image line, so there is hope for few buffers.
  • #12 16590045
    Anonymous
    Level 1  
  • #13 16593377
    krzbor
    Level 27  
    The easiest way to do this is using HTML5 canvas. specifically, you save results to the variable (javascript table). Knowing the frequency of saving the result (e.g. 15 minutes), it is enough to provide the number of minutes or seconds since the last measurement during the query (in another javascript variable). Then you can create a graph placed in real time (e.g. last point 7 minutes from now, previous: 7 + 15, 7 + 2 * 15 etc.). The chart itself should be painted using javascript (the browser will do it), which downloads subsequent results, scales them to the size of the canvas and then draws.
    It's best to create the whole first on your computer (it's a normal html page) and test there, and then transfer it to ESP.
    The problem may be remembering previous results - the simplest is to use RAM - unfortunately after reboot we will lose our chart. If we use EEPROM then we should consider the problem of numerous write cycles allowed in EEPROM ESP8266 - I have not found this number anywhere.

Topic summary

The discussion revolves around creating 24-hour and 7-day sensor data charts using Arduino, ESP8266, and DS18B20 sensors. Users explore various methods to visualize sensor data, including sending data to cloud services like ThingSpeak for chart generation, utilizing Google Charts, and employing HTML5 canvas for real-time graphing. Challenges include limited internet access, memory constraints of the Arduino, and the need for efficient data handling. Suggestions include using JavaScript libraries for dynamic graphics and storing data in EEPROM to retain information across reboots. The conversation emphasizes the importance of optimizing data transmission and refresh rates to accommodate the hardware limitations.
Summary generated by the language model.
ADVERTISEMENT