Amazon

Wednesday, February 28, 2018

Welcome to part 2 of using Arduino IoT Device with Azure IoT Edge. You should have installed all the prerequisites from the part 1 post (my last one). The information is almost a direct lift from Microsoft as this is their suggested setup. I have no intellectual property right to this information provided. If you get stuck you can contact me.

This post is going to cover some of the additional steps that will need to be performed so that your laptop is configured correctly. Since we are using our Edge device "as a gateway*, so we need:
  • a) our IoT Device to be able to find it
  • b) to have valid certificates so the IoT Device will open a successful TLS connection to the Edge
Add a host file entry for our Edge device -- this will let our "IoT Device" resolve and find our Edge gateway. To do this:
  • Open a command prompt __*as an Administrator*__
  • Open (with notepad) c:\windows\system32\drivers\etc\hosts
  • Notepad.exe c:\windows\system32\drivers\etc\hosts
  • Add a row at the bottom with the following 127.0.0.1 mygateway.local
  • Save and close the file
  • Confirm you can successfully "ping mygateway.local"
Open a PowerShell session *as an Adminstrator*. NOTE: do this in a plain Powershell window. it does not work in the PowerShell ISE for some reason
  • Make an \edge folder (mkdir c:\edge)
  • cd to the \edge folder (cd \edge)
  • Run the following powershell command:
    • Set-ExecutionPolicy Unrestricted
  • Run the following commands to set up our use of OpenSSL
    • $ENV:PATH += ";c:\utils\OpenSSL\bin"
    • $ENV:OPENSSL_CONF="c:\utils\OpenSSL\bin\openssl.cnf"
    Import the ca-certs script with the following command (note the leading dot and space. This is called dot sourcing)
  • . \azure-iot-sdk-c\tools\CACertificates\ca-certs.ps1
  • Run
    • Test-CACertsPrerequisites
    • make sure it returns the result "SUCCESS"
    • If the Test-CACertsprequisites call fails, it means that the local machine already contains Azure IoT test certs (possibly from a previously deployment.
      • If that happens, you need to follow Step 5 - Cleanup of the instructions
      • https://github.com/Azure/azure-iot-sdk-c/blob/CACertToolEdge/tools/CACertificates/CACertificateOverview.md) before moving on
    • * DO NOT CLOSE THE POWERSHELL session yet (if you do, just reopen it and re-add the environment variables above)
    • We are now ready to generate the TLS certificates for our Edge device
      • make sure you are still in the c:\edge folder in your PowerShell session
      • Run
        • New-CACertsCertChain rsa
      • to generate our test certs (in production, you would use a real CA for this...)
        • In the azure portal, navigate back to your IoT Hub and click on "Certificates" on the left-nav and click "+Add".
        • Give your certificate a name, and upload the c:\edge\RootCA.cer" file
        • Now we need to generate certs for our specific gateway to do so, run
          • New-CACertsEdgeDevice myGateway
          • Command in Powershell. This will generate the gateway specific certs (MyGateway.*).
          • When prompted to enter a password during the signing process, just enter "1234".
          • NOTE: If anything goes wrong during this process and you need to repeat it, you'll likely need to clean up the existing certs before generating new ones. To do so, follow Step 5 - Cleanup, of the process outlined (https://github.com/Azure/azure-iot-sdk-c/blob/CACertToolEdge/tools/CACertificates/CACertificateOverview.md)

    ## Install IoT Edge configuration tool

    • Microsoft provides a python-based, cross-platform configuration and setup tool for IoT Edge. To install the tool, open an administrator command prompt and run:
      • pip install -U azure-iot-edge-runtime-ctl
  • ## Configure and start IoT Edge
  • Now that we have all the pieces in place, we are ready to start up our IoT Edge device. We will start it by specifying the IoT Edge Device connection string capture above, as well as specifying the certificates we generated to allow downstream devices to establish valid TLS sessions with our Edge gateway.
  • To setup and configure our IoT Edge device, run the following command (if you used '1234' for the password above, enter it again here when prompted). Make sure that Docker is running.
    • iotedgectl setup --connection-string "" --edge-hostname "mygateway.local" --device-ca-cert-file c:\edge\myGateway-public.pem --device-ca-chain-cert-file c:\edge\myGateway-all.pem --device-ca-private-key-file c:\edge\myGateway-private.pem --owner-ca-cert-file c:\edge\RootCA.pem
      • Replace *IoT Edge Device connection string* with the Edge device connection string you captured above. If it prompts you for a password for the edge private cert, use '12345' (NOTE: different from the password above!)
    • We're ready now to start our IoT Edge device
      • iotedgectl start
      • You can see the status of the docker images by running
      • docker ps
      • at this point (because we haven't added any modules to our Edge device yet), you should only see one container/module running called 'edgeAgent'
      • If you want to see if the edge Agent successfully started, run
        • docker logs -f edgeAgent
        • Note that you may see an error in the edgeAgent logs about having an 'empty configuration'. That's fine, because we haven't set a configuration yet!
        • CTRL-C to exit the logs when you are ready
you now have an IoT Edge device up and running and ready to use

Tuesday, February 27, 2018

Today Starts my journey on the IoT using first the Arduino and then using the Raspberry Pi. I am starting out real simple and then will build on what I know. I am starting with an Arduino UNO r3 board and a DHT11 Digital Temperature Humidity Sensor Module. The plan is to add on a Giger Counter to measure if any radio active particles are in the air. The data produced will be sent to a Microsoft Azure Edge Hub to be processed. Some of the information I am providing was received from a Free Microsoft class I took on IOT Edge. If you ever get a chance to attend some of the free classes at your local Microsoft I highly suggest it.
    To start you will need the following things:
  • Arduino Uno 3
  • DHT11 or DHT22 Digital Temperature Humidity Sensor Module
  • Windows 10 pro
  • An Azure account, the free one from Microsoft will work. Here is a link: https://azure.microsoft.com/en-us/services/iot-edge/
    here are the prerequisites that will be needed:
  • Windows 10 pro Fall Creators Update (build 16299)
  • Docker for Windows ** the "community edition" is fine. Make sure you install the STABLE version. A reboot may be required to enable Hyper-V
  • Visual Studio Code
  • .NET Core SDK
  • Arduino IDE
  • Open SSL
  • * create a c:\utils folder and unzip the downloaded OpenSSL zip to c:\utils\ (so you should a folder structure that looks like this-> c:\utils\OpenSSL)
  • git ** installation of the default components and default configurations are fine clone the Azure IoT C sdk. We need this to get the certificate generation scripts. Also, while Edge is in public preview, we need the 'CACertToolEdge' branch of the SDK. Run the following command from the root of the "C" drive git clone -b CACertToolEdge http://github.com/azure/azure-iot-sdk-c
  • Python 2.7 for Windows -- __**make sure it's 2.7.x, NOT 3.x.x**__ * during setup, elect to "add python 2.7 folder to the path" ![python_install](/images/python_install.png)
I am going to stop at this point today, to see if I have any questions. Stephan

Monday, February 26, 2018

Raspberry Pi & Ardunio shop

Good evening I have been going over the pages of Amazon and I have been looking for the parts you may need to build your next project. Check Out my Page and buy what ya need. Electronic's
Check Out my Necromunda Store

Necromunda is back


Have you seen the blast from the past is back?  Necromunda: Underhive the great skirmish game from Games Workshop, which gets played here in the Minneapolis, MN area at The Source, Games Workshop and Fantasy Flight Games.  The big news I saw was that GW is releasing Genestealer Cults in March.  I know I'm a little late, but they also released Mad Donna Ulanti along with Kal Jericho &  Scabb's.  I am hoping of joining a group to start playing again.