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: h
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
Temperature: to C
pH: to
Chlorine: to ppm
Assumptions
Each device has an ID eg "POOL identifying the pool.
Data exchanged as lines of text.
Server is singlethreaded, 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 qualityString poolId, int period method computes water quality for a pool week, month, year Invalid pool ID or period returns ; otherwise, it returns a value from to
Protocols
Get Quality: Client sends QUAL id poolid period. Server checks validity; returns ERR errordescription for errors, otherwise OK and then water quality.
Store Data: Client sends STORE id timestamp temperature ph chlorine. Invalid data returns ERR errordescription, otherwise OK
Microcontrollers MC
Q Describe an Arduino sketch structure and how it runs postboot.
Q Explain Serial.begin
Q Provide code to set up a WiFi station connecting to poolap with password poolpass, looping until connection is established.
Q Assuming a WiFiClient client variable and active WiFi give instructions to establish a TCP connection to server IP on port looping until successful.
ESP Dev Board Setup
Pins:
Pin Digital: onoff switch on no deep sleep
Pin Digital: LED indicates device status
Pins & Digital: pH sensor IC protocol; byte represents pH
Pin Digital: Temperature sensor; byte represents range from C to C
Pin Analog: Chlorine sensor; voltage ranges from V ppm to V ppm
Information
On ESP analog read returns a value from V to V
To communicate with the pH sensor the Wire library initializes with Wire phsensor Wire offers writebyte b and read functions. Reading the sensor requires writing byte first, then reading.
For the temperature sensor the OneWire library initializes with OneWire tempsensor providing a read function for the current value.
Q Provide instructions for setting up readwrite modes for pins and
Q Set up an interrupt on pin to call handleSwitch when the pin state changes.
Q Write the interrupt handler handleSwitch It checks the switch state: if sets nosleep to true and lights the LED; if sets nosleep to false and turns off the LED.
Q Write the float getPh function, which retrieves a value from phsensor and converts it to actual pH
Q Write the float getTemp function, which retrieves a value from tempsensor and converts it to actual temperature.
Q Write the float getChlorine function, which retrieves an integer value from pin 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 "POOL per protocol.
Read and print server response on Serial.
If nosleep is false, deep sleep for minute; otherwise, wait minute.
Q Provide instructions to implement the above main sketch steps.
Q Battery Details:
Powered by a mAh battery.
Modified sketch sleeps seconds per hour, active for seconds.
Power usage: mA in deep sleep, mA 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
