Created
July 12, 2020 21:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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