Software apps and online services
Hand tools and fabrication machines
I decided to build a Star Gate sort-of exploration robot that uses Azure back end infrastructure and its services. Just imagine that the aliens for once don't speak English but Dutch. This robot is to be eventually capable of translating what they say and send us images over a cam. Yes, its a huge sandbox for the Azure services. This is the beginning of my adventure, in which I wire up the robot and implement the first basic remote controls over Azure IoT Hub.Goals
The goal of this project was for me to gain experience with IoT Hub in a fun way and have a basis platform for further IoT experiments.Preperations
I had to set up a scheduled powershell script on my Pi that syncs its time with a time server, since the Pi has no internal clock. Wrong time leads to issues when authenticating against the Azure hub, the SDK generates a token from device key that is valid for certain time span. Besides that, I only accept commands on the device that have been created within the last 500 milliseconds. Black holes are going to be a problem!
PWM Servo Motors
Run PowerShell as an Administrator on the board (Press the Windows button, and start typing PowerShell, right click on the icon and select “Run as Administrator”). Set-ExecutionPolicy RemoteSigned PuTTy to RPi as admin and: setx PATH "%PATH%;C:\Windows\System32" schtasks /create /tn "StartupPowerShell" /tr c:\Startup.bat /sc onstart /ru SYSTEM Startup.bat powershell -command "C:\IotCoreStartup.ps1" IotCoreStartup.ps $logFile = 'C:\StartupLog.txt' get-date > $logFile tzutil /s "UTC" >> $logFile # set alternate time servers "Setting additional time servers" >> $logFile w32tm /config /syncfromflags:manual /manualpeerlist:"0.windows.time.com 1.pool.ntp.org" >> $logFile Deleting a scheduled task if required: schtasks /Delete /TN "StartupPowerShell" Running a scheduled task if to test: schtasks /Run /tn "StartupPowerShell"
Pan and tilt uses the new PWM Controller from
(available as nugget). I had some hurdles to get it running. It first requires a change to manifest file, adding
<iot:Capability Name="lowLevelDevices" />
to Capabilities. Further more its required to set the Default Controller Driver to DMMD (can be done via the web interface, device section). If something is missing or wrong, you might not even get the default GpioController at all.
LowLevelDevicesController.DefaultProvider = LightningProvider.GetAggregateProvider()
as soon the app starts if LightningProvider.IsLightningEnabled returns true. As frequency for the Servo Motors, for now, I use one that centers them. After starting the PWM Signal, I disable it again after giving the motors a moment to move. See code for PanTiltServo further below.
What is PWM? (https://learn.sparkfun.com/tutorials/pulse-width-modulation)Remote Control App
I created a WPF application for controlling the Exploration Rover. Administration page allows registering a new device. "Events" displays a log of last 100 events that were sent to event hub from device. And finally the main page that allows control of the robot.
- Logging (Application Insights) - Done! - Remember to replace the InstrumentationKey's
- Change the image feed transfer mechanism to web sockets. - Done! - https://goo.gl/jwGJAo
- Remote Control from Android Wear