mathiaspl20

generate_html.py

Oct 30th, 2016
138
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. import interrupt_client, MCP342X, wind_direction, HTU21D, bmp085, tgs2600, ds18b20_therm
  3. import database # requires MySQLdb python 2 library which is not ported to python 3 yet
  4. import time
  5.  
  6. pressure = bmp085.BMP085()
  7. temp_probe = ds18b20_therm.DS18B20()
  8. air_qual = tgs2600.TGS2600(adc_channel = 0)
  9. humidity = HTU21D.HTU21D()
  10. wind_dir = wind_direction.wind_direction(adc_channel = 0, config_file="wind_direction.json")
  11. interrupts = interrupt_client.interrupt_client(port = 49501)
  12.  
  13. db = database.weather_database() #Local MySQL db
  14.  
  15. wind_average = wind_dir.get_value(10) #ten seconds
  16.  
  17. print("Inserting...")
  18. #db.insert(humidity.read_temperature(), temp_probe.read_temp(), air_qual.get_value(), pressure.get_pressure(), humidity.read_humidity(), wind_average, interrupts.get_wind(), interrupts.get_wind_gust(), interrupts.get_rain())
  19. print(humidity.read_temperature())
  20. print("done")
  21.  
  22. interrupts.reset()
  23.  
  24. #write_html
  25. output = """<html><head></head><body>
  26. """+str(time.ctime())+"""<h3>Temperatur in Bodenn&auml;he:
  27. """+str(temp_probe.read_temp())+"""</h3><h3>Lufttemperatur:
  28. """+str(humidity.read_temperature())+"""</h3>
  29. </body></html>"""
  30.  
  31.  
  32. f = open('/var/www/NW2016/test.html','w')
  33. f.write(output)
  34. f.close()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×