Question: Embedded Systems Duration: 2 h 0 0 Context This is a swimming pool management application with devices monitoring characteristics like temperature, pH , and chlorine

Embedded Systems Duration: 2h00
Context
This is a swimming pool management application with devices monitoring characteristics like temperature, pH, and chlorine in different pools at an aquatic center. Each pool has one device that communicates with a central Java server to manage data. There are two types of requests:
Check water quality: For a specific pool over the past week, month, or year.
Store data: Each data entry includes a timestamp, temperature, pH, and chlorine level. Valid ranges are:
Timestamp: seconds since January 1,1970
Temperature: -15.0 to 35.0C
pH: 0.0 to 14.0
Chlorine: 0.0 to 100.0 ppm
Assumptions
Each device has an ID (e.g., "POOL1") identifying the pool.
Data exchanged as lines of text.
Server is single-threaded, storing data in maps:
Map> for timestamps,
Map> for temperature, pH, and chlorine.
The server appends new data to the respective maps upon receiving a quadruplet. Its quality(String poolId, int period) method computes water quality for a pool (0= week, 1= month, 2= year). Invalid pool ID or period returns -1; otherwise, it returns a value from 0 to 10.
Protocols
Get Quality: Client sends QUAL id poolid period. Server checks validity; returns ERR error_description for errors, otherwise OK and then water quality.
Store Data: Client sends STORE id timestamp temperature ph chlorine. Invalid data returns ERR error_description, otherwise OK.
Microcontrollers (MC)
Q6. Describe an Arduino sketch structure and how it runs post-boot.
Q7. Explain Serial.begin(115200).
Q8. Provide code to set up a Wi-Fi station connecting to poolap with password poolpass, looping until connection is established.
Q9. Assuming a WiFiClient client variable and active Wi-Fi, give instructions to establish a TCP connection to server IP 192.168.0.10 on port 12345, looping until successful.
ESP32 Dev Board Setup
Pins:
Pin 2(Digital): on/off switch (on = no deep sleep).
Pin 4(Digital): LED (indicates device status).
Pins 18 & 19(Digital): pH sensor (I2C protocol); 1 byte represents pH 10.
Pin 22(Digital): Temperature sensor; 1 byte represents range from -15C (0) to 35C (150).
Pin 34(Analog): Chlorine sensor; voltage ranges from 1V (0 ppm) to 2V (100 ppm).
Information
On ESP32, analog read returns a value from 0(0V) to 4095(3.3V).
To communicate with the pH sensor, the Wire library initializes with Wire phsensor(18,19). Wire offers write(byte b) and read() functions. Reading the sensor requires writing 1 byte first, then reading.
For the temperature sensor, the OneWire library initializes with OneWire tempsensor(22), providing a read() function for the current value.
Q10. Provide instructions for setting up read/write modes for pins 2,4,18,19,22, and 34.
Q11. Set up an interrupt on pin 2 to call handleSwitch() when the pin state changes.
Q12. Write the interrupt handler handleSwitch(). It checks the switch state: if 1, sets nosleep to true and lights the LED; if 0, sets nosleep to false and turns off the LED.
Q13. Write the float getPh() function, which retrieves a value from phsensor and converts it to actual pH.
Q14. Write the float getTemp() function, which retrieves a value from tempsensor and converts it to actual temperature.
Q15. Write the float getChlorine() function, which retrieves an integer value from pin 34 and converts it to actual chlorine concentration.
Main Sketch Requirements
Use now() to get timestamp as String.
Use getTemp(), getPh(), and getChlorine() to read respective values.
Send a request to store timestamp, temperature, pH, chlorine for device "POOL1" per protocol.
Read and print server response on Serial.
If nosleep is false, deep sleep for 1 minute; otherwise, wait 1 minute.
Q16. Provide instructions to implement the above main sketch steps.
Q17. Battery Details:
Powered by a 3000mAh battery.
Modified sketch sleeps 3,500 seconds per hour, active for 100 seconds.
Power usage: 0.04mA in deep sleep, 106.6mA while active.
Estimate battery life in hours before depletion, showing computationsteps.
solve this Arduino code please

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!