Go Down

Topic: UV sensor via wireless and data upload to the Internet (Read 3024 times) previous topic - next topic

PaulRB

"avr" is a trade mark of the manufacturer Atmel who make the chips in most Arduino. But they did not make the esp8266. So that library may not be available/suitable for esp. You need to find an equivalent library that is suitable.

Why not post your code so we can suggest how to fix it? Use code tags.

otronics

"avr" is a trade mark of the manufacturer Atmel who make the chips in most Arduino. But they did not make the esp8266. So that library may not be available/suitable for esp. You need to find an equivalent library that is suitable.

Why not post your code so we can suggest how to fix it? Use code tags.
OK - that explains it.

Here is my project code, followed by the .h and .cpp wifi files. I've not added individual settings to my code (ie/ wifi passwords etc) - just trying to get it to compile first.

PROJECT CODE:

Code: [Select]
#include <WiFi.h>
#include "plotly_streaming_wifi.h"

// Sign up to plotly here: https://plot.ly
// View your API key and streamtokens here: https://plot.ly/settings
#define nTraces 3
// View your tokens here: https://plot.ly/settings
// Supply as many tokens as data traces
// e.g. if you want to ploty A0 and A1 vs time, supply two tokens
char *tokens[nTraces] = {"25tm9197rz", "unbi52ww8a", "ibsfyg7qd8"};
// arguments: username, api key, streaming token, filename
plotly graph = plotly("workshop", "v6w5xlbx9j", tokens, "your_filename", nTraces);

// Setup UV Sensor (ML8511) Pins
int UVOUT = A0;
const byte REF_3V3 = A0;

int status = WL_IDLE_STATUS;     // the Wifi radio's status
char ssid[] = "wifi_network_name"; //  your network SSID (name)
char pass[] = "wifi_network_password"; // // your network password

void wifi_connect(){
    // attempt to connect using WPA2 encryption:
    Serial.println("... Attempting to connect to WPA network...");
    status = WiFi.begin(ssid, pass);
    // if you're not connected, stop here:
    if ( status != WL_CONNECTED) {
      Serial.println("... Couldn't get a WiFi connection, trying again");
      wifi_connect();
    }
    // if you are connected, print out info about the connection:
    else {
      Serial.println("... Connected to network");
    }
}

void setup() {

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // Initialize pinMode for UV Sensor
  pinMode(UVOUT, INPUT);
  pinMode(REF_3V3, INPUT);

  wifi_connect();

  graph.fileopt="overwrite"; // See the "Usage" section in https://github.com/plotly/arduino-api for details
  bool success;
  success = graph.init();
  if(!success){while(true){}}
  graph.openStream();
}

void loop() {

  int uvLevel = averageAnalogRead(UVOUT);
  int refLevel = averageAnalogRead(REF_3V3);
  float outputVoltage = 3.3 / refLevel * uvLevel;
  float uvIntensity = mapfloat(outputVoltage, 0.99, 2.9, 0.0, 15.0);

  Serial.print("MP8511 output: ");
  Serial.print(uvLevel);
  graph.plot(millis(), uvLevel, tokens[0]);

  Serial.print("MP8511 voltage: ");
  Serial.print(outputVoltage);
  graph.plot(millis(), outputVoltage, tokens[1]);

  Serial.print("UV Intensity (mW/cm^2): ");
  Serial.print(uvIntensity);
  graph.plot(millis(), uvIntensity, tokens[2]);

  delay(200);

}

//Takes an average of readings on a given pin
//Returns the average
int averageAnalogRead(int pinToRead)
{
  byte numberOfReadings = 8;
  unsigned int runningValue = 0;

  for(int x = 0 ; x < numberOfReadings ; x++)
    runningValue += analogRead(pinToRead);
  runningValue /= numberOfReadings;

  return(runningValue);
}

//The Arduino Map function but for floats
//From: http://forum.arduino.cc/index.php?topic=3922.0
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

otronics

.h file:

Code: [Select]
#ifndef plotly_streaming_wifi_h
#define plotly_streaming_wifi_h

#include "Arduino.h"
#include <avr/pgmspace.h>

#include <WiFi.h>

class plotly
{
    public:
        plotly(char *username, char *api_key, char* stream_tokens[], char *filename, int nTraces);
        WiFiClient client;
        bool init();
        void openStream();
        void closeStream();
        void reconnectStream();
        void jsonStart(int i);
        void jsonMiddle();
        void jsonEnd(char *token);

        void plot(unsigned long x, int y, char *token);
        void plot(unsigned long x, float y, char *token);

        int log_level;
        bool dry_run;
        int maxpoints;
        bool world_readable;
        bool convertTimestamp;
        char *timezone;
        char *fileopt;

    private:
        void print_(int d);
        void print_(unsigned long d);
        void print_(float d);
        void print_(char *d);
        void print_(const __FlashStringHelper* d);

        int len_(int i);
        int len_(unsigned long i);
        int len_(char *i);

        unsigned long fibonacci_;
        char *username_;
        char *api_key_;
        char** stream_tokens_;
        char *filename_;
        int nTraces_;

};
#endif

otronics

.cpp file:

PART 1 (had to split due to char limit)

Code: [Select]
#include "Arduino.h"
#include <WiFi.h>
#include "plotly_streaming_wifi.h"

#include <avr/dtostrf.h>
#include <avr/pgmspace.h>


plotly::plotly(char *username, char *api_key, char* stream_tokens[], char *filename, int nTraces)
  {
    log_level = 2;  // 0 = Debugging, 1 = Informational, 2 = Status, 3 = Errors, 4 = Quiet (// Serial Off)
    dry_run = false;
    username_ = username;
    api_key_ = api_key;
    stream_tokens_ = stream_tokens;
    filename_ = filename;
    nTraces_ = nTraces;
    maxpoints = 30;
    fibonacci_ = 1;
    world_readable = true;
    convertTimestamp = true;
    timezone = "America/Montreal";
    fileopt = "overwrite";
}

