![]() Put the measurement in a separate function. That caused to effectively make only one reading and resulted in the factor 10 error. The sensor needs a handshake to get started and that is not used in the loop (of 10 readings). You might want to check - Arduino Playground - MultiMap - to create an interpolating lookup tableĭid some investigation why there was this factor 10 in the code and concluded there is a bug in the code I posted. So we can add a correction factor #include ĭistance = 1.38/1.52 * distance // correction factor = (wanted/measured) You should now read 1.52 meter while it is 1.38 meter So adjust the formula to match in the order of magnitude. The pulse time is twice the distance (forth and back). (in air above water it is higher due to the humidity - don't know how much) Speed of sound is 330 meter/second in normal air. Probably the formula distance = distance * 0.001657 is not right? ![]() Serial.print(distance, 2) // two decimal places Serial.println(nivel_agua) // reuse char array Serial.begin(115200) // use fastest serial possibleĭistance = distance*0.001657 // 10 measurements means another divider!! It takes a long time to update and says it measures 18.84 meters. I tried the code should be updated every 100 milliseconds or 1 second. Enviamos los datos medidos a traves del puerto serie y al display LCD el tiempo que transcurre hasta que sea LOW (Cuando la lectura del pin sea HIGH medira Adquirimos los datos y convertimos la medida a metrosĭistance=pulseIn(echo,HIGH) // Medimos el ancho del pulso Enviamos una señal activando la salida trigger durante 10 microsegundos No matter if the code, or just the HC-SR04 sensor is not very accurate as compared to other Ping))), SFR05, SFR08 and some more.Ĭonst String nivel_agua = "Nivel de agua:" If I had an earthquake understand the variation. In the variation ranges from 2 inches, sometimes 4. Using the code below, so you see, is not very accurate, ie, if I leave the HC-SR04 sensor activated and in a fixed location, such as the photo above, the fixed floor pointing at the ceiling. I was going to buy the SFR05 for 15 € but I thought better for the price. ![]() Using the HC-SR04 sensor which cost me less than 5 €.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |