Here’s what happens behind the scenes when you use the WaterScope interface:
Connecting to the WaterScope: The Raspberry Pi is configured to broadcast a WiFi access point, give your device a network address, and make sure that when you go to http://pi/, you get the right webpage back. - see Antoine’s report
Pretty webpage: The webpage layout is written in HTML and CSS. That’s what your browser displays as text, buttons, and the video stream - see Kai Song’s report.
Client-Server interface: When you click on a button, a JavaScript function gets executed that sends an HTTP request to the Raspberry Pi to tell it to do what you want. On the Raspberry Pi, a Python server called Flask listens for the request, tries to execute what you wanted, and replies to your browser with the outcome - see Antoine’s report
Streaming and capturing photos: On the Raspberry Pi, the program mjpg-streamer takes the photos from the camera, encodes them, and make them available on the network. The webpage then requests the stream from mjpg-streamer and displays it for you. When you click on “Capture Photo”, we stop mjpg-streamer to free the camera, then take a single image at the highest resolution, and finally restart it - see Kai Song’s report
Controlling the motors: When you click on an arrow button, the server sends a command to the fergboard over the Raspberry Pi’s I2C interface - see Antoine’s report
Arduino sensors and outputs: The Arduino has the nanpy firmware and pyserial library, which transforms it into a slave controlled over the serial connection. The server then interacts with it using the Python nanpy - see Kai Song’s report
Automatically opening the WaterScope interface when the user connects: Ever noticed how when you connect to a WiFi network that requires some sign-in, like in a hotel, the sign-in page opens automatically? Wouldn’t it be awesome if the WaterScope could do that too? - see Antoine’s report
Different user modes: It sounds obvious, but different users have different needs. An unskilled user wishing to just perform automatic recognition of bacteria would be confused by a wealth of camera options. Also, if there is no access control, any user connected to the network can control the motors and restart the stream, potentially disruptive operations - see Kai Song’s report