Skip to content

Instantly share code, notes, and snippets.

@izzuddin91
Last active September 1, 2017 08:32
Show Gist options
  • Select an option

  • Save izzuddin91/ec234f0918c8608545b126f8344b4149 to your computer and use it in GitHub Desktop.

Select an option

Save izzuddin91/ec234f0918c8608545b126f8344b4149 to your computer and use it in GitHub Desktop.
calling currency api and send data through serial
import currencylayer
import serial
import time
exchange_rate = currencylayer.Client(access_key='eae8fe8c3b393cca980cf0252f876d5f')
a = exchange_rate.live_rates_for(currencies=['MYR'], base_currency='USD')
value = a['quotes']['USDMYR'] * 1000
ser = serial.Serial('/dev/ttyACM0',9600)
# tunggu 5 saat utk make sure ade mase utk connect ngan arduino, kalau x jadi laju sangat , x sempat nk pick up data
time.sleep(5)
s = [0]
ser.write(str(value))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment