Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:iot-open:getting_familiar_with_your_hardware_rtu_itmo_sut:raspberrypi_rpi:sensors_and_sensing [2019/02/18 17:19]
Agrisnik
en:iot-open:getting_familiar_with_your_hardware_rtu_itmo_sut:raspberrypi_rpi:sensors_and_sensing [2019/03/12 20:51] (current)
oleg
Line 194: Line 194:
 ECHO = 29  # define an echo pin GPIO5 ECHO = 29  # define an echo pin GPIO5
  
-print "​Distance Measurement In Progress"​+print ("​Distance Measurement In Progress"​)
  
 GPIO.setup(TRIG,​ GPIO.OUT) ​    # set the GPIO4 as trigger output port GPIO.setup(TRIG,​ GPIO.OUT) ​    # set the GPIO4 as trigger output port
Line 201: Line 201:
 GPIO.output (TRIG,​False) GPIO.output (TRIG,​False)
  
-print "​Waiting for Sensor to Settle"​+print ("​Waiting for Sensor to Settle"​)
 time.sleep(2) time.sleep(2)
  
Line 217: Line 217:
 distance = pulse_duration*17150 distance = pulse_duration*17150
 distance = round(distance,​2) ​        # Calculating the distance distance = round(distance,​2) ​        # Calculating the distance
-print "​Distance:",​ distance, "​cm"​+print ("​Distance:",​ distance, "​cm"​)
 </​code>​ </​code>​
  
Line 249: Line 249:
 pirPin = 7; // Passive Infrared (PIR) sensor output is connected to the GPIO4 pin pirPin = 7; // Passive Infrared (PIR) sensor output is connected to the GPIO4 pin
  
-GPIO.setup(pirPin ,GPIO.IN);      ​# set the GPIO5 pin as echo input+GPIO.setup(pirPin ,​GPIO.IN) ​      ​# set the GPIO5 pin as echo input
    
 while 1: while 1:
   # read the digital value of the PIR motion sensor GPIO4   # read the digital value of the PIR motion sensor GPIO4
   pirReading = GPIO.input(pirPin) ​   pirReading = GPIO.input(pirPin) ​
-  print piReading;                ​# print out+  print (piReading)               # print out
    
   if pirReading == True:          # motion was detected   if pirReading == True:          # motion was detected
-    print ('​Motion Detected'​); +    print ('​Motion Detected'​) 
-  time.sleep(10);+  time.sleep(10)
 </​code>​ </​code>​
  
Line 288: Line 288:
 header = 67 header = 67
 print('​-'​*header) print('​-'​*header)
-print("​| {:17} | {:20} | {:20} |"​.format("​Accels [g'​s]", ​ +print("​| {:17} | {:20} | {:20} |"​.format("​Accels [g'​s]",​ " Magnet [uT]", "Gyros [dps]"​))
-      ​" Magnet [uT]", "Gyros [dps]"​))+
 print('​-'​*header) print('​-'​*header)
 for _ in range(10): for _ in range(10):
Line 459: Line 458:
 while True: while True:
     humidity, temperature = Adafruit_DHT.read_retry(11,​ 7) # read GPIO4 Pin 7     humidity, temperature = Adafruit_DHT.read_retry(11,​ 7) # read GPIO4 Pin 7
-    print 'Temp: {0:0.1f} C  Humidity: {1:0.1f} %'​.format(temperature,​ humidity)+    print ('Temp: {0:0.1f} C  Humidity: {1:0.1f} %'​.format(temperature,​ humidity))
  
 </​code>​ ((http://​www.circuitbasics.com/​how-to-set-up-the-dht11-humidity-sensor-on-an-arduino/​)) </​code>​ ((http://​www.circuitbasics.com/​how-to-set-up-the-dht11-humidity-sensor-on-an-arduino/​))
Line 492: Line 491:
 def callback (pin) def callback (pin)
   if GPIO.input (pin)   if GPIO.input (pin)
-    print "Sound detected!"​+    print ("Sound detected!"​)
   else:   else:
-    print "Sound detected!"​+    print ("Sound detected!"​)
   # activate when pin changed its state   # activate when pin changed its state
   GPIO.add_event_detect(pin,​GPIO_BOTH,​ bouncetime=300) ​   GPIO.add_event_detect(pin,​GPIO_BOTH,​ bouncetime=300) ​
Line 550: Line 549:
 def Print(x): def Print(x):
   if x == 1:   if x == 1:
-    print ''​ +    print (''​) 
-    print ' ​  ​*********'​ +    print (' ​  ​*********'​) 
-    print ' ​  * Safe~ *' +    print (' ​  * Safe~ *') 
-    print ' ​  ​*********'​ +    print (' ​  ​*********'​) 
-    print ''​+    print (''​)
     if x == 0:     if x == 0:
-      print ''​ +      print (''​) 
-      print ' ​  ​***************'​ +      print (' ​  ​***************'​) 
-      print ' ​  * Danger Gas! *' +      print (' ​  * Danger Gas! *') 
-      print ' ​  ​***************'​ +      print (' ​  ​***************'​) 
-      print ''​+      print (''​)
  
 def loop(): def loop():
Line 566: Line 565:
   count = 0   count = 0
   while True:   while True:
-    print ADC.read(0)+    print (ADC.read(0))
   
     tmp = GPIO.input(DO);​     tmp = GPIO.input(DO);​
     if tmp != status:     if tmp != status:
-      ​Print(tmp)+      ​print(tmp)
       status = tmp       status = tmp
       if status == 0:       if status == 0:
Line 646: Line 645:
 while x == 0: while x == 0:
   gps = ser.readline()   gps = ser.readline()
-  # print all NMEA strings +  # print (all NMEA strings) 
-  print gps+  print (gps)
   # check gps fix status   # check gps fix status
   if gps[1:6] == "​GPGSA":​   if gps[1:6] == "​GPGSA":​
Line 655: Line 654:
     if fix == 3:     if fix == 3:
       color = greenColor       color = greenColor
-   # print time, lat and long from #GPGGA string+   # print (time, lat and long from #GPGGA string)
     if gps[1 : 6] == "​GPGGA":​     if gps[1 : 6] == "​GPGGA":​
       # clear window       # clear window
en/iot-open/getting_familiar_with_your_hardware_rtu_itmo_sut/raspberrypi_rpi/sensors_and_sensing.txt · Last modified: 2019/03/12 20:51 by oleg
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0