A Blazor WASM App simulating sensors on the client… … with the server sending the data to an IoT Hub.

The App Source: djaus2/SensorBlazor

An earlier version deployed App on Azure: blazorsimulatediothubdevicesensor ..To be updated

The app is based upon the Azure IoT HUb SDK simulated-device .NET Core Sample

Recap: Previous posts covered attempts to use a Blazor WASM client as a direct source of IoT data from a physical sensor connected to it with the service sending the data when posted to it to an IoT Hub. The hardware access by the client was found to be not possible**. The app covered here is the one that would have been the client and service to so do. The app does though generate configurable simulated sensor data on the client and the service sends it to an IoT Hub.
**A Blazor Service can though access sensor hardware connected to it.

A Blazor WebAssembly app (with PWA set).
Simulates an IoT Device with a Temperature, Humidity or Accelerometer sensor.
Can choose sensor type and set data in client.
That is then sent to the Service which then forwards it as an IoT Hub message to an Azure IoT Hub.

Sensor Types:

  • temperature
  • pressure
  • humidity
  • luminosity
  • accelerometer
  • environment
    • accelerometer and environment sensors have 3 values,
  • switch
    • switch is binary.

Simulated Device App

Pages:

  • Send Data
    • Set sensor data and send (one message):
      • Set number to send to 1.
      • Choose sensor type
      • Set value/s
      • Then Press [Send]
    • Multiple Random data:
      • Set number to send > 1 and will auto generate random data, including changing sensor type.
        • Option to disable random selection of Sensor Type
      • Set delay for this auto mode.
      • Then Press [Send]
  • Direct Temperature sample
    • As per Send Data bur comes with one preconfigured Temperature datum.
    • Auto-sends when navigated to.
  • Direct Hunidity sample
    • As per Send Data bur comes with one preconfigured Hunidity datum.
    • Auto-sends when navigated to.
  • Direct Accelerometer sample
    • As per Send Data bur comes with one preconfigured Accelerometer datum.
    • Auto-sends when navigated to.

Usage

Need to set the Hub Device Connection string in server/appsettings.json:

  • IOTHUB_DEVICE_CONN_STRING

Nb: The PowerShell app on GitHub at djaus2/az-iothub-ps can generate a complete appsettings.json file of all the connection settings for an IoT Hub. It can also quickly generate an IoT Hub, device etc.


Addendum:

The GitHub Repository here now includes the .NET Core Console app that posts telemetry directly to the Service in this app. This is discussed in a later blog post Azure IoT Hub Interaction using Blazor on a RPi - Some Hacks

Next: A Blazor App for Monitoring IoT Hub submissions.


 TopicSubtopic
   
 This Category Links 
Category:IoT Index:IoT
  Next: > Blazor-IoT
<  Prev:   Blazor-IoT