Online DAQ suggestions


+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    64

    Default Online DAQ suggestions

    Anyone have any suggestions for either an off the shelf solution or something with minimal development effort that will allow me to plug say 1 or 2 0-5V sensors into and allow me to bring up the readings online? I know there are cheap chinese wifi modules out there but aren't they tricky to setup... like the hosting interface/page?

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,748

    Default Re: Online DAQ suggestions

    an esp8266 server can be as simple as this, it reads the analogue pin every 20 sec once connected to a wifi net.
    it responds with the last read value to a get request from anywhere. the requester has the appropriate web page stored locally.
    using a GET request like this.

    be warned when you master this stuff you may chuck all your pic/pbp stuff in the hard waste.
    i'm turning everything into little servers. with ntp time keeping , ota updates no need for displays or icsp or serial ports
    it make pics stuff look awkward and very limited. you can mix and merge the data from multiple sources to get one dreamed of
    functionality

    function readdata() {
    $.get("http://yourhostname/t24")
    .done(function (data) {
    if (data) {
    tot = (data.data/ 10);
    $("#label").text( tot.toFixed(1));
    }
    }).fail(function () {
    console.log("The was a problem retrieving the total yield");
    });
    }


    Code:
    /*
      ESP8266 
      wemos d1  
    */
    
    
    #include <ESP8266WebServer.h>
    #include <ESP8266WiFiMulti.h>
    
    
    
    
    ESP8266WiFiMulti wifiMulti;
    ESP8266WebServer server(80);             // create a web server on port 80
    
    
    unsigned int lastsample , samplerate=20000;
    float rawdata;
    
    
    void setup() {
      Serial.begin(19200);
      WiFi.mode(WIFI_STA);
      wifiMulti.addAP("ssid1", "pass1");
      wifiMulti.addAP("ssid2", "pass2");
      Serial.println("Connecting Wifi...");
      while (wifiMulti.run() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
      }
      if (wifiMulti.run() == WL_CONNECTED) {
        Serial.println("");
        Serial.println("WiFi connected");
        Serial.println("IP address: ");
        Serial.println(WiFi.localIP());
      } 
      startServer();
    }
    
    
    void loop() {  
      if (millis() - lastsample > samplerate) {// things to do every 1 sec
        rawdata = analogRead(A0);
        lastsample=millis();
      }
      yield();
      server.handleClient();                      // run the server
    }
    
    
    void startServer() { // Start a HTTP server with a file read handler and an upload handler
      server.on ("/t24", T24H);
      server.onNotFound(handleNotFound);          // if someone requests any other file or page, go to function 'handleNotFound'
      server.begin();                             // start the HTTP server
      Serial.println("HTTP server started.");
    }
    /*__________________________________________________________SERVER_HANDLER__________________________________________________________*/
    void T24H() { 
      char buff[10];
      String gd = "{\"data\":"; 
        dtostrf( rawdata, 3, 1, buff);
        gd += buff;
      gd +="}";
      server.sendHeader("Access-Control-Allow-Origin", "*");
      server.sendHeader("Access-control-allow-headers", "Authorization, Content-Type,x-requested-with");
      server.sendHeader("Access-control-allow-methods", "GET,PUT,HEAD");
      server.sendHeader("Content-Type", " application/json");
      server.send(200, "application/json", gd);
    }
    
    
    void handleNotFound() { // if the requested file or page doesn't exist, return a 404 not found error      
        server.send(404, "text/plain", "404: File Not Found");  
    }
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    64

    Default Re: Online DAQ suggestions

    Thanks Richard, again, much appreciated.

    Cheers,

Similar Threads

  1. Getting Parallax PLX-DAQ to work with HSEROUT
    By dbachman in forum Serial
    Replies: 13
    Last Post: - 24th January 2011, 22:57
  2. Online Javascript games
    By T.Jackson in forum Off Topic
    Replies: 3
    Last Post: - 8th February 2008, 04:18
  3. 4 to 20 ma signal DAQ question
    By Snap in forum General
    Replies: 3
    Last Post: - 3rd October 2007, 18:53
  4. Most users ever online
    By NavMicroSystems in forum Off Topic
    Replies: 8
    Last Post: - 1st October 2007, 17:06
  5. Online webcam supplier needed
    By keithdoxey in forum Off Topic
    Replies: 0
    Last Post: - 26th March 2007, 23:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts