Coder Social home page Coder Social logo

dexterind / grovepi Goto Github PK

View Code? Open in Web Editor NEW
486.0 79.0 488.0 7.37 MB

GrovePi is an open source platform for connecting Grove Sensors to the Raspberry Pi.

Home Page: https://www.dexterindustries.com/grovepi/

License: Other

C++ 12.93% Shell 2.14% Python 46.46% Go 0.69% JavaScript 3.01% Makefile 0.42% Perl 5.41% C 9.78% C# 11.38% Java 5.88% Roff 0.79% Ruby 0.49% HTML 0.30% Rust 0.30%
raspberry-pi grove-sensors grovepi grovepi-board iot iot-platform

grovepi's Introduction

Modular Robotics (Dexter Industries) GrovePi Generic badge MIT license

Picture

The GrovePi is an open-source platform for connecting Grove Sensors to the Rasberry Pi. Create IoT (Internet of Things) devices and inventions without the need of soldering!

Its official API is written in Python, but it can also be interfaced with in other languages such as C, C#, Go and NodeJS. These other variations of the same library came from our contributors.

Getting Started

In order to quick install the GrovePi repository, open up a terminal and type the following command:

curl -kL dexterindustries.com/update_grovepi | bash

The same command can be used for updating the GrovePi to the latest version. For more details on how you can install/update your GrovePi, please check this README.

To install into a virtual environment, first active your virtualenv and type the following command:

curl -kL dexterindustries.com/update_grovepi | bash -s -- --user-local --bypass-gui-installation

To flash the latest firmware to the GrovePi, run

cd /home/pi/Dexter/GrovePi/Firmware
bash firmware_update.sh

Then, import the grovepi module and start playing with it. Its documentation can be found here.

The old guide on getting started with the GrovePi can be found here. It can still prove to be useful if you're unsure how the GrovePi has to be stacked on top of the Raspberry Pi, although it should be pretty obvious.

Support

Raspberry Pi Compatibility

The GrovePi is compatible with the Raspberry Pi models A, A+, B, B+, 2, and B3, B3+, A3+, and 4B.

Documentation

There is extensive documentation available

Scratch Support

Once you've done the above command, you can install Scratch support if you want it. This step is optional.

sudo bash /home/pi/Dexter/GrovePi/Script/install_scratch.sh

If your SD card has Scratch 2.0 installed on it, then this will install GrovePi support for it. GrovePi integration for Scratch 1.4 is also getting installed.

Want to use a sensor not in the library yet?

Ask us in the forums. Want to use the GrovePi in a language not currently supported? Ask and we will help.

Programming the GrovePi

The GrovePi can be programmed in Python, C, C#, Go, and NodeJS on the Raspberry Pi. Simply start with one of our example projects or example code.
The GrovePi uses an Arduino to interface between the Raspberry Pi and the Grove Sensors, and comes programmed with a standard firmware. The firmware can be rewritten from the Raspberry Pi.

Getting Help

Need help? We have a forum here where you can ask questions or make suggestions.

Getting Ideas

Need an idea to get started? We have a few project examples to get your creative juices flowing.

grovepi's People

Contributors

alanch-ms avatar awong1900 avatar cleoqc avatar cymplecy avatar davidone avatar dgkanatsios avatar dougseven avatar exadon avatar fhunleth avatar guruth avatar joemarshall avatar johnisanerd avatar k33g avatar karan259 avatar killingjacky avatar lanselambor avatar lucavallin avatar marcellobarile avatar mcauser avatar memetolsen avatar molexx avatar nikkoura avatar odubuc avatar patrickecleary avatar robertlucian avatar rpedersen avatar shoban94 avatar sitfit avatar the-alchemist avatar tkumata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grovepi's Issues

AggregateException was unhandled by user code in C# Project

Anyone else facing this:

I pulled down a clone of the GrovePi repo today and went to build a simple Blinky app in C# (using a Windows IoT Background Application template).

Everything builds fine, but when I try to run on Remote Machine and point to my RPi2, I get an AggregteException at the line of code indicated by my comment (DeviceFactory.cs lines 175-183):

private GrovePi BuildGrovePiImpl(int address)
{
    if (_device != null)
    {
        return _device;
    }

    /* Initialize the I2C bus */
    var settings = new I2cConnectionSettings(address)
    {
        BusSpeed = I2cBusSpeed.StandardMode
    };

    _device = Task.Run(async () =>
    {
        var dis = await GetDeviceInfo();

        // Create an I2cDevice with our selected bus controller and I2C settings
        var device = await I2cDevice.FromIdAsync(dis[0].Id, settings);
        return new GrovePi(device);
   }).Result; // EXCEPTION OCCURRED HERE
   return _device;
}

There is NO I2C jack in use - the only thing plugged into the GrovePi shield is an LED module in port D5 (I have also tried D4 to rule out the port). The code that is apparently invoking the above code is led = DeviceFactory.Build.Led(Pin.DigitalPin5);

Here is the call stack

GrovePi.dll GrovePi.DeviceBuilder.BuildGrovePiImpl(int address) Line 175
GrovePi.dll GrovePi.DeviceBuilder.DoBuild<GrovePi.Sensors.Led>(System.Func<GrovePi.GrovePi, GrovePi.Sensors.Led> factory) Line 158
GrovePi.dll GrovePi.DeviceBuilder.Led(GrovePi.Pin pin) Line 68
Blinky.winmd Blinky.StartupTask.Run(Windows.ApplicationModel.Background.IBackgroundTaskInstance taskInstance) Line 58

Here is the exception info

An exception of type 'System.AggregateException' occurred in mscorlib.ni.dll but was not handled in user code

System.AggregateException was unhandled by user code
  HResult=-2146233088
  Message=One or more errors occurred.
  Source=mscorlib
  StackTrace:
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
       at System.Threading.Tasks.Task`1.get_Result()
       at GrovePi.DeviceBuilder.BuildGrovePiImpl(Int32 address)
       at GrovePi.DeviceBuilder.DoBuild[TSensor](Func`2 factory)
       at GrovePi.DeviceBuilder.Led(Pin pin)
       at Blinky.StartupTask.Run(IBackgroundTaskInstance taskInstance)
  InnerException: 
       ErrorCode=-2147024865
       HResult=-2147024865
       Message=A device attached to the system is not functioning.

Failed to apply connection settings to the device.
       Source=""
       StackTrace:
            at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
            at GrovePi.DeviceBuilder.<>c__DisplayClass30_0.<<BuildGrovePiImpl>b__0>d.MoveNext()
       InnerException: 

cloning from raspberry pi

Hi Guys,
Doubt if this is a NEW issue but....
Trying to setup my Raspberry pi for grovepi and get message - Couldn't resolve host 'gitup.com' while accessing ...../GrovePi.git/info/refs
Thank you

Compass readings noise or error values

  • Test the grove_compass_example with a Grove compass sensor
  • Check the reading for the heading carefully
  • Rotate the compass 360 degrees with 90 degree increments and see what values do you get on the terminal
  • Current behavior: ~(80, 120 , 70, 90) degree, instead of (90,90,90,90) degree with the compass module

install.sh

Google.com is used to test internet connection, users in China won't be able to go beyond this.

Problem with GrovePi testing

Dear GrovePi-Crew,

First of all: thank you for your efforts to bring two wonderful worlds together: the grove-sensors and RaspberryPi!

I installed your script successfully at the Raspbian-OS.

I see the little green SMD-LED glowing at the GrovePi and after the command

“sudo i2cdetect -y 1” there is the correct output: “04” at the correct position.

But, when I run the script “grovepi_blink.py” the LED didn’t start blinking, instead there is the following error message:

pi@raspberrypi ~/Desktop/GrovePi/Software/Python $ python grovepi_blink.py

Traceback (most recent call last):

File "grovepi_blink.py", line 3, in

import grovepi

File "/home/pi/Desktop/GrovePi/Software/Python/grovepi.py", line 21, in

bus = smbus.SMBus(1)

IOError: [Errno 13] Permission denied

Perhaps its related with this(?):

I discovered one “anomaly”: when I boot the RasPi/GrovePi I see a short time this line

FATAL: Module spi-dev not found

Is it possible, that something during the installation went wrong?

Thanks in advance

Frank

GrovePI Humidity in C#

I have tried the C# example and I could get the temperature value with temperature & humidity sensor. How to access humidity value from the sensor? I couldn't find any method to get the humidity value.

Thanks

API of grovepi.read_i2c_block is unsafe and chashes grovepi.ultrasonicRead

read_i2c_block normally returns a list but in case of an IOError it returns -1 (int). This is extremely difficult to handle as one would had to test the return value of read_i2c_block.

One would have to use something like this:

number = read_i2c_block(address)
if type(number) is list:
     do something_usefull()
else:
  handle_error()

which is the same thing as catching the exception.
ultrasonicRead and all the other function I saw in grovepi.py use the function in unsafe manor:

def ultrasonicRead(pin):
        write_i2c_block(address, uRead_cmd + [pin, unused, unused])
        time.sleep(.2)
        read_i2c_byte(address)
        number = read_i2c_block(address)
        return (number[1] * 256 + number[2])

Which leads to an TypeError and the program to crash as one is not expecting an TypeError.

This also happens in the wild:
http://www.dexterindustries.com/forum/?topic=ultrasonic-ranger-1-0-broken/

It would be much clearer to just raise the IOError as this is what is happening as to convert it in an TypeError.

I have not checked all the other i2c routines maybe there are more problems like this.

Edit: Typo

Cannot build VS2015 project with grovepi nuget reference

Hello!

Installed the GrovePi nuget package into my c# windows iot backgroud task template. But I always get the following error:

APPX0702: Payload file [USER-Folder]\.nuget\packages\GrovePi\1.0.6\lib\uap10.0\GrovePi\Properties\client.winU.rd.xml' does not exist.

Anyone knows what the problem could be?

Best regards,
Christoph

grove_gps.py file output incorrect decimal degrees format

Hi,

While the latitude and longitude coordinates in decimal degrees is in the correct format on the screen, the decimal is moved to the left 2 positions in the output file, making them invalid decimal degree values.

Need to change:
s=str(t)+","+str(float(lat)/100)+","+str(float(long)/100)+"\n"

to

s=str(t)+","+str(float(lat))+","+str(float(long))+"\n"

thanks,

Chris

Version mismatch with Microsoft.VCLib

I have just downloaded the Visual Studio Project won VS2015 + Windows 10 up to date and I have the following error message.

DEP0810 : This app references Microsoft.VCLibs.140.00.Debug, version 14.0.22929.0, found in your SDK, but you have a higher version of Microsoft.VCLibs.140.00.Debug installed on the target machine, 14.0.23019.0. If you continue to run this application, it will run against the currently installed version, Microsoft.VCLibs.140.00.Debug, version 14.0.23019.0. Consider updating your SDK to match the version of Microsoft.VCLibs.140.00.Debug that is installed.

Celsius is spelled wrong

In Software\CSharp\GrovePi\Sensors\TemperatureAndHumiditySensor.cs Celsius is spelled Celcius

Installation Failure

Below are the error sections I receive when trying to install node-grovepi via npm:

gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Linux 3.18.7-v7+
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/node_modules/node-grovepi/node_modules/i2c
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
npm ERR! Linux 3.18.7-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "node-grovepi"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the i2c package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls i2c
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/pi/GrovePi/Practice/npm-debug.log

Grove pi Temperature/Humidty error in test python script and GrovePi.py

I followed the steps here it set up a Raspberry pi 2 for use with a Grove pi.
http://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/setting-software/
When plugging the Temperature and Humidity Sensor Pro into analog A0 and running the test script:
https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_temperature_sensor.py
I get the following error:
...
temp = grovepi.temp(sensor,'1.2')
File "/home/pi/GrovePi/Software/Python/grovepi.py", line 197, in temp
t = (float)(1 / (math.log(resistance / 10000) / bValue + 1 / 298.15) - 273.15)
ValueError: math domain error

I am certain my temp/humid sensor is a 1.2 (it says on it 1.2) and came with the grovepi hat.
Any ideas? Thanks!

Could not locate the bindings file.

Error: Could not locate the bindings file. Tried:
→ /data/jumpway/iot/node_modules/i2c-bus/build/i2c.node
→ /data/jumpway/iot/node_modules/i2c-bus/build/Debug/i2c.node
→ /data/jumpway/iot/node_modules/i2c-bus/build/Release/i2c.node
→ /data/jumpway/iot/node_modules/i2c-bus/out/Debug/i2c.node
→ /data/jumpway/iot/node_modules/i2c-bus/Debug/i2c.node
→ /data/jumpway/iot/node_modules/i2c-bus/out/Release/i2c.node
→ /data/jumpway/iot/node_modules/i2c-bus/Release/i2c.node
→ /data/jumpway/iot/node_modules/i2c-bus/build/default/i2c.node
→ /data/jumpway/iot/node_modules/i2c-bus/compiled/5.3.0/linux/arm/i2c.node
at bindings (/data/jumpway/iot/node_modules/bindings/bindings.js:88:9)
at Object. (/data/jumpway/iot/node_modules/i2c-bus/i2c-bus.js:4:28)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/data/jumpway/iot/node_modules/node-grovepi/grovepi.js:2:19)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/data/jumpway/iot/node_modules/node-grovepi/index.js:3:12)

Extraneous bus.read_byte commands?

In various functions in grovepi.py, there are what seem to me to be completely extraneous calls to read_byte, which can just be deleted. Or at least, deleting them doesn't seem to break anything for me.

e.g. in analogRead it says bus.read_byte(address), then it does the actual read transaction with number = bus.read_i2c_block_data(address, 1). As far as I can tell the bus.read_byte is totally ignored, just does an extra i2c transaction for no reason and makes the code slightly slower.

Maybe I'm missing something and there is a reason for it, but as far as I can tell this is a bug?

grove_version_check.py returns 255.255.255

Running the following command the scripts returns a strange value as version number:

pi@raspberrypi ~/GrovePi/Software/Python $ sudo python grove_version_check.py
255.255.255

Busy loop vs Interrupts?

I'm trying to build a clap sensor using the sound sensor module that switches lights on/off on double-clapping. However, due to the sleep in the analogRead, I miss claps from time to time. Increasing the sampling rate will result in a busy loop which is not good either. Is there a way that I can register to hardware timers / interrupts?

Make python groovepi library `pip` installable

Please make the library pip installable for easy access.

Step 1: Register to PyPI Live / PyPI Test

https://pypi.python.org/pypi?%3Aaction=register_form
https://testpypi.python.org/pypi?%3Aaction=register_form
Create accounts to both sites

Step 2: Create a .pypirc configuration file

Make sure that is located at ~/.pypirc and update with the right credentials

[distutils] 
index-servers =
  pypi
  pypitest

[pypi]
repository: https://pypi.python.org/pypi
username: {{your_username}} # HERE !!!
password: {{your_password}}  # HERE !!!

[pypitest]
repository: https://testpypi.python.org/pypi
username: {{your_username}}  # HERE !!!
password: {{your_password}}  # HERE !!!
Step 3: Folder structure
root-directory/   
  setup.py
  setup.cfg
  LICENSE.txt
  README.md
  groovepi/
    __init__.py
    groovepi.py
Step 4: setup.py
from distutils.core import setup
setup(
  name = 'groovepi',
  packages = ['groovepi'], # this must be the same as the name above
  version = '0.1',
  description = 'GrovePi is an open source platform for connecting Grove Sensors to the Raspberry Pi.',
  author = 'Dexter', # UPDATE HERE
  author_email = '[email protected]',  # UPDATE HERE
  url = 'https://github.com/DexterInd/GrovePi/tree/master/Software/Python'
  download_url = 'https://github.com/DexterInd/GrovePi/tarball/0.1'  # UPDATE HERE
  keywords = [ 'example'], ## UPDATE HERE
  classifiers = [],
) 

The download_url :
At master branch,
$ git tag 0.1 -m "Tag for PyPI."
$ git push --tags origin master
and you get a download_url with structure https://github.com/{username}/{module_name}/tarball/{tag}.

Step 5: Ttell PyPI where your README file is, setup.cfg,
[metadata]
description-file = README.md
Step 6: Don't forget LICENSE.txt
Step 7: Make the magic
# first PyPI Test to check setup
python setup.py register -r pypitest
python setup.py sdist upload -r pypitest
# Upload to PyPI Live
python setup.py register -r pypi
python setup.py sdist upload -r pypi

Running test programs using GrovePi+ board from idle Python 2 or 3

I can run without problem athe test program grove_relay.py from the command line : sudo python grove_relay.py

When I want to run it from idle python I get an error message when doing an import grovepi

bus = smbus-SMBus(1)
IOError: [Erno 13] Permission denied. .......

Questions
a) How to run from the command line python grove_relay.py not as SUDO?
or
b) from Idle, python grove_relay.py as SUDO when Running the program?

How to set up the corresponding right?

Thank you

Olivier

Simple robot project with Java support for some Grove modules

Hi,
I've built a simple driving robot called "Captain Picar" with the GrovePi and Java.
Here is the source: https://github.com/jbman/captain-picar

Anyone who is interested in using the GrovePi with Java might take it as an example. You may also add the generic code to the Software section of the GrovePi project (package com.github.jbman.jgrove).

The project amkes use of the pi4j I/O API and libraries project.
Currently there are classes for these Grove modules:

  • Button
  • Ultrasonic
  • MotorDriver
  • Lcd with RGB backlight
  • (Digital Gyro started, but it produces to many errors when reading the values)

Grove LCD and NodeJS

Hello,

I’m a newbie with GrovePi and I’ve understood how to extend AnalogicSensor to use sound sensor. But it becomes more complicated (for me) with Grove LCD and Leds. It would be fine to have some samples about LCD & leds.

Thank you

Regards
Philippe

Multiple Relays

We've bought three relays, and we use the following Python Class to interact with the relay (see attached file). Nothing complicated. It's just Python 3 and more object encapsulation.

The problem we have is that when we set off a relay, the two other relays also set off ! Which is not what we're expected.

For example:

r1 = Relay(5)
r2 = Relay(6)
r3 = Relay(7)

r1.on()
r2.on()
r3.off() # r1 and r2 are now off ...

We observed the same problem without the object encapsulation. And thus we suspect that the problem is coming from GrovePi.

Is it a know bug? Or is GrovePi intended to only work with one relay?

relay.py.txt

Grove Digital Accelerometer/Button/Touch are not working on Win 10 IoT Raspberry PI 2

Environment - Raspberry PI 2
OS - Windows 10 I0T Core
Sensor - Grove - 3-Axis Digital Accelerometer(±1.5g), Button and Touch

On below line...
DeviceFactory.Build.AccelerometerSensor(Pin.DigitalPin3).Read()
The excpetion is thrown as...
The thread 0xbb8 has exited with code 0 (0x0).
Exception thrown: 'System.IO.FileNotFoundException' in GrovePi.dll
WinRT information: Slave address was not acknowledged.
The program '[2652] XXX.exe' has exited with code -1 (0xffffffff).

Any known issue/help?

win10 Csharp SimpleDriver.cs occur Exception

This is the steps I run the code:
1)Download GrovePi and click GrovePi\Software\CSharp\GrovePi.sln to open the project with VisualStudio 2015.
2)Seeting SimpleDriver.cs as Startup Project,
3)Compile and deploy the project.
4)Exception happended after a few minutes.

'backgroundTaskHost.exe' (CoreCLR: DefaultDomain): Loaded 'c:\data\Programs\WindowsApps\Microsoft.NET.CoreRuntime.1.0_1.0.23430.0_arm__8wekyb3d8bbwe\mscorlib.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'backgroundTaskHost.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppxLayouts\GrovePiVS.Debug_ARM.lambor\Driver.winmd'. Symbols loaded.
'backgroundTaskHost.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppxLayouts\GrovePiVS.Debug_ARM.lambor\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'backgroundTaskHost.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppxLayouts\GrovePiVS.Debug_ARM.lambor\WinMetadata\Windows.winmd'. Module was built without symbols.
'backgroundTaskHost.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppxLayouts\GrovePiVS.Debug_ARM.lambor\GrovePi.dll'. Symbols loaded.
'backgroundTaskHost.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppxLayouts\GrovePiVS.Debug_ARM.lambor\System.Runtime.InteropServices.WindowsRuntime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'backgroundTaskHost.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppxLayouts\GrovePiVS.Debug_ARM.lambor\System.Threading.Tasks.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'backgroundTaskHost.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppxLayouts\GrovePiVS.Debug_ARM.lambor\System.Runtime.WindowsRuntime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x208 has exited with code 0 (0x0).
The thread 0xab0 has exited with code 0 (0x0).
Exception thrown: 'System.Runtime.InteropServices.COMException' in GrovePi.dll
WinRT information: Unexpected number of bytes was transferred. Expected: '. Actual: '.
Exception thrown: 'System.Runtime.InteropServices.COMException' in Driver.winmd
WinRT information: Unexpected number of bytes was transferred. Expected: '. Actual: '.
An exception of type 'System.Runtime.InteropServices.COMException' occurred in Driver.winmd but was not handled in user code
WinRT information: Unexpected number of bytes was transferred. Expected: '. Actual: '.
Additional information: The request could not be performed because of an I/O device error.

Unexpected number of bytes was transferred. Expected: '. Actual: '.

The thread 0xccc has exited with code 0 (0x0).
The program '[560] backgroundTaskHost.exe' has exited with code 1 (0x1).

Anyone got this exception?

Ruby

Is building a ruby framework on the timeline for GrovePi?

avrdude: Can't find programmer id "gpio"

Based on a post on the forums, this may be occurring because I installed the lastest version of Raspbian (Jessie). The blinking LED test program did not work, so I tried to upgrade the firmware and received the 'avrdude: Can't find programmer id "gpio"' error. Then I tried running the Troubleshooting program and received the same error. The above post mentioned work on fixing this problem was in beta for Raspian for Robots. When might those changes find their way into this GrovePi project?

Running test programs using GrovePi+ board from idle Python 2 or 3

I can run without problem athe test program grove_relay.py from the command line : sudo python grove_relay.py

When I want to run it from idle python I get an error message when doing an import grovepi

bus = smbus-SMBus(1)
IOError: [Erno 13] Permission denied. .......

Questions
a) How to run from the command line python grove_relay.py not as SUDO?
or
b) from Idle, python grove_relay.py as SUDO when Running the program?

How to set up the corresponding right?

Thank you

Not able to install npm package on Visual Studio

@marcellobarile

====Executing command 'npm install node-grovepi --save '====
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No license field.

