Can you provide me a example for the Grove Encoder (D2) connected to GrovePi+ board?
I tried following code but I always receive zeros.
print "Reading from the encoder"
[new_val,encoder_val] = grovepi.encoderRead()
and this is definations;
write_i2c_block(address, encoder_en_cmd + [unused, unused, unused])
write_i2c_block(address, encoder_dis_cmd + [unused, unused, unused])
write_i2c_block(address, encoder_read_cmd + [unused, unused, unused])
data_back= bus.read_i2c_block_data(address, 1)[0:2]
If you can also suggest how to change D2 to other port to test the GrovePi+ or Grove encoder has a problem.
The Grove encoder only works with firmware version 1.2.5 and up. Can you make sure that you have it on your Pi: https://github.com/DexterInd/GrovePi/tree/master/Firmware/Source/v1.2/grove_pi_v1_2_5 and run a firmware update to upload it to the Atmega using: avrdude -c gpio -p m328p -U flash:w:grove_pi_v1_2_5.cpp.hex . After uploading the firmware, make sure that it is on there by running: https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_firmware_version_check.py . Once the firmware is updated, connect the encoder to port D2 and try running this https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_encoder_read.py.
Do let us know if this helps.
Can you please give instructions for uploading firmware.
Make sure that you have the latest version of the GrovePi repository on the Raspberry Pi.
Go to the firmware folder: Grovepi/Firmware/Source/v1.2/grove_pi_v1_2_5 . It should look like this: https://github.com/DexterInd/GrovePi/tree/master/Firmware/Source/v1.2/grove_pi_v1_2_5 .
Double-check that this file is there: grove_pi_v1_2_5.cpp.hex
Run the firmware update using:
avrdude -c gpio -p m328p -U flash:w:grove_pi_v1_2_5.cpp.hex.
Once the firmware update is done, run the grove_firmware_version_check.py in the Grovepi/Software/Python folder and make sure that it shows 1.2.5.
Not since you have a GrovePi+. The old GrovePi-without-plus needed that to be able to be flashed with avrdude.
Thank you Karan & Mirar,
Can you please advice how do I port Grove encoder to D3 or D4 port?
I manage to update firmware sucessfully.
The Grove encoder can only work on Port 2 because it needs interrupts to work and the pins on Port 2 are the only ones that support it.