amc:ss2025:group-f:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
amc:ss2025:group-f:start [2025/07/28 20:50] – [3.6 Google Apps Script and Google sheets] 33784_students.hsrw | amc:ss2025:group-f:start [2025/07/29 22:36] (current) – paul-christian.thoma | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== | ====== | ||
+ | **Applied Measurement and Control 2025** | ||
+ | |||
Paul-Christian Thoma(32436)-Elham Mohammadi(32475)-Deniz-Zeynep Adem(33784) | Paul-Christian Thoma(32436)-Elham Mohammadi(32475)-Deniz-Zeynep Adem(33784) | ||
Line 16: | Line 18: | ||
By combining local sensing, cloud-based logic, and remote monitoring tools, this system provides a scalable, modular approach to smart irrigation in home or laboratory environments. | By combining local sensing, cloud-based logic, and remote monitoring tools, this system provides a scalable, modular approach to smart irrigation in home or laboratory environments. | ||
- | {{ amc: | + | {{ : |
**Figure 1.** Automated Plant Watering System Prototype | **Figure 1.** Automated Plant Watering System Prototype | ||
Line 123: | Line 125: | ||
The following diagrams, created using Tinkercad, illustrate the complete hardware connections for both the Sensor and Pump nodes in the system. | The following diagrams, created using Tinkercad, illustrate the complete hardware connections for both the Sensor and Pump nodes in the system. | ||
- | {{ amc: | + | {{ :amc: |
**Figure 2.** Schematic Diagram of Sensor Setup (designed by Deniz-Zeynep Adem) | **Figure 2.** Schematic Diagram of Sensor Setup (designed by Deniz-Zeynep Adem) | ||
| | ||
- | {{ amc: | + | {{ :amc: |
**Figure 3.** Schematic Diagram of Pump Setup (designed by Deniz-Zeynep Adem) | **Figure 3.** Schematic Diagram of Pump Setup (designed by Deniz-Zeynep Adem) | ||
Line 532: | Line 534: | ||
**Google Apps Script Codes:** | **Google Apps Script Codes:** | ||
+ | <code cpp> | ||
+ | function doPost(e) { | ||
try { | try { | ||
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(" | const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(" | ||
const data = JSON.parse(e.postData.contents); | const data = JSON.parse(e.postData.contents); | ||
+ | |||
const status = data.status || ""; | const status = data.status || ""; | ||
const moisture = data.moisture || ""; | const moisture = data.moisture || ""; | ||
const action = data.action || ""; | const action = data.action || ""; | ||
const timestamp = new Date(); | const timestamp = new Date(); | ||
- | | + | |
+ | | ||
sheet.insertRows(2, | sheet.insertRows(2, | ||
- | sheet.getRange(2, | + | sheet.getRange(2, |
- | sheet.getRange(2, | + | sheet.getRange(2, |
- | sheet.getRange(2, | + | sheet.getRange(2, |
- | sheet.getRange(2, | + | sheet.getRange(2, |
- | // Optional: | + | |
+ | // Send emails if there is an alert | ||
if (action.toLowerCase().includes(" | if (action.toLowerCase().includes(" | ||
- | | + | |
- | const subject = " | + | `Soil Alert!\nStatus: ${status}\nMoisture: |
- | const message = `An alert has been logged in your system:\n\n` + | + | |
- | `Status: ${status}\nMoisture: | + | |
- | MailApp.sendEmail(emailAddress, | + | |
} | } | ||
+ | |||
return ContentService.createTextOutput(" | return ContentService.createTextOutput(" | ||
- | } catch (error) { | + | } catch (err) { |
- | Logger.log(" | + | return ContentService.createTextOutput(" |
- | return ContentService.createTextOutput(" | + | |
| | ||
} | } | ||
+ | } | ||
+ | |||
+ | </ | ||
====== | ====== | ||
Line 570: | Line 576: | ||
Below is a video showcasing the node-Red flow and showing the code and possible errors that came up and how they were fixed. Starting with the discussion part of this documentation. | Below is a video showcasing the node-Red flow and showing the code and possible errors that came up and how they were fixed. Starting with the discussion part of this documentation. | ||
- | https:// | + | {{ : |
**Figure 4.** Documentation of the data in note-red (designed by Paul-Christian Thoma) | **Figure 4.** Documentation of the data in note-red (designed by Paul-Christian Thoma) | ||
Line 619: | Line 624: | ||
- | {{youtube> | + | {{youtube> |
- | + | ||
- | + | ||
+ | {{youtube> | ||
+ | {{youtube> | ||
amc/ss2025/group-f/start.1753728601.txt.gz · Last modified: 2025/07/28 20:50 by 33784_students.hsrw