|  | 
| Edited by phyesix at 2017-2-13 18:32 
 I tried to translate the sample code in the forum you sent. For example:
 
 gpio.setup(PIN, gpio.IN, pull_up_down=gpio.PUD_UP)
 
 For example, how to translate this code block? My code block:
 
 
 Copy code#!/usr/bin/env python
from pyA20.gpio import gpio
from pyA20.gpio import port
from pyA20.gpio import connector
from time import sleep
def bin2dec(string_num):
    return str(int(string_num, 2))
   
data = []
#GPIO.setmode(GPIO.BCM)
PIN = port.PA6
gpio.init()
gpio.setcfg(PIN, gpio.OUTPUT)
gpio.output(PIN,gpio.HIGH)
sleep(0.025)
gpio.output(PIN,gpio.LOW)
sleep(0.02)
gpio.setup(PIN, gpio.IN, pull_up_down=gpio.PUD_UP)
for i in range(0,500):
    data.append(gpio.input(PIN))
   
   
bit_count = 0
tmp = 0
count = 0
HumidityBit = ""
TemperatureBit = ""
crc = ""
try:
   while data[count] == 1:
      tmp = 1
      count = count + 1
        
   for i in range(0, 32):
      bit_count = 0
      
      while data[count] == 0:
         tmp = 1
         count = count + 1
      while data[count] == 1:
         bit_count = bit_count + 1
         count = count + 1
      if bit_count > 3:
         if i>=0 and i<8:
            HumidityBit = HumidityBit + "1"
         if i>=16 and i<24:
            TemperatureBit = TemperatureBit + "1"
      else:
         if i>=0 and i<8:
            HumidityBit = HumidityBit + "0"
         if i>=16 and i<24:
            TemperatureBit = TemperatureBit + "0"
            
except:
   print "ERR_RANGE"
   exit(0)
   
try:
   for i in range(0, 8):
      bit_count = 0
      
      while data[count] == 0:
         tmp = 1
         count = count + 1
      while data[count] == 1:
         bit_count = bit_count + 1
         count = count + 1
      if bit_count > 3:
         crc = crc + "1"
      else:
         crc = crc + "0"
except:
   print "ERR_RANGE"
   exit(0)
      
      
Humidity = bin2dec(HumidityBit)
Temperature = bin2dec(TemperatureBit)
if int(Humidity) + int(Temperature) - int(bin2dec(crc)) == 0:
   print Humidity
   print Temperature
else:
   print "ERR_CRC"
 In the meantime, as in the following photo:
 
  
 
 | 
 |