Fatal error: avr/dtostrf.h: No such file or directory

I am trying to use my Arduino to Stream data via ethernet to Plot.ly but I have issues uploading the code.

This is the error:

C:\Program Files (x86)\Arduino\libraries\plotly_streaming_ethernet\plotly_streaming_ethernet.cpp:6:25: fatal error: avr/dtostrf.h: No such file or directory

 #include <avr/dtostrf.h>

                         ^

compilation terminated.

Here is the code I am trying to run

#include <SPI.h>
#include <Ethernet.h>
#include "plotly_streaming_ethernet.h"

// I change my tokens and API keys to something generic
// Plot.ly Tokens: 

#define nTraces 4


char *tokens[nTraces] = {"tokens1", "tokens2", "tokens3", "tokens4"};
// arguments: username, api key, streaming token, filename
plotly graph("Hohokam337", "API_KEYZ", tokens, "TITLE", nTraces);


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte my_ip[] = { 199, 168, 1, 177 }; // google will tell you: "public ip address"

void startEthernet(){
    Serial.println("... Initializing ethernet");
    if(Ethernet.begin(mac) == 0){
        Serial.println("... Failed to configure Ethernet using DHCP");
        // no point in carrying on, so do nothing forevermore:
        // try to congifure using IP address instead of DHCP:
        Ethernet.begin(mac, my_ip);
    }
    Serial.println("... Done initializing ethernet");
    delay(1000);
}


void setup() {
  graph.maxpoints = 100;
  // Open serial communications and wait for port to open:
  Serial.begin(9600);

  startEthernet();
  
  graph.fileopt="overwrite";
  bool success;
  success = graph.init();
  if(!success){while(true){}}
  graph.openStream();
}

int SV, WV;

void loop() {
 
float SI = 0;{
  for(int i = 0; i < 1000; i++) {
    SI = SI + (.0264 * analogRead(A0) -13.51) / 1000;}
}
float WI = 0;{
  for(int i = 0; i < 1000; i++) {
    WI = WI + (.19 * analogRead(A0) -25) / 1000; }
}

  SV = (analogRead(A0)*.239);
  WV = (analogRead(A3)*.325);
  graph.plot(millis(), SV, tokens[0]);
  graph.plot(millis(), SI, tokens[1]);
  graph.plot(millis(), WV, tokens[2]);
  graph.plot(millis(), WI, tokens[3]);

}

Searching for a solution hasn't helped at all.

Any direction will be greatly appreciated

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here using code tags.

Here is the exact error:

Arduino: 1.6.10 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Program Files (x86)\Arduino\libraries\plotly_streaming_ethernet\plotly_streaming_ethernet.cpp:6:25: fatal error: avr/dtostrf.h: No such file or directory

 #include <avr/dtostrf.h>

                         ^

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Wow, what a complete joke plot.ly is! The most simple, stupid, easy to fix bug but instead of spending 2 minutes fixing it they spend the same amount of time to add to their documentation:

Note: this library doesn't work with the latest Arduino IDE. Use 1.0.3 (for WiFi) or 1.0.5 for other shields. See avr/dstrtof.h No such file or directory in Arduino 1.6 · Issue #38 · plotly/arduino-api · GitHub for more details

I'd look for another option. If you really want to use this garbage then you can find the solution at the link above.

Yeah, I've gone through all the other options they suggested except this one. I was trying to avoid installing an older version of the IDE.

Do you have a preferred site similar to plot.ly? I've was trying to use Xively but it was equally frustrating.

Thank you for helping out!

The only thing similar I've used is Google Spreadsheets via Temboo. It was kind of a pain getting it set up but after that it worked well for me.

Thanks, I checked out Temboo, looks like it only supports the Yun or a Bluetooth board. I haven't worked with a Yun board but I'll check it out.

Thank you!

It's not very well documented, but you can use the Temboo library with anything that creates a standard Client object, such as the Ethernet library. You just pass the client object to the constructor. I haven't used it with Ethernet but I have used it with the ESP8266WiFi library and the WiFiEsp library.

Temboo has some code generator stuff on their website that makes it seem like it only works with a couple of boards but it's easy enough to adapt the example code to your needs.

If you do decide to go the Temboo/Google Spreadsheet path I can provide detailed instructions for how to set it up that I wrote for a friend of mine last year.

There well may be other, better options, Temboo/Google Spreadsheet was just the only thing I had experience with. I went the Temboo path because the friend that I wrote the code for was already using Temboo for another project so it seemed easier to stick with something they were familiar with and already had an account.

I think that function is declared in stdlib.h, not in its own include file. Try commenting out line 6 of: C:\Program Files (x86)\Arduino\libraries\plotly_streaming_ethernet\plotly_streaming_ethernet.cpp

// #include <avr/dtostrf.h>

If the function (not the file) is then undefined, add this line after the commented line:

#include <stdlib.h>
1 Like

pert:
It's not very well documented, but you can use the Temboo library with anything that creates a standard Client object, such as the Ethernet library. You just pass the client object to the constructor. I haven't used it with Ethernet but I have used it with the ESP8266WiFi library and the WiFiEsp library.

Temboo has some code generator stuff on their website that makes it seem like it only works with a couple of boards but it's easy enough to adapt the example code to your needs.

If you do decide to go the Temboo/Google Spreadsheet path I can provide detailed instructions for how to set it up that I wrote for a friend of mine last year.

There well may be other, better options, Temboo/Google Spreadsheet was just the only thing I had experience with. I went the Temboo path because the friend that I wrote the code for was already using Temboo for another project so it seemed easier to stick with something they were familiar with and already had an account.

I just got the Yun board today, and started to play around with Temboo I have it generating a code. I just have to adjust the sensor values to output the limits I set in Temboo.

I need to have 4 sensors read from digital pins but it only uses one to trigger?

for my case it if WV greater than or equal to 0 then it will read all sensors?? Am I understanding that right?

#include <Bridge.h>
#include <Temboo.h>
#include <limits.h>
#include "utility/TembooGPIO.h"
#include "TembooAccount.h" // Contains Temboo account information  
 
// The number of times to trigger the action if the condition is met
// We limit this so you won't use all of your Temboo calls while testing
int maxCalls = 10;

// The number of times this Choreo has been run so far in this sketch
int calls = 0;

// Declaring sensor configs
TembooGPIOConfig tmb_wvConfig;

// Declaring TembooSensors
TembooSensor tmb_wv;

// Choreo execution interval in milliseconds
unsigned long choreoInterval = 300000; 
// Store the time of the last Choreo execution
unsigned long lastChoreoRunTime = millis() - choreoInterval; 

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

  // For debugging, wait until the serial console is connected
  delay(4000);
  while(!Serial);
  Bridge.begin();
  
  // Initialize sensors and configs
  tembooAnalogGPIOInit(&tmb_wvConfig, &tmb_wv, A3, 0, INPUT);

  Serial.println("Setup complete.\n");
}

void loop() {
  if(millis() - lastChoreoRunTime >= choreoInterval) {
    int sensorValue = tmb_wv.read(&tmb_wvConfig);
    Serial.println("Sensor: " + String(sensorValue));
    if (sensorValue >= 0) {
      if (calls < maxCalls) {
        Serial.println("\nTriggered! Calling GeocodeByAddress Choreo...");
        runGeocodeByAddress(sensorValue);
        lastChoreoRunTime = millis();
        calls++;
      } else {
        Serial.println("\nTriggered! Skipping to save Temboo calls. Adjust maxCalls as required.");
      }
    }
  }

  if (millis() - lastChoreoRunTime >= ULONG_MAX - 10000) {
    lastChoreoRunTime = millis() - choreoInterval;
  }
  delay(250);
}

void runGeocodeByAddress(int sensorValue) {
  TembooChoreo GeocodeByAddressChoreo;

  // Invoke the Temboo client
  GeocodeByAddressChoreo.begin();

  // Set Temboo account credentials
  GeocodeByAddressChoreo.setAccountName(TEMBOO_ACCOUNT);
  GeocodeByAddressChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
  GeocodeByAddressChoreo.setAppKey(TEMBOO_APP_KEY);

  // Set Choreo inputs
  GeocodeByAddressChoreo.addInput("Address", "3424 N Oilver St Samsquanch TX 76232");
  // Identify the Choreo to run
  GeocodeByAddressChoreo.setChoreo("/Library/Google/Geocoding/GeocodeByAddress");

  // Run the Choreo
  unsigned int returnCode = GeocodeByAddressChoreo.run();

  // Read and print the error message
  while (GeocodeByAddressChoreo.available()) {
    char c = GeocodeByAddressChoreo.read();
    Serial.print(c);
  }
  Serial.println();
  GeocodeByAddressChoreo.close();
}