0

I want to control a Raspberry pi to control an arduino which is controlled by a webpage hosted by apache. I do not know how I would attempt this and if it is even possible. Can anyone please guide me in the right direction to do this. I want to press a button and it tells the pi to send an I2C signal to the Arduino to start the motor while the button is pressed.

20
  • 2
    Divide your problem into subproblems and then try to find an answer for each of them. For example: 1. Hosting Apache website on Raspberry Pi 2. Raspberry Pi and Arduino connection BTW why not starting the motor directly from RPi?
    – Mark
    Commented Oct 19, 2017 at 5:30
  • Are you using pigpiod ?
    – guyd
    Commented Oct 19, 2017 at 9:51
  • @Mark I know I am going to start the connection between the 2 via I2C, but I want to know how I can control that I2C connection from Apache. I’m not doing it from the Pi because the PWM on the pi isn’t great and I plan to do more in the future with this project. Commented Oct 19, 2017 at 11:02
  • @Guy.D What is pigpiod? Commented Oct 19, 2017 at 11:06
  • 1
    @ppumkin I dont know how to keep the function running while the button is clicked. Can I still use AJAX for it? Commented Oct 20, 2017 at 21:54

2 Answers 2

0

You need cgi, cgi are scripts or programs run by server. There are plenty of example

You can have a cgi script on server called by web page via forms to start/stop your motor.

You can develop cgi in python, bash, c ...

2
  • So I could use CGI to turn a motor on when a button is pressed by it sending an I2C signal to the Arduino and turn it off when it isn’t pressed. All in python and Apache? Commented Oct 19, 2017 at 14:52
  • Yes. I make something close to what you want to do (I'm using webpage on mobile phone to open/close portal and garage door) see You can too use an Arduino Yun if your raspberry pi is only used as web server , the Arduino Yun can do the job, but with raspberry pi it is possible too.
    – flc
    Commented Oct 20, 2017 at 10:21
0

Use these:

Control rapsberry using PHP.

Use python to execute scripts over i2c

conenct i2c to arduino.

make all arduinos on i2c bus as slave mode to receive a fixed range of bytes.

use these byte data to interpret and pefrom action in arduino using C

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.