bool plotly::init(){
    //
    //  Validate a stream with a REST post to plotly
    //
    if(dry_run && log_level < 3){
        Serial.println(F("... This is a dry run, we are not connecting to plotly's servers..."));
    }
    else if(log_level < 3) {
        Serial.println(F("... Attempting to connect to plotly's REST servers"));
    }
    while ( !client.connect("plot.ly", 80) ) {
        if(log_level < 4){
            Serial.println(F("... Couldn\'t connect to plotly's REST servers... trying again!"));
        }
        fibonacci_ += fibonacci_;
        delay(min(fibonacci_, 60000));
    }
    fibonacci_ = 1;
    if(log_level < 3){} Serial.println(F("... Connected to plotly's REST servers"));
    if(log_level < 3){} Serial.println(F("... Sending HTTP Post to plotly"));
    print_(F("POST /clientresp HTTP/1.1\r\n"));
    print_(F("Host: plot.ly:80\r\n"));
    print_(F("User-Agent: Arduino/0.6.0\r\n"));

    print_(F("Content-Length: "));
    int contentLength = 126 + len_(username_) + len_(fileopt) + nTraces_*(87+len_(maxpoints)) + (nTraces_-1)*2 + len_(filename_);
    if(world_readable){
        contentLength += 4;
    } else{
        contentLength += 5;
    }
    print_(contentLength);
    // contentLength =
    //   44  // first part of querystring below
    // + len_(username)  // upper bound on username length
    // + 5   // &key=
    // + 10  // api_key length
    // + 7  // &args=[...
    // + nTraces*(87+len(maxpoints)) // len({\"y\": [], \"x\": [], \"type\": \"scatter\", \"stream\": {\"token\": \") + 10 + len(\", "maxpoints": )+len(maxpoints)+len(}})
    // + (nTraces-1)*2 // ", " in between trace objects
    // + 22  // ]&kwargs={\"fileopt\": \"
    // + len_(fileopt)
    // + 16  // \", \"filename\": \"
    // + len_(filename)
    // + 21 // ", "world_readable":
    // + 4 if world_readable, 5 otherwise
    // + 1   // closing }
    //------
    // 126 + len_(username) + len_(fileopt) + nTraces*(86+len(maxpoints)) + (nTraces-1)*2 + len_(filename)
    //
    // Terminate headers with new lines
    print_(F("\r\n\r\n"));

    // Start printing querystring body
    print_(F("version=2.3&origin=plot&platform=arduino&un="));
    print_(username_);
    print_(F("&key="));
    print_(api_key_);
    print_(F("&args=["));
    // print a trace for each token supplied
    for(int i=0; i<nTraces_; i++){
        print_(F("{\"y\": [], \"x\": [], \"type\": \"scatter\", \"stream\": {\"token\": \""));
        print_(stream_tokens_[i]);
        print_(F("\", \"maxpoints\": "));
        print_(maxpoints);
        print_(F("}}"));
        if(nTraces_ > 1 && i != nTraces_-1){
            print_(F(", "));
        }
    }
    print_(F("]&kwargs={\"fileopt\": \""));
    print_(fileopt);
    print_(F("\", \"filename\": \""));
    print_(filename_);
    print_(F("\", \"world_readable\": "));
    if(world_readable){
        print_("true");
    } else{
        print_("false");
    }
    print_(F("}"));
    // final newline to terminate the POST
    print_(F("\r\n"));

    //
    // Wait for a response
    // Parse the response for the "All Streams Go!" and proceed to streaming
    // if we find it
    //
    char allStreamsGo[] = "All Streams Go!";
    int asgCnt = 0; // asg stands for All Streams Go
    char url[] = "\"url\": \"http://plot.ly/~";
    char fid[4];
    int fidCnt = 0;
    int urlCnt = 0;
    int usernameCnt = 0;
    int urlLower = 0;
    int urlUpper = 0;
    bool proceed = false;
    bool fidMatched = false;

    if(log_level < 2){
        Serial.println(F("... Sent message, waiting for plotly's response..."));
    }
    if(!dry_run){
        char c;
        while(client.connected()){
            if(client.available()){
                c = client.read();

                if(log_level < 2) Serial.print(c);
                //
                // Attempt to read the "All streams go" msg if it exists
                // by comparing characters as they roll in
                //

                if(asgCnt == len_(allStreamsGo) && !proceed){
                    proceed = true;
                }
                else if(allStreamsGo[asgCnt]==c){
                    asgCnt += 1;
                } else if(asgCnt > 0){
                    // reset counter
                    asgCnt = 0;
                }

                //
                // Extract the last bit of the URL from the response
                // The url is in the form http://plot.ly/~USERNAME/FID
                // We'll character-count up through char url[] and through username_, then start
                // filling in characters into fid
                //

                if(log_level < 3){
                    if(url[urlCnt]==c && urlCnt < len_(url)){
                        urlCnt += 1;
                    } else if(urlCnt > 0 && urlCnt < len_(url)){
                        // Reset counter
                        urlCnt = 0;
                    }
                    if(urlCnt == len_(url) && fidCnt < 4 && !fidMatched){
                        // We've counted through the url, start counting through the username
                        if(usernameCnt < len_(username_)+2){
                            usernameCnt += 1;
                        } else {
                            // the url ends with "
                            if(c != '"'){
                                fid[fidCnt] = c;
                                fidCnt += 1;
                            } else if(fidCnt>0){
                                fidMatched = true;
                            }
                        }
                    }
                }
            }
        }
        client.stop();
    }
    if(!dry_run && !proceed && log_level < 4){
        Serial.println(F("... Error initializing stream, aborting. Try again or get in touch with Chris at chris@plot.ly"));
    }

    if(!dry_run && proceed && log_level < 3){
        Serial.println(F("... A-ok from plotly, All Streams Go!"));
        if(fidMatched){
            Serial.print(F("... View your streaming plot here: https://plot.ly/~"));
            Serial.print(username_);
            Serial.print(F("/"));
            for(int i=0; i<fidCnt; i++){
                Serial.print(fid[i]);
            }
            Serial.println(F(""));
        }
    }
    return proceed;

}
void plotly::openStream() {
    //
    // Start request to stream servers
    //
    if(log_level < 3){} Serial.println(F("... Connecting to plotly's streaming servers..."));
    char server[] = "arduino.plot.ly";
    int port = 80;
    while ( !client.connect(server, port) ) {
        if(log_level < 4) Serial.println(F("... Couldn\'t connect to servers... trying again!"));
        fibonacci_ += fibonacci_;
        delay(min(fibonacci_, 60000));
    }
    fibonacci_ = 1;
    if(log_level < 3){} Serial.println(F("... Connected to plotly's streaming servers\n... Initializing stream"));

    print_(F("POST / HTTP/1.1\r\n"));
    print_(F("Host: arduino.plot.ly\r\n"));
    print_(F("User-Agent: Arduino\r\n"));
    print_(F("Transfer-Encoding: chunked\r\n"));
    print_(F("Connection: close\r\n"));
    if(convertTimestamp){
        print_(F("plotly-convertTimestamp: \""));
        print_(timezone);
        print_(F("\"\r\n"));
    }
    print_(F("\r\n"));

    if(log_level < 3){} Serial.println(F("... Done initializing, ready to stream!"));
}

void plotly::closeStream(){
    print_(F("0\r\n\r\n"));
    client.stop();
}
void plotly::reconnectStream(){
    while(!client.connected()){
        if(log_level<4) Serial.println(F("... Disconnected from streaming servers"));
        closeStream();
        openStream();
    }
}

otronics

.cpp file:

PART 2

Code: [Select]
void plotly::jsonStart(int i){
    // Print the length of the message in hex:
    // 15 char for the json that wraps the data: {"x": , "y": }\n
    // + 23 char for the token: , "token": "abcdefghij"
    // = 38
    if(log_level<2) Serial.print(i+44, HEX);
    if(!dry_run) client.print(i+44, HEX);
    print_("\r\n{\"x\": ");
}
void plotly::jsonMiddle(){
    print_(", \"y\": ");
}
void plotly::jsonEnd(char *token){
    print_(", \"streamtoken\": \"");
    print_(token);
    print_("\"}\n\r\n");
}

int plotly::len_(int i){
    // int range: -32,768 to 32,767
    if(i > 9999) return 5;
    else if(i > 999) return 4;
    else if(i > 99) return 3;
    else if(i > 9) return 2;
    else if(i > -1) return 1;
    else if(i > -10) return 2;
    else if(i > -100) return 3;
    else if(i > -1000) return 4;
    else if(i > -10000) return 5;
    else return 6;
}
int plotly::len_(unsigned long i){
    // max length of unsigned long: 4294967295
    if(i > 999999999) return 10;
    else if(i > 99999999) return 9;
    else if(i > 9999999) return 8;
    else if(i > 999999) return 7;
    else if(i > 99999) return 6;
    else if(i > 9999) return 5;
    else if(i > 999) return 4;
    else if(i > 99) return 3;
    else if(i > 9) return 2;
    else return 1;
}
int plotly::len_(char *i){
    return strlen(i);
}
void plotly::plot(unsigned long x, int y, char *token){
    reconnectStream();
    jsonStart(len_(x)+len_(y));
    print_(x);
    jsonMiddle();
    print_(y);
    jsonEnd(token);
}
void plotly::plot(unsigned long x, float y, char *token){
    reconnectStream();

    char s_[15];
    dtostrf(y,2,3,s_);

    jsonStart(len_(x)+len_(s_)-1);
    print_(x);
    jsonMiddle();
    print_(y);
    jsonEnd(token);
}
void plotly::print_(int d){
    if(log_level < 2) Serial.print(d);
    if(!dry_run) client.print(d);
}
void plotly::print_(unsigned long d){
    if(log_level < 2) Serial.print(d);
    if(!dry_run) client.print(d);
}
void plotly::print_(float d){
    if(log_level < 2) Serial.print(d);
    if(!dry_run) client.print(d);
}
void plotly::print_(char *d){
    if(log_level < 2) Serial.print(d);
    if(!dry_run) client.print(d);
}
void plotly::print_(const __FlashStringHelper* d){
    if(log_level < 2) Serial.print(d);
    if(!dry_run) client.print(d);
}

PaulRB

Ok, I only spotted one use of dtostrf()
Code: [Select]
dtostrf(y,2,3,s_);

Fist, try just removing the #include. Maybe if we are lucky the function is defined elsewhere.

Failing that, try replacing the above with
Code: [Select]
sprintf(s_, "%5.3f", y);

However, you may have a bigger problem...

Code: [Select]
#include <avr/pgmspace.h>
This allows fixed strings to be held in flash instead of ram, by using the F() macro, as in
Code: [Select]

        Serial.println(F("... Attempting to connect to plotly's REST servers"));

This is done to save ram, but that's not such a problem on esp8266.

otronics

Sorry for the delay in reply.

Too many compatibility errors with boards, software etc.

I have come across this guide and it compiles fine: https://learn.sparkfun.com/tutorials/ml8511-uv-sensor-hookup-guide

I'm not sure what the end result is? Can the UV data be uploaded to Plot.ly?

Is there a way to make it upload via wi-fi if so?

Here is the code:

Code: [Select]
/*
 ML8511 UV Sensor Read Example
 By: Nathan Seidle
 SparkFun Electronics
 Date: January 15th, 2014
 License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

 The ML8511 UV Sensor outputs an analog signal in relation to the amount of UV light it detects.

 Connect the following ML8511 breakout board to Arduino:
 3.3V = 3.3V
 OUT = A0
 GND = GND
 EN = 3.3V
 3.3V = A1
 These last two connections are a little different. Connect the EN pin on the breakout to 3.3V on the breakout.
 This will enable the output. Also connect the 3.3V pin of the breakout to Arduino pin 1.

 This example uses a neat trick. Analog to digital conversions rely completely on VCC. We assume
 this is 5V but if the board is powered from USB this may be as high as 5.25V or as low as 4.75V:
 http://en.wikipedia.org/wiki/USB#Power Because of this unknown window it makes the ADC fairly inaccurate
 in most cases. To fix this, we use the very accurate onboard 3.3V reference (accurate within 1%). So by doing an
 ADC on the 3.3V pin (A1) and then comparing this against the reading from the sensor we can extrapolate
 a true-to-life reading no matter what VIN is (as long as it's above 3.4V).

 Test your sensor by shining daylight or a UV LED: https://www.sparkfun.com/products/8662

 This sensor detects 280-390nm light most effectively. This is categorized as part of the UVB (burning rays)
 spectrum and most of the UVA (tanning rays) spectrum.

 There's lots of good UV radiation reading out there:
 http://www.ccohs.ca/oshanswers/phys_agents/ultravioletradiation.html
 https://www.iuva.org/uv-faqs

*/

//Hardware pin definitions
int UVOUT = A0; //Output from the sensor
const byte REF_3V3 = A0; //3.3V power on the Arduino board

void setup()
{
  Serial.begin(9600);

  pinMode(UVOUT, INPUT);
  pinMode(REF_3V3, INPUT);

  Serial.println("ML8511 example");
}

void loop()
{
  int uvLevel = averageAnalogRead(UVOUT);
  int refLevel = averageAnalogRead(REF_3V3);

  //Use the 3.3V power pin as a reference to get a very accurate output value from sensor
  float outputVoltage = 3.3 / refLevel * uvLevel;

  float uvIntensity = mapfloat(outputVoltage, 0.99, 2.8, 0.0, 15.0); //Convert the voltage to a UV intensity level

  Serial.print("output: ");
  Serial.print(refLevel);

  Serial.print("ML8511 output: ");
  Serial.print(uvLevel);

  Serial.print(" / ML8511 voltage: ");
  Serial.print(outputVoltage);

  Serial.print(" / UV Intensity (mW/cm^2): ");
  Serial.print(uvIntensity);

  Serial.println();

  delay(100);
}

//Takes an average of readings on a given pin
//Returns the average
int averageAnalogRead(int pinToRead)
{
  byte numberOfReadings = 8;
  unsigned int runningValue = 0;

  for(int x = 0 ; x < numberOfReadings ; x++)
    runningValue += analogRead(pinToRead);
  runningValue /= numberOfReadings;

  return(runningValue); 
}

//The Arduino Map function but for floats
//From: http://forum.arduino.cc/index.php?topic=3922.0
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

otronics

Or, the other option is that I purchase a genuine Arduino and try the original code.

However, the IDE has to be an older version. Will this still work?

And if so, what Arduino and wi-fi module should I buy?

Thanks.

PaulRB

Quote
Too many compatibility errors with boards, software etc.
You gave up too soon, in my opinion. That code is probably a few dozen edits away from working. If that's too much for you, I'm not sure what to suggest. What you want to do is not beginner level stuff. It's not going to be easy, and you won't be able to achieve it without spending more time, being more determined and being prepared to learn to code.

otronics

You gave up too soon, in my opinion. That code is probably a few dozen edits away from working. If that's too much for you, I'm not sure what to suggest. What you want to do is not beginner level stuff. It's not going to be easy, and you won't be able to achieve it without spending more time, being more determined and being prepared to learn to code.
Point taken - let's get this sorted.

So, I am stuck on this error:

Code: [Select]

In file included from C:\Users\OTronics\Documents\Arduino\UV\UV.ino:2:0:

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi/plotly_streaming_wifi.h:5:26: fatal error: avr/pgmspace.h: No such file or directory

 #include <avr/pgmspace.h>

                          ^

compilation terminated.

exit status 1
Error compiling for board NodeMCU 0.9 (ESP-12 Module).

PaulRB

Delete that #include line, and then go through the rest of the code looking for lines like
Code: [Select]
client.println(F("xyz"));
including Serial.println and print_, and remove the F(...) so they look like
Code: [Select]
client.println("xyz");

But before you remove all the F(...) instances, try putting
Code: [Select]
#define F(x) x

otronics

The #include <avr/pgmspace.h> error seems to have been fixed.

I was then back to this error:

Code: [Select]

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:5:25: fatal error: avr/dtostrf.h: No such file or directory

 #include <avr/dtostrf.h>


I removed the #include line and it didn't work, so I tried your other suggestion replacing:

Code: [Select]
dtostrf(y,2,3,s_);

with

Code: [Select]
sprintf(s_, "%5.3f", y);

I now get this error:

Code: [Select]
Arduino: 1.8.5 (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, 4M (1M SPIFFS), v2 Prebuilt (MSS=536), Disabled, None, 115200"

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:4:3: error: expected unqualified-id before '{' token

   {

   ^

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp: In member function 'bool plotly::init()':

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:35:36: error: no matching function for call to 'min(long unsigned int&, int)'

         delay(min(fibonacci_, 60000));

                                    ^

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:35:36: note: candidates are:

In file included from c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\algorithm:62:0,

                 from C:\Users\OTronics\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266/Arduino.h:240,

                 from C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:1:

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4226:5: note: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)

     min(initializer_list<_Tp> __l, _Compare __comp)

     ^

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4226:5: note:   template argument deduction/substitution failed:

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:35:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'

         delay(min(fibonacci_, 60000));

                                    ^

In file included from c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\algorithm:62:0,

                 from C:\Users\OTronics\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266/Arduino.h:240,

                 from C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:1:

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4221:5: note: template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)

     min(initializer_list<_Tp> __l)

     ^

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4221:5: note:   template argument deduction/substitution failed:

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:35:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'

         delay(min(fibonacci_, 60000));

                                    ^

