How do I change frequency of telemetry of Azure IoT Edge simulated tempSensor module - azure-iot-hub

I would like to change the frequency of the simulated tempSensor module so that it sends telemetry to the IoT Hub every 60 seconds, not every 5 seconds. I cannot find the code in order to create my own C# module or to modify the one that Azure has as a sample. How do I change the frequency of the telemetry of this simulated temperature sensor module used in the IoT Edge walkthrough?
https://hub.docker.com/r/microsoft/azureiotedge-simulated-temperature-sensor/
I have an Azure Iot Hub with 8000 messages per day and Iot Edge device simulated and a tempSensor and filterModule through Docker setup etc... All is working well.
I could write another C# module similar to the filterModule which would function like a time filter and averages 12 readings together and sends a message every 60 seconds and then the filterModule does it's job after. So the route would go from tempSensor to timeFilter to filterModule. Along this line of thinking.
SIMULATED TEMPERATURE SENSOR in Docker
https://azure.microsoft.com/en-us/resources/samples/?service=iot-hub&sort=0&term=simulated
Where do I find the code for that example? I looked here:
https://github.com/Azure-Samples
I am trying to learn how the simulated temperature sensor module works in the code in order to build off that to create my own IoT modules.
I found something close but am not sure how to go between this code and the modules used in IoT Edge.
https://learn.microsoft.com/en-us/dotnet/api/overview/azure/iot?view=azure-dotnet
I don't see API reference here:
https://learn.microsoft.com/en-us/azure/iot-edge/
Here are some other places I looked:
https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-edge
https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-toolkit

The source code is not currently open source.
Update:
Currently (April 2018) the code is open-sourced under the MIT licence and can be found on GitHub here:link
To solve your immediate need, there is an undocumented setting for adjusting the delay. All the available settings for the Simulated Temperature sensor module (and default values):
"MessageDelay": "00:00:05",
"machineTempMin": 21,
"machineTempMax": 100,
"machinePressureMin": 1,
"machinePressureMax": 10,
"ambientTemp": 21,
"ambientHumidity": 25
This may be set as environment variables in the "createOptions" section, like this:
"tempSensor": {
"version": "1.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "microsoft/azureiotedge-simulated-temperature-sensor:1.0-preview",
"createOptions": "{\"Env\":[\"MessageDelay=00:01:00\"]}"
}
}

Related

How to include information about iotEdge capability in device created event in IoT Hub?

I am wondering if it is possible to include information if device is an edge device in Microsoft.Devices.DeviceCreated event data? I receive those events for both type of devices but I am not able to distinguish them and say oh yeah this one is an edge device.
I can see that device twin which I receive is a little bit different than the one I can see in portal. In portal twin contains information about capabilities which say iotEdge: true for edge and false for directly connected devices.
Basically, there are two ways to handle this issue:
The subscriber event handler (EventGridTrigger function) will pull up the full device twins info like you can see on the portal.
Using the Bulk Create or Update REST API call for creating devices with an additional information in the tags. I do recommend this way and based on my answer here, the following is an example of the payload POST:
[
{
"id":"TD_0001",
"importMode":"create",
"status":"enabled",
"tags":{
"capabilities":{
"iotEdge":false
}
}
},
{
"id":"TD_0002",
"importMode":"create",
"status":"enabled",
"tags":{
"capabilities":{
"iotEdge":true
}
},
"capabilities":{
"iotEdge":true
}
}
]
As you can see, the capabilities property has been added in the tags. Basically, you can initialized any device twins properties included a reported property.
The Azure IoT Hub Notification to the AEG is almost immediately and the following screen snippet shows an example of the event message:
and the azure portal screen:

Unable to start the chipKit BasicIOShield with PIC32 using PICKIT3 programmer

I have chipKit uC32 (PIC32MX340F512H) ,chipkit BasicIOShield and PICkit3
programmer all from the Microchip.
I'm using MPLABX IDE.
Since I'm very new to this so I didn't know where to start I have searched and look at the web and find only tutorial which using MPIDE which I'm not allowed to use in my project.
I have read the Reference manual and Data sheet for and make test project but any way the uC32 Board refuse to recognize the BasicIOShield and I was unable to connect this two together.
Any tips and link would be great. Thanks in advance.
In the Basic IO shield Reference manual stated that you should follow some step in order to make the ChipKit to talk to the basic IO shield.
Power on sequence
Apply power to VDD.
Send Display Off command.
Initialize display to desired operating mode.
Clear screen.
Apply power to VBAT.
Delay 100ms.
Send Display On command.
Power off sequence
Send Display Off command.
Power off VBAT.
Delay 100ms.
Power off VDD.
The shield is using SPI2. The following registers are used
RF4, RF5, RF6 and RG9
Also you must change the jumper in the uC32 from LED4 to JP4 and JP8.
in the Appendix B of the reference manual of the basic IO shield is an example code which is useful.

How to run baremetal application on Altera Cyclone V SoC using HPS loading from SD card

I have a Terasic DE1-SoC board and I want to run a simple led-blinking baremetal application with using HPS.
I've learned HPS tech ref, HPS Boot guide, SoC EDS guide and followed all instructions to run my app.
Here's a brief list of my steps.
Create a system in QSYS with HPS component and some PIOs (for on-board leds and buttons)
Run bsp-editor to create a preloader. I want to run from SD card so I check BOOT_FROM_SDMMC option. Also i want my app to be in FAT partition (check FAT_SUPPORT, FAT_BOOT PARTITION 1, FAT_LOAD_PAYLOAD_NAME test.img (or should it be test.bin?)) Uncheck WATCHDOG_ENABLE. I want to see booting of preloader process in serial connection, so I check SERIAL_SUPPORT. Other settings keep unchanged.
Type "make" in SOC EDS 15.0 command shell to obtain preloader-mkpimage.bin
Write preloader-mkpimage.bin by typing alt-boot-disk-util on sd card with FAT32 partition and custom partition A2.
Create simple app in DS-5, compile it and obtain test.axf then convert it to test.bin using fromelf command and then convert it in test.img with mkimage tool.
Drag-n-drop test.img on sd card FAT32 partition.
Insert it in board and power up
Load .sof on board (my system FPGA-HPS)
Reset HPS by pressing reset button
So the problem is that there is nothing going on in serial connection so i thing that preloader isn't working at all, HPS reset not helping.
I don't see even "<0>" in terminal, just blank page.
I've tried prebuilt images with linux provided by Terasic they are working on 100%.
I do everything according altera docs but nothing is working.
Even official example altera-socfpga-hardwarelib-unhosted isn't working. I've tried to use their preloader from example, but in terminal window I see only "<0>" symbol when I reset HPS.
By the way App is working only in debugger DS5 with inserted SD card and loaded .sof file on board. I don't clearly understand the meaning and the way of writing of .scat file. Don't understand what load address and entry point should I use when I use mkimage tool when converting test.bin->test.img (should i do this convertion or use in BSP settings test.bin???) In my opinion main problem is incorrect preloader. What is the problem with it?
Please help!
UPD: After editing HPS part in QSYS (UART module was added) and re-generating system and re-building preloader (other previous settings was not changed) I started to receive correct messages in terminal about successfull loading of U-boot SPL. But still can't run test.img. Working on it.
UPD2: Ok, I solved this problem, now it's working fine

Sony A6000 failing to set exposure mode

I'm attempting to set the exposure mode of a Sony A6000 using smart remote version 2.0.1 by posting the following command: {'method': 'setExposureMode', 'params': ['Shutter'], 'id': 12, 'version': '1.0'}, but I'm getting back the following response: {u'id': 12, u'error': [500, u'Set operation failed.']}. I can't seem to find a description for error code 500 anywhere in the API documentation. I've used the same command to successfully set the exposure modes of NEX-5, NEX-6, and A5000 cameras. Is there something different I need to be doing for the A6000?
Nothing different as far as I am aware of. Please check code and other general things like current camera mode, also if camera has latest firmware, latest "Smart Remote Control" app, etc,.
Best Regards, Prem, Developer World team

Mac - Get Battery/Charging Status (Plugged in or not)

I'm building a Mac OSX app that needs to poll a server every minute, or even less if the user wishes. Unfortunately the service doesn't support push...
Anyways, I would like to provide two options to the user:
Polling interval on battery Polling
interval while charging
How would I get the state of the charger in Objective C? I don't really care about the actual percentage, only if the laptop is plugged in or not. Obviously, this doesn't matter for desktops, so hopefully there is a solution that works for laptops and desktops.
Have a look at the IOPowerSources API.
First call IOPSCopyPowerSourcesInfo(), then IOPSCopyPowerSourcesList() to get a list of all available power sources. IOPSGetPowerSourceDescription() will return a dictionary with information about a particular power source. According to the documentation, the key kIOPSPowerSourceStateKey describes "the current source of power. kIOPSBatteryPowerValue indicates power source is drawing internal power; kIOPSACPowerValue indicates power source is connected to an external power source."
You can also set up a notification when the power sources change with IOPSNotificationCreateRunLoopSource().
(NB: I haven't tested any of this, just looked at the documentation.)
Although this question does already have an accepted answer which led me to my solution, it was painful to click through lots and lots of broken links.
Here is my solution:
Add IOKit.framework
Import #import <IOKit/ps/IOPowerSources.h>
Code:
CFTimeInterval timeRemaining = IOPSGetTimeRemainingEstimate();
if (timeRemaining == kIOPSTimeRemainingUnlimited) {
// connected to outlet
} else if (timeRemaining == kIOPSTimeRemainingUnknown){
// time remaining unknown (recently unplugged)
} else if ((timeRemaining / 60) < 30){
// less than 30 minutes remaining
}