Skip to content

Instantly share code, notes, and snippets.

@luiszugasti
Created July 12, 2020 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luiszugasti/a6919524cc40b7ffee57dac575661f07 to your computer and use it in GitHub Desktop.
Save luiszugasti/a6919524cc40b7ffee57dac575661f07 to your computer and use it in GitHub Desktop.
A simple client that communicates with an arduino item via Serial monitor. Expect to find the code here when it goes public: https://github.com/luiszugasti/air_sens
from importlib import import_module
import os
import time
import arduinosensor
def main():
# open defined client
start_time = time.time()
while True:
reading = arduinosensor.get_values(os.environ.get('PORT', "/dev/ttyUSB0"))
arduinosensor.pub("python_client", payload=reading)
time.sleep(10.0 - ((time.time() - start_time) % 10.0))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment