Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4019) - 03 April 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Geting Cumulus Data fom PI Zero to ESP8266's

Talk about anything that doesn't fit elsewhere - PLEASE don't put Cumulus queries in here!
Post Reply
User avatar
e-monitor
Posts: 2
Joined: Wed 28 Sep 2016 4:03 pm
Weather Station: WH1080
Operating System: Linux/win10
Contact:

Geting Cumulus Data fom PI Zero to ESP8266's

Post by e-monitor »

Hi,
I am new to this but have been using Cumulus MX with my WH1080 for about a week and this is so easy to use, Thank You Cumulus Admin......

I have looked through the pages about hosting the data presented by Cumulus, the options are many, most of them require Host Computers or the WRT device, the Raspberry PI Zero has been running this software and posting the data to a free web space, with the PI Zero at £4 + WiFi @ £5 + USB2 Hub @ £3 + SD @ £3 you get a very capable host.

The USB hub is powered providing power to the PI.

I have for setup connected a USB Keyboard and mouse to configure WiFi via HDMI on the TV, then installed the basic Jessi build from https://www.raspberrypi.org/, Installed mono as per post(from sudo apt-get mono-complete), then downloaded the Cumulus MX to the pi home directory and ran it.

The FTP setup uploads realtimegauges.txt to a free website, this is then gathered by one of my ESP8266's and presented as a CORS Enabled JSON frame, allowing the data to be presented with other sensor data from the network of ESP's.

The basic Template Site... is here(uploaded by Cumulus from the PI Zero)
http://emonitor.16mb.com/index.htm

The ESP8266 Hosted data.....very simple layout...
http://82.5.78.180:5050/monitor

This is the basic code for the ESP it is using the Arduino IDE, the code is adapted from the Arduino Ethernet therefore it is very portable......

The fetch routine......

Code: Select all

void getfile() {
  delay(200);
   WiFiClient cl;

// The Start of the Routine to clollect the data...........
    // if you get a connection, GET the file
    if (cl.connect("emonitor.16mb.com", 80)) {  
    // Make a HTTP request:
    // send the HTTP GET request:
    cl.println("GET /realtimegauges.txt HTTP/1.1");
    cl.println("Host: emonitor.16mb.com");
    cl.println("User-Agent: arduino-ethernet");
    cl.println("Connection: close");
    cl.println();
    }
  while(!!!cl.available()) {
     yield();
  }
  while (cl.available()) {
    char c = cl.read();
// Use a marker for self constructed formats, I am using this as it works for stripping header and my files
    if (c == '{') {  // First Tag.....
// end of HTTP header, now save requested file 
// open the file for writing
  File theFile = SPIFFS.open("/realtime.txt", "w");  // change file name to write to here
  if (theFile) { // If we can open file write to it
  theFile.print("{");
  int Lc=0;    // we do not want to get stuck in the loop.....      
      while (cl.available()) {
        // stay in this loop until the file has been received

         String linew = cl.readStringUntil('\n');  // get data a line at a time to save memory
          theFile.println(linew);   // save data to file
    Lc++;
    if(Lc>=128){
      ESP.restart();      
     }
    }
   }
   theFile.close(); 
  }
 }
cl.flush();
cl.stop();
}
The Serving of the data.....

Code: Select all

if(sPath=="/realtime")
  {
    ulReqcount++;  // Counter for web requests
    
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: application/json");
                        client.println("Connection: close");
                         // client.println("Connection: keep-alive");
                        client.println("Access-Control-Allow-Origin: *");
                        client.println("Access-Control-Allow-Methods: GET");
                        client.println("Access-Control-Allow-Headers: Content-Type");
                        client.println("Access-Control-Max-Age: 500");
  
                        client.println();
                        // send web page/file
                        File thefile = SPIFFS.open("/realtime.txt", "r");        // open web page/file
                            while(thefile.available()) {
                               client.println(thefile.readStringUntil('\n')); // send web page/file to client
                              }
                              thefile.close();                                      
                        client.println();
}
This is a bit of the html I am using to gather data......

Code: Select all

<script>
$.ajax({
	 type: "GET",
	 url: "http://82.5.78.180/realtime",
	 async: false,
	 beforeSend: function(x) {
	  if(x && x.overrideMimeType) {
	   x.overrideMimeType("application/j-son;charset=UTF-8");
	  }
 },
 dataType: "json",
 success: function(data){
	  var items = [];
           var key1 = ["Time Sampled(UTC+1) ","Ext Temp Now(°C) ","Low Today(°C) ","High Today(°C) ","Int Temp(°C) ","Wind Speed (Mph)","Barometric Pressure(Mbar)","Rainfall Today(mm)","Ext Humidity(RH%)","Int Humidity(RH%)","Forecast For Today "];
	  $.each(data, function(key, val) {
      if (key=="date") {
         key=key1[0];
	    items.push("<tr><td> "+ key +" </td><td> " + val + " </td></tr> ");
         }
      if (key=="temp") {
         key=key1[1];
	    items.push("<tr><td> "+ key +" </td><td> " + val + " </td></tr> ");
         }
      if (key=="tempTL") {
         key=key1[2];
	    items.push("<tr><td> "+ key +" </td><td> " + val + " </td></tr> ");
         }
      if (key=="tempTH") {
         key=key1[3];
	    items.push("<tr><td> "+ key +" </td><td> " + val + " </td></tr> ");
         }
      if (key=="intemp") {
         key=key1[4];
	    items.push("<tr><td> "+ key +" </td><td> " + val + " </td></tr> ");
         }
      if (key=="wlatest") {
         key=key1[5];
	    items.push("<tr><td> "+ key +" </td><td> " + val + " </td></tr> ");
         }
      if (key=="press") {
         key=key1[6];
	    items.push("<tr><td> "+ key +" </td><td> " + val + " </td></tr> ");
         }
      if (key=="rfall") {
         key=key1[7];
	    items.push("<tr><td> "+ key +" </td><td> " + val + " </td></tr> ");
         }
      if (key=="hum") {
         key=key1[8];
	    items.push("<tr><td> "+ key +" </td><td> " + val + " </td></tr> ");
         }
      if (key=="inhum") {
         key=key1[9];
	    items.push("<tr><td> "+ key +" </td><td> " + val + " </td></tr> ");
         }
      if (key=="forecast") {
         key=key1[10];
	    items.push("<tr><td> "+ key +" </td><td> " + val + " </td></tr> ");
         }
	  });
	
	 // $('.my-new-list').remove();	


	  $('<ul/>', {
	    'class': 'my-new-list',
	    html: items.join('')
	  }).appendTo('#ESPS008');
 }
});
   </script>
Last edited by e-monitor on Fri 07 Oct 2016 7:26 am, edited 1 time in total.
User avatar
mcrossley
Posts: 12756
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Geting Cumulus Data fom PI Zero to ESP8266's

Post by mcrossley »

Well done getting it all working.
Post Reply