from iota import * api = Iota('https://host', 'SampleSeed') pt = ProposedTransaction(address = Address('SampleOutput'), value = 100) in_addy = Address('SampleInput') # 0 or more ch_addy = Address('SampleChange') # 0 or 1 api.send_transfer(transfers = [ pt ], inputs = [ in_addy ], change_address = [ ch_addy ])
Tag: Python
How to Connect to a Network with Grove UART Wi-Fi in Raspberry Pi
1) Connect the module to the RPISER port.
2) Install the hat library.
3) Enable the UART.
4) Disable the serial console.
5) If you want to use the PL011 UART instead of the mini UART (recommended), add the pi3-disable-bt
or pi3-miniuart-bt
overlays to the device tree, and disable the hciuart
service.
6) Restart the Pi.
7) Run the following code:
import serial import time ser = serial.Serial('/dev/ttyAMA0', 115200) # or /dev/ttyS0 if using the mini UART ser.write('ATE0\r\n') # disable echo time.sleep(5) while ser.in_waiting > 0: if ser.readline() == 'OK\r\n': ser.write('AT+CWJAP_CUR="SampleNetwork","SamplePassword"\r\n') # connect to AP time.sleep(5) while ser.in_waiting > 0: if ser.readline() == 'OK\r\n': print "Connected!" break break
How to Get Voltage with a Grove Voltage Divider in Raspberry Pi
1) Connect the module to the A0 port.
2) Install the hat library.
3) Run the following code:
from grovepi import * import time PIN = 2 while True: print 3 * analogRead(PIN) * 5 / 1023.0 # 3 = dial switch voltage, 5 = input voltage time.sleep(1)
How to Measure Distance with a Grove Ultrasonic Ranger in Raspberry Pi
1) Connect the module to the D2 port.
2) Install the hat library.
3) Run the following code:
from grovepi import * import time PIN = 2 while True: print ultrasonicRead(PÌN) time.sleep(1)
How to Detect Touch on a Grove Touch Sensor in Raspberry Pi
1) Connect the module to the D2 port.
2) Install the hat library.
3) Run the following code:
from grovepi import * import time PIN = 2 while True: print digitalRead(PIN) time.sleep(1)
How to Get Temperature from a Grove Temperature Sensor in Raspberry Pi
1) Connect the module to the D2 port.
2) Install the hat library.
3) Run the following code:
from grovepi import * import time PIN = 0 while True: print temp(PIN, '1.2') # or another sensor version time.sleep(1)
How to Get Humidity from a Grove Temperature & Humidity Sensor in Raspberry Pi
1) Connect the module to the D2 port.
2) Install the hat library.
3) Run the following code:
from grovepi import * import time PIN = 2 while True: _, hum = dht(PIN, 0) print hum time.sleep(1)
How to Get Temperature from a Grove Temperature & Humidity Sensor in Raspberry Pi
1) Connect the module to the D2 port.
2) Install the hat library.
3) Run the following code:
from grovepi import * import time PIN = 2 while True: temp, _ = dht(PIN, 0) print temp time.sleep(1)
How to Get Sound Intensity from a Grove Sound Sensor in Raspberry Pi
1) Connect the module to the D2 port.
2) Install the hat library.
3) Run the following code:
from grovepi import * import time PIN = 0 while True: print analogRead(PIN) time.sleep(1)
How to Get Rotary Angle from a Grove Rotary Angle Sensor in Raspberry Pi
1) Connect the module to the A0 port.
2) Install the hat library.
3) Run the following code:
from grovepi import * import time PIN = 0 while True: v = analogRead(PIN) print ((v * 5 / 1023.0) * 300) / 5; # 5 = ADC reference voltage, 5 = hat voltage time.sleep(1)