Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By xtal
#38172 Should I put a delay after the last client.print(wpage) then issue client.flush() ?

I now have string to float problems

about 10 vars are floats, some of my test data is like float PH= 7.3 Cdeg = 25.7 etc

I tried float cdeg0 = std::stof(SerINP.substring(3,cx-1));

wifi-web-servbO.ino: In function 'void parseSerial()':
wifi-web-servbO:298: error: 'stof' is not a member of 'std'

wifi-web-servbO:301: error: cannot convert 'String' to 'int' in assignment
wifi-web-servbO:304: error: cannot convert 'String' to 'int' in assignment
wifi-web-servbO:307: error: cannot convert 'String' to 'float' in assignment
wifi-web-servbO:310: error: cannot convert 'String' to 'float' in assignment
wifi-web-servbO:319: error: 'class String' has no member named 'find'
wifi-web-servbO:320: error: 'TxBuf' was not declared in this scope

'stof' is not a member of 'std'
What to do? -- thanks in advance
User avatar
By martinayotte
#38173 No, I don't think client.flush is needed, and if I remember, if yo do it, it will also flush any response, so don't use it, and simply loop with all the chunks.

For std::stof, I don't know, I've never used it on ESP.
Did you try to do equivalent with sscanf() ?
User avatar
By xtal
#38347 have had no luck with canned FP stuff so wrote my own function that seems to be working fine..
Text --> ABC.DE
locate decimal pt. save substr ABC and DE into long y and long z modifier toInt()
use length of DE to create multiplier/divider [ie] 10 ^ length(DE) [ pow(10,stringx.length()) ]
len0 = 1 len1 = 10 len2 = 100 etc
long y = substr(ABC).toInt()
long z = substr(DE).toInt()
float = y * lenX
float = ( float + z) / lenX
User avatar
By xtal
#38456 Why does this simple code not work???? Arduino 1.6.5
Fails on ESP-13 and ESP-210
What am I doing wrong?

Code: Select all/*
test-------------- 
*/
String SerINP = "[c25.3/1770/43645/7.32/1.22]"; 
char SerialDone;
/*------------------------------------------------------------------*/
void setup()
  {  Serial.begin(115200);     
     SerialDone == 'R';    }    // enable receiving SerINP   
/*-------------------------------------------------------------------*/
void loop() 
{   int cycle;
    Serial.println("---get serial---");     
    SerialDone = 'R';
    SerialX();     

/*------------------------------------------------------------------*/
String SerialX()
 {
  Serial.println("serial avail");
  SerINP ="";
  delay(1000);
 }
/*------------------------------------------------------------------*/


This is what I get over and over.....
---get serial---
serial avail

Exception (28):
epc1=0x40100f92 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont
sp: 3ffef7d0 end: 3ffef9e0 offset: 01a0

>>>stack>>>
3ffef970: 3fffdc20 3ffee9b4 402020cc 3ffee9c0
3ffef980: 40106974 3ffee9ac 000003e8 402010a3
3ffef990: 0000001c 00000000 3ffee9ac 4020304c
3ffef9a0: 0001c200 00000000 3ffee9ac 40202011
3ffef9b0: 3fffdc20 00000000 3ffee9ac 40201fad
3ffef9c0: 00000000 00000000 00000000 40202115
3ffef9d0: 00000000 00000000 3ffee9c0 40100114
<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld