I would like to fork the BrewPi project which uses a Raspberry Pi connected to an Arduino to use as a temp controller. It seems like a huge waste to use the Arduino as a controller, though I understand why they did it. They coupled the Arduino with a Raspberry Pi because of the high functionality you get from a complete Linux system (chiefly file system, ethernet/wifi, ssh, ntp, apache/php, and a BrewPi daemon) along with the high reliability you get to dedicated hardware. They could of course decouple from the Pi and poll the Arduino from any linux variant if they would just make a more standard package that is not reliant on Raspian.
BrewPi uses an Arduino because it is highly reliable and realtime (not that they need realtime except for standard things like SPI and OneWire). They actually had to move from Arduino to Spark because they wanted more memory. I've thought about this for a while, and I think the best solution might be to make a temperature controller kernel module and interact with that instead. This way, even if the daemon dies, the filesystem is full, etc, as long as the kernel is running then the temperature is still being controlled.
My idea is to write a kernel module that does the following:
Each instance of the module would use between 1 and 2 switches (1 for heating, 1 for cooling), use a DS18B sensor for determining temperature, and work as a PID controller (for compensating overshoots). I'd want to be able to do the following things with an instance of the module:
get/set the controller pin(s) and heating/cooling mode
get/set a controller pin(s) to be normal or inverse (high means on or off)
get/set variables in the PID (including target temperature, Kp, Ki, and Kd)
get/set the pin for OneWire and serial
get the last temperature reading
Would my approach be feasible? Is there a better approach I could take while maintaining high reliability on a RPi? I could go bare metal, but I'd like to have many features that linux gives and it seems like it'd be a huge time suck. This would be my first kernel module, though I am comfortable in C and have built and configured Linux kernels in the past. For interacting with OneWire I likely wouldn't reinvent the wheel in my module when there is already the 1-wire module. I know that there is a project called Fuscus that implements the Arduino side of BrewPi as a python library, but then you lose the reliability if the process dies or never gets started.