Yet another M2M application?
|
Well, this greenhouse M2M application:
- uses open source M2M protocol and embedded framework,
- is programmed in Lua,
- can run on both cheap open hardware (which is perfect for a mockup!), and industrialized gateways & routers like Sierra Wireless ones (like in real life industry projects),
- and does not require you to be expert in embedded software programming.
Here's a the video of it*
Now, let me present you the application, and give you all the information you need, including all source code, to replicate it by yourself.
Would you have any comment or question, we'll do our best to support you on this forum topic.
|
Greenhouse M2M application
If you passed by Sierra Wireless booth at Embedded World Congress this year, you may have seen & played with this nice greenhouse M2M application using an Arduino, an AirLink GX400 gateway, the AirVantage M2M Cloud, and an Android application on a tablet, to remotely monitor the temperature, light and humidity, and control the greenhouse roof.
This end-to-end M2M application is composed of a mini greenhouse with 3 sensors: temperature, light and humidity, plus a motor to open/close the roof of the greenhouse, connected to an Arduino Uno.
The Arduino is used to simulate an industrial PLC talking modbus. It simply keeps updating a modbus register with sensors values, and returns the modbus register when someone asks for it.
The "intelligence" of the application resides in the Lua code running on a Linux gateway (here a ruggedized AirLink GX400, although the code provided below works on a simple Raspberry Pi as well). The application is developed using the ALEOS AF development tools which are based on the open source project Koneki. The Lua application uses the open source framework Mihini to query the arduino via modbus, compute the raw data (change integers values into physical entities, and detect changes), and update the server (AirVantage M2M Cloud) whenever a value has changed.
On the server side, we used the Corona (Lua as well) framework to develop and generate an Android/iOS application for smart phones & tablets, that query the AirVantage M2M Cloud API (REST/Jason) to get sensors values.
On a click action on the switch on the iOS/Android application, the mobile device sends a command to the remote gateway thru the M2M Cloud. On reception of this command, the Mihini/ALEOS AF application updates the modbus register to let the arduino know that the roof has to be opened/closed*.
*Note: unfortunately, this part is not demonstrated in the video because we broke the motor the day before registering the video.
Before you start
Before you rush into the implementation of this demo, I encourage you to:
- subscribe to Sierra Wireless Developer Zone to get access to source code and tutorials,
- subscribe an AirVantage trial account for developers, which is free of charge (although limited to 5 devices connected)
Bill of materials
Here's what you need to replicate this demo, hardware wise:
- A mini greenhouse (or a real big one?!), or anything else you'd need to monitor and command remotely
- An AirLink GX400 or GX440 device, or a Raspberry Pi (or any other Linux device compatible with the Mihini project)
- An Arduino Uno + the right USB power supply
- A Grove Kit or equivalent augmented with sensors/actuators of your choice (moisture + light + temperature + servo motor sensors + ant to replicate the exact same demo)
- RS232/TTL converter and a null modem adapter to connect the GX gateway to the Arduino
Get Started!
All the source code of the greenhouse demo is located
here. But, first of all, you'll need to:
- Get started with Arduino if you're not familiar with it: install & play with the development environment and the different sensors you have.
- Then, use the greenhouse arduino code. You'll have to install the Simple Modbus Slave library first (instructions here). Then use the GHDemo2 arduino code: take a close look at the pins used for each sensors, at the beginning of the file and ensure it matches your installation.
- On the GX, if you're not familiar with it, open the ALEOS AF home page and proceed to step 1 to intall it and run your first hello world program. If you're using a Raspberry Pi instead, check out this tutorial to get familiar with Mihini on Raspberry Pi.
- Register your gateway (either GX or Raspberry Pi) on your AirVantage trial account.
- Use the greenhouse Mihini demo code.
- With ALEOS AF development tools, generate an application for AirVantage.
- In AirVantage, deploy the application generated by ALEOS AF on your device.
- In AirVantage, check in the monitoring view that your device communicates with AirVantage (check the last communication date), and the application values change (last communication dates as well).
- Get started with Corona development environment, if you're not familiar with it already.
- Use the greenhouse Corona code. Replace the fake credentials by yours. Use the simulator to validate your application.
- Generate your application for your mobile device, and install it on your favorite device.
Done!
Links
Comment or get support on the forum