CC300 weather station

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: CC300 weather station

Post by adafruit_support_mike »

The increase in code size probably has to do with 'sprint()'s floating point coversion code.

When you compile the code, the linker adds code from all the libraries you used, but a good linker will ignore any part of the library that doesn't actually get executed. When you used the '%s' target, the linker was able to ignore all of 'sprint()'s floating point conversion code, but when you switched to '%f', it was forced to include it.

Try this:

Code: Select all

    sprintf( 
        buffer, 
        "GET /submit.php?temp=%d.%d&hum=%d.%d&light=%d HTTP/1.0", 
        (int)t, (int)(t * 10) % 10,
        (int)h, (int)(h * 10) % 10,
        l
    );
It does the float-to-decimal conversion directly, so hopefully it will produce a smaller binary.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”