-->
Page 5 of 6

Re: Reading a soil moisture sensor using a ESP-12-F

PostPosted: Thu Mar 03, 2016 10:18 am
by Dulag Utok
martinayotte wrote:Serial.read() is returning characters one by one of the string, not the actual integer value from sensor that you sent.
You need to acumulate all the characters until newline and then you can send it to Wifi client.
Code: Select all  char buf[64];
  int i = 0;
  if (Serial.available()) {
    int inByte = Serial.read();
    buf[i] = (char)inByte;
    if (inByte == '\r' or inByte == '\n' or i > (sizeof(buf) - 1)) {
      buf[i] = 0;
      i = 0;
      client.println(buf); // here we sent the whole line to the WiFi client
    }



ow wow. :) :) :) I'll try this one. thank you so much Mr. Martinayotte.

Re: Reading a soil moisture sensor using a ESP-12-F

PostPosted: Thu Mar 03, 2016 10:31 am
by Dulag Utok
ohw. it displays

Soil moisture: 9†þ?

this time, instead of a value at around 94.

Re: Reading a soil moisture sensor using a ESP-12-F

PostPosted: Thu Mar 03, 2016 11:30 am
by martinayotte
Maybe try it at slower baudrate ...

Re: Reading a soil moisture sensor using a ESP-12-F

PostPosted: Thu Mar 03, 2016 12:03 pm
by Dulag Utok
martinayotte wrote:Maybe try it at slower baudrate ...


slower baud rate for both esp and arduino? i tried lowering the baud rate of the arduino but still used the 115200 for the esp. doesn't work at all. Does this means i have to flash may esp with a firmware which has a slower baud rate?