All the input sensor and serial lines are polled on the atmega 2560 every couple of seconds. the raw output from these sensor are formatted as a json string and sent to the linux computer through the serial line UART0. the linux computer then sends a json object to the remote database server. the raw values are converted to the actual calibrated values during visualization by using the kj2arduino library.
this data path is show below:
the raw json from the 2560 typically looks as shown below
.—kijanistart—
“initialize”:0,
“baudRate”:38400,
“version”:”v2.0.0″,
“atmegaUptime”:”00:00:06:23″,
“pins”:{
“D3”:0,
“D4”:1,
“D5”:0,
“D6”:1,
“D7”:1,
“D8”:1,
“D9”:1,
“D22”:0,
“D23”:1,
“D25”:0,
“D28”:1,
“D29”:0,
“D30”:0,
“D31”:0,
“D32”:0,
“D33”:0,
“D34”:0,
“D35”:0,
“D36”:0,
“D37”:0,
“D38”:0,
“D39”:1,
“D40”:0,
“D42”:1,
“D43”:0,
“D44”:0,
“D45”:0,
“D46”:0,
“D47”:0,
“D48”:0,
“D49”:0,
“A0”:386.00,
“A1”:722.00,
“A2”:556.00,
“A3”:1023.00,
“A4”:323.00,
“A5”:330.00,
“A6”:338.00,
“A7”:372.00,
“A8”:388.00,
“A9”:1023.00,
“A10”:735.00,
“A11”:642.00,
“A12”:567.00,
“A13”:503.00,
“A14”:464.00,
“A15”:436.00,
“UART2”:0,
“UART3”:0,
“nutrientTemp”:19.75,
“ph”:2.34,
“ec”:1751,
“tds”:946,
“salinity”:0,
“flow_rate_sensor”:0.00,
“rtc”:”2000/8/6 19:45:16″
}
—kijanistop—
The final json object sent by linux computer to the server is: shown below:
{“baudRate”: 38400, “name”: “kj_v2_12”, “uptime”: “2:21:16.520000”, “pins”: {“D38”: 0, “D39”: 0, “D36”: 0, “D37”: 0, “D34”: 0, “D35”: 0, “D32”: 0, “D33”: 0, “D30”: 0, “D31”: 0, “tds”: 890, “A15”: 420.0, “A14”: 462.0, “A11”: 611.0, “A10”: 745.0, “A13”: 500.0, “A12”: 543.0, “relay8”: 0, “UART3”: 0, “A1”: 718.0, “A0”: 387.0, “A3”: 1023.0, “A2”: 552.0, “A5”: 339.0, “A4”: 322.0, “A7”: 350.0, “A6”: 346.0, “A9”: 1023.0, “A8”: 368.0, “ph”: 2.6, “D29”: 0, “D28”: 1, “nutrientTemp”: 19.75, “D23”: 1, “D22”: 0, “D25”: 0, “UART2”: 0, “D49”: 0, “D48”: 0, “ec”: 1647, “relay6”: 1, “D43”: 0, “D42”: 1, “rtc”: “2000/8/6 21:59:38”, “D40”: 0, “D47”: 0, “D46”: 0, “D45”: 0, “D44”: 0, “salinity”: 0, “flow_rate_sensor”: 0.0, “D8”: 1, “D9”: 0, “D6”: 1, “D7”: 1, “D4”: 1, “D5”: 0, “D3”: 0}, “version”: “v2.0.0”, “wlan0”: “192.168.42.82”, “initialize”: 0, “atmegaUptime”: “00:02:20:44”}