This hackster is an adapted version of the original hackster (https://www.hackster.io/onem2m/onem2m-demo-57022e). The original hackster has been adapted to accommodate the Hackaton needs, conducted by LAAS-CNRS Team.
1.High level architecture
The following tools are required to run this demonstration.
- Java Runtime Environment (JRE), at least 1.8
- Arduino IDE 1.8.9 (or later)
- Your favorite IDE to develop your IoT application
- Node.js environment OR Python environment
- Postman (Optional)
Download (a release of) the oneM2M Tutorial from Github from the following link:
The project contains the following folders:
- onem2m-platform: a (demo version) of an oneM2M compliant platform from SENSINOV
- onem2m-device: The NodeMCU Sketch(es)
- onem2m-application: IoT applications written in Node.js & Python
You may want to follow the project updates on GitHub : https://github.com/Samir-Medjiah-LAAS/oneM2M-Malaga4. Start the oneM2M IoT Platform
The oneM2M CSE is in : "oneM2M-Malaga/onem2m-platform"
4.1. Configure the IoTPlatform
The default configuration can be used for a local demonstration. The IoT platform will listen on port 8080. The database is reset after each restart.
If needed, you can change the configuration of the IoT Platform by editing the file: "onem2m-platform/configuration/config.ini”.
4.2. Start the IoTPlatform
The IoT Platform can be launched through the start script ("start.sh" on unix-like OS or "start.bat" on Windows OS).
You should see at the end of the logs "CSE Started".4.3. Login to oneM2M web interface
Open the following URL in your browser to access the oneM2M IoT platform web interface: http://127.0.0.1:8080/webpage
With the default configuration, enter the originator "Cae-admin" and then "Connect"
You will be then able to see the oneM2M resource tree :
The arduino source code and required libraries are available on the folder "oneM2M-Tutorial/oneM2M-IoT-Device".5.1. Schematics
Connect the LED and luminosity sensor to the NodeMCU board using the following components:
- NodeMCU board
- LED (or NodeMCU embedded LED)
- Tilt Sensor (SW-520D)
If not already installed, download and install the Arduino IDE from the following link: https://www.arduino.cc/en/Main/Software
NB: We don’t recommend to use the Arduino Web Editor for this demonstration because the NodeMCU board is not supported.
When plugged, if the NodeMCU port is not detected, then you need to download and install the USB driver manually using the following link: https://github.com/nodemcu/nodemcu-devkit/tree/master/Drivers5.3. Add NodeMCU board support to Arduino IDE
Firstly open the Arduino IDE, go to "Files" > "Preferences" entry.
Copy the below URL in the "Additional boards Manager URLS" Textbox :
Click "OK" to close the "Preferences" dialog box.
After completing the above steps, go to "Tools" > "Board:..." and then select "Board Manager"
Type in the textbox "esp8266", then navigate to "esp8266 by esp8266 community" and "install" the software for Arduino.
Go to "Tools" > "Board...", and then select "NodeMCU 1.0" board.
Once all the above process been completed, you are ready to program the NodeMCU board with Arduino IDE.5.4. Add Arduino “Timer.h” library
The “Timer.h” library is available on the zip folder “Timer.zip” under the folder : "onem2m-device/libraries/"
Go to "Sketch", and then select “include library”., choose the “Add.ZIP library” option.
Select the zip folder “Timer.zip” then confirm.
NB: You don’t have to extract the zip content.5.5. Configure the oneM2M sketch
Open the sketch "NodeMCU_TiltSensor-LedActuator.ino" in your Arduino IDE. This file is located in your "onem2m-device" folder.
Set your WIFI parameters
char* WIFI_SSID = "FILL_THE_WIFI_SSID";
char* WIFI_PSWD = "FILL_THE_WIFI_PSWD";
Set the IP address of the oneM2M IoT platform
String CSE_IP = "X.X.X.X";
Click on verify button to compile the sketch.
5.7. Upload the oneM2M sketch to theNodeMU board
Click on upload button to upload the sketch to the NodeMCU board.
Click on button to open the Arduino Serial Monitor to display the NodeMCU console.
Then after opening the Serial Monitor select 115200 from the drop-down list.5.9. Check IoT device resources on oneM2M web interface
You should see “TiltSensor” Application Entity resource with “DESCRIPTOR” and “DATA” containers created on the oneM2M web interface.
You should also see “LedActuator” Application Entity resource with “DESCRIPTOR”, “DATA”, and "COMMAND" containers created on the oneM2M web interface.
The tilt monitoring and led management application source code is provided in NodeJS and Python. The source code is available on the folder:
Set the IP address of the oneM2M platform (variable "monitorIP"). You can keep localhost (127.0.0.1) if you are running the oneM2M platform and the application in the same machine.6.1.B Python
Open the file onem2m-monitor.py with your favorite Python IDE or any text editor.
Set the IP address of the oneM2M platform (variable "monitorIP"). You can keep localhost (127.0.0.1) if you are running the oneM2M platform and the application in the same machine.6.2. Start the application6.2.A NodeJS
On a terminal, install the following Node.js modules using the npm tool (installed by default when Node.js is installed):
> npm install express
> npm install request
Start the Node.js oneM2M IoT application using the following command:
> node onem2m-monitor.js
On a terminal, install the following Python modules using the pip tool (can be installed when Python is installed):
> pip install requests
> pip install flask
Start the Python oneM2M IoT application using the following command:
6.3. Check IoT application resource on oneM2M web interface
> python onem2m-monitor.py
You should see
“Monitor” Application Entity (AE) resource created on the oneM2M web interface. Also check the creation of Subscription resource under
If you put the tilt sensor upright for few seconds, you should see the led switched ON by the monitoring application and vice versa. See the following picture to understand how the tilt sensor works.
Get the latest Content Instance resource
Get all Content Instance resources