SyP-

Untitled

Jul 9th, 2020
111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. cat /dev/ttyACM0 | head -1 > measure.txt
  4.  
  5. file=measure.txt
  6.  
  7. while read line ; do
  8.  
  9.          
  10.        s01=$( echo "$line" |cut -d\: -f1 )
  11.        s02=$( echo "$line" |cut -d\: -f2 )
  12.        s03=$( echo "$line" |cut -d\: -f3 )
  13.        s04=$( echo "$line" |cut -d\: -f4 )
  14. done < ${file}
  15.  
  16. #Calculos de conversion
  17.  
  18. hPa=`echo "0.015*($s01-4000)+850" | bc -l`
  19. T=`echo "0.009375*($s02-4000)+(-50)" | bc -l`
  20. Vocs=`echo "0.00625*($s03-4000)" | bc -l`
  21. PM10=`echo "0.025*($s04-4000)"  | bc -l`
  22.  
  23. #INSERTA VALOR RAW DESDE SENSORES
  24.  
  25. mysql -u sensor -p1234 -D mediciones -e "INSERT INTO measures (s01, s02, s03, s04) VALUES ($s01, $s02, $s03, $s04)"
  26.  
  27.  
  28.  
  29.  
  30. #INSERTA VALOR FISICO
  31.  
  32. mysql -u sensor -p1234 -D mediciones -e "INSERT INTO conversiones (hpa, temp, vocs, pm10 ) VALUES ($hPa, $T, $Vocs, $PM10)"
  33.  
  34. #mysql -u sensor -p1234 -D mediciones -e "select * from (SELECT * FROM measures order by id desc limit 10) sub order by id asc"
  35.  
  36.  
  37. ### Conversion de uA > hPa ó mbar
RAW Paste Data