In file included from c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\algorithm:61:0,

                 from C:\Users\OTronics\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266/Arduino.h:240,

                 from C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:1:

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:239:5: note: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)

     min(const _Tp& __a, const _Tp& __b, _Compare __comp)

     ^

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:239:5: note:   template argument deduction/substitution failed:

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:35:36: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')

         delay(min(fibonacci_, 60000));

                                    ^

In file included from c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\algorithm:61:0,

                 from C:\Users\OTronics\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266/Arduino.h:240,

                 from C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:1:

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:193:5: note: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)

     min(const _Tp& __a, const _Tp& __b)

     ^

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:193:5: note:   template argument deduction/substitution failed:

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:35:36: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')

         delay(min(fibonacci_, 60000));

                                    ^

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp: In member function 'void plotly::openStream()':

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:208:36: error: no matching function for call to 'min(long unsigned int&, int)'

         delay(min(fibonacci_, 60000));

                                    ^

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:208:36: note: candidates are:

In file included from c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\algorithm:62:0,

                 from C:\Users\OTronics\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266/Arduino.h:240,

                 from C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:1:

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4226:5: note: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)

     min(initializer_list<_Tp> __l, _Compare __comp)

     ^

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4226:5: note:   template argument deduction/substitution failed:

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:208:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'

         delay(min(fibonacci_, 60000));

                                    ^

In file included from c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\algorithm:62:0,

                 from C:\Users\OTronics\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266/Arduino.h:240,

                 from C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:1:

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4221:5: note: template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)

     min(initializer_list<_Tp> __l)

     ^



otronics

Error continued:

Code: [Select]
c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algo.h:4221:5: note:   template argument deduction/substitution failed:

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:208:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'

         delay(min(fibonacci_, 60000));

                                    ^

In file included from c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\algorithm:61:0,

                 from C:\Users\OTronics\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266/Arduino.h:240,

                 from C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:1:

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:239:5: note: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)

     min(const _Tp& __a, const _Tp& __b, _Compare __comp)

     ^

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:239:5: note:   template argument deduction/substitution failed:

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:208:36: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')

         delay(min(fibonacci_, 60000));

                                    ^

In file included from c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\algorithm:61:0,

                 from C:\Users\OTronics\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266/Arduino.h:240,

                 from C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:1:

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:193:5: note: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)

     min(const _Tp& __a, const _Tp& __b)

     ^

c:\users\otronics\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2\xtensa-lx106-elf\include\c++\4.8.2\bits\stl_algobase.h:193:5: note:   template argument deduction/substitution failed:

C:\Users\OTronics\Documents\Arduino\libraries\plotly_streaming_wifi\plotly_streaming_wifi.cpp:208:36: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')

         delay(min(fibonacci_, 60000));

                                    ^

exit status 1
Error compiling for board NodeMCU 0.9 (ESP-12 Module).

PaulRB

OK, I just got it to compile...

I used your code from post #16. Then I downloaded the zip file from https://github.com/plotly/arduino-api and tried to add it as a library (Sketch-->Include LIbrary-->Add .ZIP library) but the zip has not been built correctly to allow that. So I extracted the 3 files from the plotly_streaming_wifi folder in the zip and saved them into the same folder as your code and re-started the IDE.

Then I commented out the lines "#include <avr/dtostrf.h>" and "#include <avr/pgmspace.h>" in plotly_streaming_wifi.cpp and "#include <avr/pgmspace.h>" in plotly_streaming_wifi.h. It then compiled. That was all I changed. I did not need to change the dtostrf or remove the F() macros. I can't test it for you.

I am using Arduino IDE 1.6.11 and the esp8266 boards package 2.3.0.

Those last errors you posted were strange. I am wondering if maybe you changed a code line you did not intend to, when you were making those other edits, and caused those errors by accident.

otronics

Thank you for this.

The code now compiles and it uploads.

I was using newer versions of everything but downgrading to the Arduino IDE 1.6.11 and the esp8266 boards package 2.3.0 fixed it.

I am in the process of trying to get it to upload data now.

In fact, I can't get it to connect to my network at present.

No doubt I'll be back here later!

Go Up