to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' import time import grovepi # Connect the Grove Accelerometer (+/- 1.5g) to any I2C port eg. I2C-1 # Can be found at I2C address 0x4c # SCL,SDA,VCC,GND while True: try: print(grovepi.acc_xyz()) time.sleep(.5) except IOError: print ("Error")
import time import grovepi # Connect the Grove Accelerometer (+/- 1.5g) to any I2C port eg. I2C-1 # Can be found at I2C address 0x4c # SCL,SDA,VCC,GND test = grovepi.acc_xyz() print test[0]
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' import time import grovepi # Connect the Grove Accelerometer (+/- 1.5g) to any I2C port eg. I2C-1 # Can be found at I2C address 0x4c # SCL,SDA,VCC,GND while True: try: print(grovepi.acc_xyz()) time.sleep(.5) except IOError: print("Error")
import grovepi import time import smbus import RPi.GPIO as GPIO rev = GPIO.RPI_REVISION if rev == 2 or rev == 3: bus = smbus.SMBus(1) else: bus = smbus.SMBus(0) def acc_xyz2(): bus.write_i2c_block_data(0x04, 1, [20]+[0, 0, 0]) time.sleep(.1) bus.read_byte(0x04) number = bus.read_i2c_block_data(0x04, 1) if number[1] > 32: number[1] = - (number[1] - 224) if number[2] > 32: number[2] = - (number[2] - 224) if number[3] > 32: number[3] = - (number[3] - 224) return (number[1], number[2], number[3]) for i in range(0,60): print "%.3f , %.3f , %.3f" %(grovepi.acc_xyz()) time.sleep(1)
import grovepi import time import smbus import RPi.GPIO as GPIO rev = GPIO.RPI_REVISION if rev == 2 or rev == 3: bus = smbus.SMBus(1) else: bus = smbus.SMBus(0) def acc_xyz2(): bus.write_i2c_block_data(0x04, 1, [20] + [0, 0, 0]) time.sleep(.1) bus.read_byte(0x04) number = bus.read_i2c_block_data(0x04, 1) if number[1] > 32: number[1] = -(number[1] - 224) if number[2] > 32: number[2] = -(number[2] - 224) if number[3] > 32: number[3] = -(number[3] - 224) return (number[1], number[2], number[3]) for i in range(0, 60): print "%.3f , %.3f , %.3f" % (grovepi.acc_xyz()) time.sleep(1)
[temp, humi] = grovepi.dht(dht11_port, 0) print(temp, "C") print(humi, "%") # Light Sensor light_value = grovepi.analogRead(light_sensor) print("light_value = %d" % (light_value)) print("Done") # Accelerometer acc_value = grovepi.acc_xyz() print("acc", acc_value) # Broadcast Payload payload = { 'airQuality': air_quality, 'airValue': sensor_value, 'distance': dist_value, 'humi': humi, 'temp': temp, 'lightValue': light_value, 'accelerometer': acc_value } requests.post(url, data=payload)
#!/usr/bin/env python # # GrovePi Example for using the Grove I2C 3-axis Accelerometer (http://www.seeedstudio.com/wiki/Grove_-_3-Axis_Digital_Accelerometer(%C2%B11.5g)) # # The GrovePi connects the Raspberry Pi and Grove sensors. You can learn more about GrovePi here: http://www.dexterindustries.com/GrovePi # # Have a question about this example? Ask on the forums here: http://www.dexterindustries.com/forum/?forum=grovepi # # LICENSE: # These files have been made available online through a [Creative Commons Attribution-ShareAlike 3.0](http://creativecommons.org/licenses/by-sa/3.0/) license. import time import grovepi # Connect the Grove Accelerometer (+/- 1.5g) to any I2C port eg. I2C-1 # Can be found at I2C address 0x4c # SCL,SDA,VCC,GND while True: try: print grovepi.acc_xyz() time.sleep(.5) except IOError: print "Error"
import time import grovepi # Connect the Grove Accelerometer (+/- 1.5g) to any I2C port eg. I2C-1 # Can be found at I2C address 0x4c # SCL,SDA,VCC,GND while True: try: print grovepi.acc_xyz() time.sleep(.5) except IOError: print "Error"