Software Design - Arduino <-> Raspberry Pi Interfacing - RPi Communication Protocol

This blog post focuses on the interactions between the Arduino and the Raspberry Pi. More specifically, the serial communication protocol being used between the two modules.

Check out the post on the Overview of Architecture to refresh your memory on the components connected to each of the modules.

Starting with the Raspberry Pi, this is our command hub. All commands are sent from the RPi, based on the current state of the robot. This could essentially be considered as the 'brains' of our pod. A command packet is sent from the RPi to the Arduino, consisting of 10 floats, with a start and end byte to locate the start and end of the message. The RPi command packet can be seen in the following figure.


Briefly walking through each of the commands in the packet, the intended state of the pump is the first float sent in the package (i.e. whether the pump should be pumping water out of the chamber (ON) or not (OFF)). Next, the bulb state is sent, turning the bulbs ON or OFF during the spectroscopy readings. Following this float, the garage state is sent, acknowledging whether the servo operating the garage door should be powered or not. If there is a need for the garage door to be powered, the next float in the packet will be populated with a direction (i.e. rotating the servo CW or CCW depending on whether water intake is required, or the water intake has completed). The same steps work for the trap door state, and the trap door direction (whether filtering is required, or spectroscopy readings are required - during which the trap door would remain shut).

The next states correspond to some of the sensors. The pH state, conductivity sensor state and ultrasonic sensor state are floats sent to ensure each sensor continues polling the water quality during treatment. Finally, the LED state refers to the LED strip, which is powered based on the current state of all the other sensors and actuators within the pod. For example, if the pod requires a manual reset, the LED strip will be lit red.

Comments

Popular posts from this blog

Mechanical Design - Watertight Locking Mechanism

Final Post (Poster, Video)

Software Development - Making Lilypod Intelligent – Part 3 (The Implementation)