Close

NEW feature, send temperature updates to Raspberry Pi through 'fresca-link'!

A project log for 'fresca' versatile temperature controller

Control temperature for up to 8 separate processes! Cooling/heating control with humidity sensing. Based on Arduino and DS18B20/DHT22.

leoLeo 12/20/2017 at 00:030 Comments

Hello all!

I've been working on a new feature that will enable communication with a Raspberry Pi or another device that has a UART port. I've called it fresca-link. The idea is to send binary packets of data via UART to update the 'host' with real-time data from the Arduino. fresca-link is a packet based protocol designed for 8 bit microcontrollers that have low processing power. So, most of the protocol-specific words are 8-bits. I've used simple integer checksum for error protection (CRC is either too slow or takes up too much memory). Data sent over the serial link is binary not ASCII! So you can't possibly debug it by sending the output to a console.

Since the arduino is pretty busy with real-time tasks, the master of the communication will be the arduino (hence it will only start communication when it know there is no real-time event coming in the next 100ms, for example). The arduino will send packets first to the host, and then the host will respond accordingly (if necessary). Right now I've tested sending temperature update packets to the raspberry pi, and that works like a charm. Later I plan to make it possible for the 'host' to send configuration data to the arduino so that everything can be remotely controlled.

This is all working on branch 'feat/fresca_link'. Remember to use a level converter 5v <--> 3.3v if you are using a raspberry pi or any other 3.3v part. The raspberry pi receives temperature data by executing a Python script that searches for this 'temperature' packets and displays the parsed temperature on the screen (raspberry pi serial port should be enabled and the serial console feature should be disabled, remember to match baudrates as well). All the arduino code is in the 'arduino' folder, and all the raspberry pi code is in the 'rpi' folder.

Next step would be to create a webserver in the raspberry pi (possibly using 'flask' or 'django' frameworks) to display all this information and have a control panel for configuring fresca's settings. Stay tuned!

PD1: You might see a branch called 'feat/SPIcomms' which will die there, where I tried using SPI as a low-level protocol for fresca-link. Since it's rather inconvenient to use the raspberry pi as an SPI slave, I had to use it as SPI master, and that proved to be very unreliable since the arduino can't respond when it's busy doing real-time tasks (like reading the sensors). It also only reached 100Khz max, so that's about the same speed as UART 115200 (the arduino should do better, but maybe I had a problem with the cables or the level converter, anyway I can't see cause I don't own a scope). Overall it turned out to be very inconvenient, so I turned to the simple and reliable serial port.

PD2: If anyone is interested I can describe the particulars of the fresca-link protocol

Discussions