I need a bridge from the epic "Silvan Melchior's RPi_Cam_Web_Interface" package to the Arduino UNO i2C input for the Adafruit 16-Channel 12-bit PWM/Servo Driver. The "pipan.php" script includes functions for the "Servoblaster" which fails to work and is not supported by "Sparkfun". Very unhelpful. Help, to this 77 year old Microcomputer hobbyist with the modification of this script would be greatly appreciated.
I am sure there are many others like me who would welcome this remedy and would greatly assist other users projects.
Hi Neil and welcome to the Arduino forum. (Not the Raspberry Pi forum, by the way).
Please read the forum guide in the sticky post at the top of most forum sections. This will give you some ideas about what you need to post in order for anyone here to be able to help you.
Sorry, not a clue what you are talking about. Complete code plus wiring sketches is a start and a minimum.
Welcome
Please do not expect everybody to know what you're talking about; in future please provide an url so we don't have to search for it and possibly find the wrong stuff. Is it GitHub - silvanmelchior/RPi_Cam_Web_Interface: A web interface for the RPi Cam?
You also mention a bridge; can you explain what you're trying to achieve? Can the Adafruit shield not be controlled directly from the Pi?
You will always have to give a good description of "fails to work".
How does SparkFun fit in this story? Is it the Arduino that you are using? What is "unhelpful"?
In pipan.php, you can add another define
(or replace the existing 'SERVO_CMD'), e.g.
define('BASE_DIR', dirname(__FILE__));
define('SERVO_CMD', '/dev/servoblaster');
// Arduino
define('UNO_CMD', '/dev/ttyUSB0');
define('SERVO_DATA', 'servo_on');
You will have to adjust '/dev/ttyUSB0' to the port of your Uno; note that those ports might change after disconnecting/connecting the board.
The below in the current pipan.php sends data to the servoblaster
if ($servo != '') {
$fs = fopen(SERVO_CMD, "w");
fwrite($fs, $servo);
fclose($fs);
}
You can write that same data to the Uno.
if ($servo != '') {
$fs = fopen(SERVO_CMD, "w");
fwrite($fs, $servo);
fclose($fs);
// send to Uno as well
$fs = fopen(UNO_CMD, "w");
fwrite($fs, $servo);
fclose($fs);
}
Please note that the Uno will reset when its port is opened; to prevent that you either need an hardware modification or add a delay (PHP: sleep - Manual) but the latter might not be what you want because the servo might only move after two or three seconds. So I guess it will be a hardware modification.
Next you need to write the Arduino code to read the incoming data and send it to the Adafruit shield. You will need to be aware of the fact that only one application can use the serial port at a time. So your pipan can not run while you're trying to upload and vice versa.
I hope this helps to get you on the way; my last hobby PHP projects were done long ago so my knowledge is extremely rusty.
My apologies for any assumptions, absence of 'url' links and details of the fault. The link should have been, as you correctly assumed, 'GitHub - silvanmelchior/RPi_Cam_Web_Interface: A web interface for the RPi Cam' and when I mentioned "bridge" I was speaking metaphorically to infer that when clicking the "up, down, left or right" buttons, which display on the web interface when pipan.py (within 'Silvans' impressive scripts is renamed to ON), should invoke the action required by the Servo Driver. The issue at present is that, as I did not purchase the device directly from 'Sparkfun' they did not wish to assist. Even to confirm in their webpages installation, if its functionality on a Pi4 or with the latest version of Pi OS, is supported. I therefore switched to the Adafruit product as I particularly wanted all motors in the product to be managed by a battery powered Arduino Uno. Not a Pi ! Project details can be found on my webpages at impartit.info ("Model Cabin Cruiser"). I am most grateful for your suggestions and will update this post with future comments with your indulgence. I will be more than happy for any collaborative input through git-hub as I am sure the ultimate solution would benefit other users (specifically the large number of users of Silvan's flawless code.
I have installed the appropriate library on the Arduino for the Adafruit unit and plan on modifying one of the example sketches to take the input from the (bridge) on the Uno i2c pins.
The SparkFun forum is, in my experience, quite agnostic to what you use; contacting support is obviously another question.
So I guess that Model Cabin Cruiser – "ImpartIT" is your project. And the device that you're talking about is the SparkFun Servo pHAT for Raspberry Pi - DEV-15316 - SparkFun Electronics.
I think that I gave enough info in my previous post to adjust pipan.php to your needs.