Tech Spike and Estimation

I didn’t really expect this personal entertainment project would cause much attention though, recently my friend started to ask about the progress of AirCares. One of my project manager friends started asking me if I need aid for project management. Sigh, what should I say – am I impacted by the global supply chain crisis? (which is true actually). Anyway, after recovering from some unexpected errands, here is the update!

The conclusion is here: Azure IoT Service Spike (/2021/10/23/azure-iot-service-spike/)

Tech Solution

The whole system includes basically two parts: a centralized server-side controller and a few clients which either provide status from sensors or stand by for executing some actions.

Client

I’m neither a hardware engineer nor interested in hardware for a long-term career goal, so I’ll just choose a popular, affordable single-board computer as far as it works. Not to say my friend Sean even provided me his project experience.

Then I’ll use Python or Node.js to write a small client-side program to collect temperature data and send signals to drive the circulation fan.

Server

A very nature idea for the server-side is Lambda+Api Gateway. While Lambda + API Gateway is nothing new to me, I was thinking if it would make more sense for me to explore the IoT service provided by popular Cloud Platforms.

I turned to Azure for two reasons: 1. I have had a personal Azure subscription with monthly credit, so I don’t need to pay extra money for any Cloud service as my traffic will be just minimal. 2. If there have been wheels, at least let me try if the wheels meet my requirement before I reinvent my customized wheels.

Budget

As I mentioned – I am really impacted by the global supply chain crisis, the inexpensive $10 Raspberry Pi Zero W is out of stock in adafruit. So I still need to figure where can I find a supplier without paying too much for the product or shipping.

ItemQuantitySubtotal
Raspberry Pi Zero W1$10
Raspberry Pi Zero W (with header)1$14
DS18B20 Digital temperature sensor + extras4$15.8
Premium Male/Male Jumper Wires – 20 x 6″ (150mm)1$1.95
Adafruit STEMMA Non-Latching Mini Relay3$17.85
STEMMA JST PH 3-Pin to Male Header Cable – 200mm3$3.75
Premium Female/Female Jumper Wires – 20 x 6″ (150mm)1$1.95
Premium Female/Male ‘Extension’ Jumper Wires – 20 x 3″1$1.95
Adafruit Perma-Proto Half-sized Breadboard PCB – Single1$4.5
Total$71.75

Estimation

EpicEstimation
Manually create server-side Azure resourceSmall
Details of server-side Azure FunctionMedium
Build client-side softwareMedium
Build client-side hardwareLarge
Manage server-side resources per IaCLarge
Build extra QA environment plus CICDMedium
System monitorSmall

Azure IoT Service Spike

Architecture of AirCares

Architecture of AirCares

Summary of the POC

Notes of the Spike

  1. Basic concepts: events, insight and action: https://docs.microsoft.com/en-us/azure/architecture/example-scenario/iot/introduction-to-solutions
  2. Create a IoT Hub: https://www.youtube.com/watch?v=A4TKvsLu2Yw
  3. Quick start of IoT Hub: https://docs.microsoft.com/en-us/azure/iot-develop/quickstart-send-telemetry-iot-hub?pivots=programming-language-nodejs
    1. Get connection string of the IoT Hub: az iot hub connection-string show –hub-name ${nameOfIoTHub}
    2. Run a simulated device:
      1. Create a device
      2. run https://github.com/Azure/azure-iot-sdk-node/tree/master/device/samples/pnp
    3. Listen the message sent from the simulated device: az iot hub monitor-events –output table –device-id ${nameOfDevice) –hub-name ${nameOfIoTHub}
  4. Create logic layer to process events from IoT Hub: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-iot-trigger?tabs=csharp
  5. Use Azure Function
  6. Send Cloud to device message:
    1. Overview: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messaging
    2. Details: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-node-node-c2d
    3. Notes: the connectonString for device and service can only be used for specific purpose correspondingly.
  7. Azure loggin system