I have search hundreds of website, I watched many videos, but I cannot understand how to make raspberry pi talk to Photon, where it could read a sensors or turn led on or off, etc…)
I managed to use the Particle app to turn the d7 led on/off.
I cannot find a way to make the raspberry pi talk to Photon.
Some websites say I need to use the protocol i2c. but to use it a need to connect the RPI to the Photon with wire. which doesn’t make any sense.
Well for what its worth, I was able to log data from a couple of photons on a PI.
I set up the photons, with each one publishing several strings of data.
Then I wrote a python script, which used a libary called Requests. This Request Libary, allows curl commands to poll the particle cloud, obtain the data that the photons published. From there you can do what you want with the data, such and log it to a local text file. There is nothing to say that the PI could not actually post curl commands, which could control photons from the PI. The photons would need to be set up to ‘subscribe’.
So it should be possible. But the key trick is to learn about curl commands, which can directly control the photons, from a computers command line, and then you can script the commands within a python script to automate the process, but the key bridge is to use Requests, to faciltate the curl commands within Pyton.
Okay, Thank you guys.
I am reading the materials you recommended
The only thing I wish to do is a smart house, where via a local ip I connect to a webpage that is in the raspberry pi (server), and it will turn on/off light (there is a photon connect on it- client), check if door as close/open (there is another photon connect on it- client).
So there is no need of make Raspberry Pi Master, Photon I2C Slave" stuff.
Oh, then why not just create a TCP/IP socket client/sever on your devices. Eliminate the cloud stuff altogether and keep your coms local. If you ever decide to slap more sensors in the home for the Pi to monitor you can start getting into broadcasting for all to hear and respond.
But, it's worth noting, You can also create a websever on the Photon as well, just saying incase you didn't know.
Have you installed the Particle CLI on your RasPi yet? To me, that would be the easiest way to just do some Proof-of-Concept testing. You can monitor cloud-exposed variables, call functions, publish and subscribe events… It’s a great debugging/testing tool.
When you’re ready to build your home control web page, you’ll probably want to look at the Particle JavaScript API. Just try to be careful not to expose your login info or secret token to the open internet.