Software apps and online services
In this project, we'll take a look at some some of the easy and simple examples that we include within our IDE, mcStudio! There are plenty more examples available within the mcScript guide and also within the product specification sheetsHow the platform works:
The mcThings platform includes 2 main components: mcModules and mcGateways. A powered and connected mcGateway creates the mcAir network (up to 200m range under optimal conditions) and bridges the information between the mcModules (within range) to and from the Internet. Using the IDE (mcStudio) and mcScript (ultra-low power programming language - a subset of VB.NET) allows you to wirelessly connect, debug and program modules with your customized scripts.
Note - You also require an mcDongle to complete firmware updates on the modules/devices and gateways! We recommend looking at the mcModule120 Dev kit which includes everything you need to get going!!
Here are two examples of programming the LED's on the mcModules. Both examples are included within the mcStudio.
*Note - The images below are shown using the mcMod110 which is now discontinued. The same examples work on the newest model, the mcMod120!*
Single LED Blinky:
This is a simple program to blink the red LED on the module at your custom interval. The example code is defaulted to turning on the red LED every 250 milliseconds. During the time when the module is not powering the red LED, it is sleeping (only consuming 2uA in sleep mode!)
// // This is a very simple blink a led program. It blinks the red led // Automatically, event driven, low power and very simple // Class Demo Shared Event BlinkRed() RaiseEvent Every 250 milliSeconds LedRed = Not LedRed End Event End Class
Double LED Blinky:
Another simple program to blink the two built-in LED's on the mcModules. The default for this example turns the green LED on every 2000 milliseconds and the red LED on every 1500 milliseconds.
// // This program blinks the two led's for a short time (100mSec) out of // sync with each other. Good example of multi-threading with mcScript // Class Demo Shared Event BlinkGreen() RaiseEvent Every 2000 milliSeconds LedGreen = True Thread.Sleep(100000) LedGreen = False End Event Shared Event BlinkRed() RaiseEvent Every 1500 milliSeconds LedRed = True Thread.Sleep(100000) LedRed = False End Event End Class
You can easily modify the above examples to turn on the LED at specific intervals as indicator lights or for whatever you wish. Some examples of using the LED along with other programming are:
- Use the LED to visually alert you (maybe if a temperature threshold is breached or some other variable you are measuring)
- Use the LED to indicate an event has happened (we've done this to provide a visual signal that a door is open or closed using the magnetic switch)
- Program the LED's to the same timing as your favorite song and impress your friends. If you do this, we want to see the video! :)
Obviously LED's are important as cues and signals when it comes to electronic hardware. The mcThings platform gives you the ability to easily program the LED's to your requirementsUsing the temperature sensor on the mcModule
Did you know that the mcModules have a built-in TMP102, a very low-power, high-accuracy temperature sensor!? Let's show you how it works:
Because mcScript is event based, you can program the modules to 'do' specific things at specific times and then view that information. To show you how the temperature sensor works and one way to view the data, we'll use the wireless debugging feature that is built-in to mcStudio.
Using the example code within the IDE, we are programming the module to check the temperature every minute and if it detects a temperature over 25 degrees Celcius, it will turn on the LED and keep the LED on until it detects a temperature lower than 25 degrees Celcius as it will continue to check every minute.
Class Temperature Shared Event GetTemp() RaiseEvent Every 1 Minutes LedGreen = True Dim TempC As Float = TempSensor.GetTemp Dim TempF As Float = TempSensor.ToFarenheit(TempC) If TempC > 25.0 Then LedRed = True Else LedRed = False End If LedGreen = False End Event End Class
In the below image, we've already connected to an mcModule via an mcGateway and will now run the code in debug mode to see the value that the mcModule returns. Note, the mcModules will use the RAM on the device to run your program during debug mode. If you load the programming into the module, it will store it in FLASH and continue to run the program until changed (this also means that if the battery is removed and replaced, the mcModule will continue to run the programming in it's memory!)
As you can see on the right hand side, the mcModule returned a temperature value of 23.125 degrees Cecius.
Having a built-in temperature sensor on the modules that is easy and quick to control is great for so many use-cases! A couple of things to note:
- Using the debug mode in mcStudio allows you to quickly and easily change variables and programming and then test it out before deploying it to an mcModule or mcDevice. This allows you to get your use-case going very quickly and if you do need to modify something afterwards, just connect to the mcModule/Device and change the programming to your needs!
- The above script also provides an example of how you can program logic on the 'node'. This is perfect for getting information only when you need it and to ask the mcModules to do certain 'things' when 'something else' happens
- The mcThings platform allows you to push information to the cloud (via the mcGateway) using IFTTT and MQTT. You can see examples of this in the below videos:
Keep an eye out for more projects from mcThings! We'll be showing you examples of using the built-in accelerometer, magnetic switch and we'll show you other projects where we connect other sensors to show you what is possible with mcThings!
Thanks for reading!