[email protected] install C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools
node-gyp rebuild
C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
buffertools.cc
c:\users\rohit narayan\documents\visual studio 2015\projects\demonodeapp\demonodeapp\node_modules\node-grovepi\node_modules\buffertools\BoyerMoore.h(35): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
c:\users\rohit narayan\documents\visual studio 2015\projects\demonodeapp\demonodeapp\node_modules\node-grovepi\node_modules\buffertools\BoyerMoore.h(57): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
c:\users\rohit narayan\documents\visual studio 2015\projects\demonodeapp\demonodeapp\node_modules\node-grovepi\node_modules\buffertools\BoyerMoore.h(61): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
c:\users\rohit narayan\documents\visual studio 2015\projects\demonodeapp\demonodeapp\node_modules\node-grovepi\node_modules\buffertools\BoyerMoore.h(61): warning C4267: 'initializing': conversion from 'size_t' to 'const int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
c:\users\rohit narayan\documents\visual studio 2015\projects\demonodeapp\demonodeapp\node_modules\node-grovepi\node_modules\buffertools\BoyerMoore.h(62): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
c:\users\rohit narayan\documents\visual studio 2015\projects\demonodeapp\demonodeapp\node_modules\node-grovepi\node_modules\buffertools\BoyerMoore.h(62): warning C4267: 'initializing': conversion from 'size_t' to 'const int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
c:\users\rohit narayan\documents\visual studio 2015\projects\demonodeapp\demonodeapp\node_modules\node-grovepi\node_modules\buffertools\BoyerMoore.h(110): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
..\buffertools.cc(219): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
..\buffertools.cc(219): warning C4267: 'initializing': conversion from 'size_t' to 'const int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
..\buffertools.cc(220): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
..\buffertools.cc(220): warning C4267: 'initializing': conversion from 'size_t' to 'const int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
..\buffertools.cc(332): warning C4267: '=': conversion from 'size_t' to 'int32_t', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
..\buffertools.cc(334): warning C4267: '=': conversion from 'size_t' to 'int32_t', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
..\buffertools.cc(340): warning C4244: 'argument': conversion from 'const ptrdiff_t' to 'int32_t', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
..\buffertools.cc(419): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\buffertools.vcxproj]
win_delay_load_hook.c
Creating library C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\Release\buffertools.lib and object C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\Release\buffertools.exp
Generating code
Finished generating code
buffertools.vcxproj -> C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\buffertools\build\Release\buffertools.node
[email protected] install C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\sleep
node-gyp rebuild
C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\sleep>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
sleep.cc
win_delay_load_hook.c
Creating library C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\sleep\build\Release\node_sleep.lib and object C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\sleep\build\Release\node_sleep.exp
Generating code
Finished generating code
node_sleep.vcxproj -> C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\sleep\build\Release\node_sleep.node
[email protected] install C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\i2c-bus
node-gyp rebuild
C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\i2c-bus>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
i2c.cc
c:\users\rohit narayan\documents\visual studio 2015\projects\demonodeapp\demonodeapp\node_modules\node-grovepi\node_modules\i2c-bus\src./i2c-dev.h(26): fatal error C1083: Cannot open include file: 'linux/types.h': No such file or directory [C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\i2c-bus\build\i2c.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10240
gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\node_modules\node-grovepi\node_modules\i2c-bus
gyp ERR! node -v v4.2.2
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install" "node-grovepi" "--save"
npm ERR! node v4.2.2
npm ERR! npm v2.14.7
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the i2c-bus package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls i2c-bus
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Rohit Narayan\documents\visual studio 2015\Projects\DemoNodeApp\DemoNodeApp\npm-debug.log
====npm command completed with exit code 1====

Speed up firmware by supporting polling

Quite a few sensors take a long time to return. This means if you have (say) two ultrasonic sensors, 3 analog sensors, you're limited to about 1hz sampling.

The way grovepi currently handles this is by just sleeping for ages (e.g .2 of a second for ultrasonic read, .1 for analogRead).We can make those sleeps tighter (.06 is the minimum for full range on ultrasound I think, and analogRead can live with .02), but what would be ideal would be if it was possible to tell if a value had been read yet by the sensor, so you didn't have to wait.

Thanks to a quirk in the current firmware, this would be pretty trivial to implement, because for most slow commands, it returns a buffer b, which always has byte zero ignored, which could instead be used as a status byte.

So,in receivedata, where it sets index=0, it could set b[0]==0xff. Then in the analogread handling, once it has read the value into the buffer, it could zero b[0].

void receiveData(int byteCount)
{
    while(Wire.available())
    {
      if(Wire.available()==4)
      {
        flag=0; 
        index=0;
        run_once=1;
        b[0]=0xff; // mark that we haven't read the value yet 
      }
        cmd[index++] = Wire.read();
    }
}

else if(cmd[0]==3)
{
  aRead=analogRead(cmd[1]);
  b[1]=aRead/256;
  b[2]=aRead%256;
  b[0]=0; //value is ready for consumption 
}

This would allow the python side code to be much faster, like:

def fasterAnalogRead(pin):
    bus.write_i2c_block_data(address, 1, aRead_cmd + [pin, unused, unused])
    while True:
        time.sleep(.01)
        bus.read_byte(address)
        number = bus.read_i2c_block_data(address, 1)
        if number[0]==0:
            return number[1] * 256 + number[2]

It's not a massive difference with analogread, but ultrasound read speed really slows down things for our students. Ultrasonic read time is dependent on distance, slower for longer distances. We could also take advantage of the knowledge that if we're only interested in say up to 50cm, we can just put a very short delay in, and set to maximum if no value is returned in time..

def fasterUltrasonicRead(pin):
    write_i2c_block(address, uRead_cmd + [pin, unused, unused])
    while True:
            time.sleep(.01)
        read_i2c_byte(address)
        number = read_i2c_block(address)
            if number[0]==0:
                return (number[1] * 256 + number[2])

def shortUltrasonicRead(pin):
    write_i2c_block(address, uRead_cmd + [pin, unused, unused])
    time.sleep(.05)
    read_i2c_byte(address)
    number = read_i2c_block(address)
        if number[0]==0xff:
           return 50
    else:
            return (number[1] * 256 + number[2])       

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.