Wednesday, October 7, 2015

23: About My "Live" Photon System

I've had a blogspot "comment" (question) about how I implemented the Photon control system at my granddaughter's farm (see post 21). Well, it's kind of complicated.

The program on the Photon is written in C++. It was initially only 80 lines of code but has grown to over 200 lines. It will probably get longer still. It has 2 main parts: 1) In the "loop()" all of the sensors are recorded in a Particle.variable, and time readings from the "cloud" control the electric fence and make sure that the water is not on for too long; b) a Particle.function can be called to change relays or override timed events.

I wrote a PHP program for the Internet interface. It is fairly complicated and only works because my hosting service is Linux-based and permits execution of the "curl" command to communicate with the Photon. Many servers would not allow this.

I also have a Raspberry Pi running Linux. I use the "crontab" scheduling program to check the status of the Photon. It is this Pi that can send e-mails or text messages if something goes wrong (hoop house too hot or cold, power failure, etc.).

Of course, the Photon's location has to have reliable wifi/Internet service. I had to add a wifi amplifier for my "live" system.

No comments:

Post a Comment