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 the necessary resources from the main repository :
This repository include different projects:
- oneM2M-IoT-Device: The NodeMCU Sketch(es)
- oneM2M-IoT-Application: IoT applications written in Node.js & Python
- oneM2M-IoT-Device-Simulator: Node.js program to simulate various IoT sensors & actuators
You will also need an implementation of oneM2M platform. Different platforms exist, we can cite some :
- Eclipse OM2M: An open-source implementation in Java (link)
- ACME : An open-source implementation in Python (link)
- KETI Mobius : An open source implementation in Node.js (link)
For this tutorial, ACME implementation will be used. Refer to the official documentation for installing, configuring and running the platform.4. Start the oneM2M-compliant IoT 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: "acme.ini”.
4.2. Start the IoTPlatform
The IoT Platform can be launched through :
You should see at the end of the logs "CSE Started".4.3. Login to ACME web interface
Open the following URL in your browser to access the ACME IoT platform web interface: http://127.0.0.1:8080/
With the default configuration, enter the originator "CAdmin" and then "Connect"
You will be then able to see the oneM2M resource tree :
The NodeMCU source code is available on the folder "oneM2M-IoT-Device" folder.5.1. Schematics
Connect the LED and tilt 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.5. Configure the NodeMCU sketch
Open the sketch "NodeMCU_TiltSensor-LedActuator.ino" in your Arduino IDE.
Set your WIFI parameters
char* WIFI_SSID = "FILL_THE_WIFI_SSID";
char* WIFI_PSWD = "FILL_THE_WIFI_PSWD";
Set the IP address of the ACME IoT platform in your network :
String CSE_IP = "X.X.X.X";
Click on verify button to compile the sketch.
5.7. Upload the 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 ACME 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:
Open the file nodejs/config/default.json with your favorite text editor. and edit the necessary configuration parameters.
Set the IP address of the ACME platform (variable "monitorIP"). You can keep localhost (127.0.0.1) if you are running the ACME platform and the application in the same machine.6.1.B Python
Open the file python/default.json with your favorite text editor. and edit the necessary configuration parameters.
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
> npm install body-parser
> npm install request
> npm install yargs
> npm install config
Start the Node.js oneM2M IoT application using the following command:
> node onem2m-monitor.js -s Tilt -a Led
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 ACME 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.