Control Arduino via EPICS IOC on a Raspberry Pi

I wanted to demonstrate that I could control an Arduino using EPICS installed on an attached Raspberry Pi.  That is, to install an EPICS IOC on a Raspberry Pi and to use Channel Access from another machine (on the same network) to control an Arduino.  This is part of a larger plan to build a small collection of environment monitoring stations (temperature, dust, humidity, light, etc.) to place around my house, and have the data viewable online, archived for future analysis, etc.

The method of getting this up and running is relatively easy to explain, but the detailed recipe is surprisingly complex.  EPICS certainly doesn’t score too highly in terms of user-friendliness for beginners…

To get the system working the way I wanted, I had three things to do:

  1. Build a controllable Arduino system.  This could be anything, and should be as simple as possible.  There are only really three requirements for this:
    1. Has a settable value, e.g. the duty cycle of a PWM signal sent to an LED.
    2. Has a readable value, e.g., the voltage drop across a photoresistor adjacent to an LED.
    3. These values can be set/read via a serial connection.
  2. Build an EPICS IOC on the Raspberry Pi that handles the connection with the Arduino.  That is, serve up a couple of PV’s to the local network via Channel Access (CA), and perform the appropriate serial communications with the Arduino.
  3. Build an environment on another computer on the same network that will allow CA communication with the EPICS IOC, and development of a GUI control panel.  Note that this part isn’t strictly necessary for this task, but since this is just a small part of a larger project, it will prove to be very useful in the future.

After some exploring around, and after a huge amount of help from Volker Ziemann of Uppsala University, I got this system working as desired.  It turned out that the details of getting this working are relatively complex (at least they are to a beginner), and so I have broken this out into a bunch of different posts.  That is, each of the three steps outlined above will be detailed in upcoming posts.

Leave a comment

3 thoughts on “Control Arduino via EPICS IOC on a Raspberry Pi