Arduino Aquaponics: JSON

**UPDATE**
To see JSON, have a look at the Pump Controller project.

In a previous post, Online Relay Control, we demonstrated how to manually trigger a relay from a web application.  The Arduino polled App Engine on a set interval and received the status of the relay as a string; the Arduino sketch parsed the response and then analyzed the response using "if" conditionals.

While that works well for setups involving a single relay, we realize it is inherently limiting, particularly for those who want to control two relays with their Environment DAQ.  Similarly, we wanted to pair the Depth Sensor with two pumps that could be controlled independently and we needed a method of differentiating them with data from a single response.  Enter JSON.

To parse the JSON, you need aJson Library made by Marcus Nowotny.  Download, extract it and put a copy in your libraries folder.  Name the it aJSON.

The Arduino sketch below receives the following response for a GET request:

{'RELAY1': 'ON'}

and then toggles the relay.






You can see then, that returning more than one key-value pair can still be parsed from a single request.

Depth Sensor

The hardware was built directly from the Practical Arduino project, but the source code was almost completely overhauled to handle App Engine and our tank visualization, which you can see in action on the Aquaponics Tracker page.

Figure 1.  Depth sensor PCB.  The differential pressure transducer is bottom right.

Why track depth?  Actually, there are a number of reasons.  As you can see in Aquaponics Tracker, you can combine stock information with the depth to monitor the stocking density during system cycling.  You can monitor the depth for potential leaks, automatically refill the stock tank from a sump tank (due to losses from plant growth, evaporation, etc.) and when paired with pump control, you can prevent overflows and/or cycling too much water.

You can see the schematic for the depth sensor below.  The drawing is nearly identical to the Practical Arduino schematic, but we added the missing capacitor for noise reduction.

Figure 2.  Depth sensor schematic with missing capacitor.