In this tutorial you will learn, how to connect the NodeMCU to the Geeny platform.
- NodeMCU
- LED
- Resistors (220 and 10k)
- DHT22 sensor
- Breadboard and jumper wires
- Install Arduino IDE from Arduino.cc
- Go to Files>Preference (Mac: Arduino>Preferences) in the Arduino IDE
- Copy the below link in the Additional boards Manager field: http://arduino.esp8266.com/stable/package_esp8266com_index.json
- Go to Tools>Boards>Board Manager
- Search for esp8266 (by esp8266 community) and install it
- Select from Tools>Board the NodeMCU 1.0 (ESP12E module)
- Install USB driver from Silabs
- Copy the content of the Arduino Sketchfolder in this repository into your Arduino Sketchfolder
- Open Files>Examples>Basics>Blink
- Go to Tools>Port and select (usually) the last entry
- Upload the code to the NodeMCU: Sketch>Upload or click the upload button in the menu
- The LED should blink now
- Now change the circuit
- Change the sketch or open the file 1_blink.ino in the Arduino IDE
- Upload the code to the NodeMCU
- Change the circuit to this one
(Diagram made with Fritzing) 2. Open the Arduino sketch 2_DHT22.ino 3. After uploading the sketch, open the Serial Monitor
- Open the Sketch 3_DHT22Wifi.ino
- Change the Wifi credentials (to your network)
- Open the Serial Monitor
- Click the Reset Button on the NodeMCU -> It will say connected, if it connects properly
- Go to Geeny.io and create a new account
- Click on Become a developer (in the popup click skip)
- Click on Devices
- Click on Register a new Thing
- fill out the form:
- give it a name you like,
- a serial number (a new UUID e.g. from UUID Generator)
- and select the Thing Type NodeMCU+DHT22_1
- Click on Register this Thing
- Now a screen opens asking to download the certificate files. Save the files on your computer by clicking each file.
- On the Device overview page you see your newly created Thing. Click on See logs
- Copy the Thing-ID shown on top of the page and save it somewhere (BTW: this is where we will see the data later on)
For the NodeMCU we need the Certificates in a binary format. This is how to create it:
- Open a Terminal window and navigate to the folder where you stores the certificate files
- Enter the two following commands $ openssl rsa -outform der -in thing.key -out thing-key.der $ openssl x509 -outform der -in thing.crt -out thing-crt.der
- Now you should see two new files in your folder with the file extension .der
- Copy this files into the data folder of your Sketch (4_DHT22Geeny)
-
Download and install OpenSSL from slproweb (File: Win32 OpenSSL v1.1.0g Light)
-
Copy the Certificates to C:\Geeny
-
Open a Command Window (Windows+R and enter CMD)
-
Go to C:\OpenSSL-Win32\bin and run openssl.exe
-
Enter the two following commands $ openssl rsa -outform der -in c:\Geeny\thing.key -out c:\Geeny\thing-key.der $ openssl x509 -outform der -in c:\Geeny\thing.crt -out c:\Geeny\thing-crt.der
-
Now you should see two new files with the file extension .der in this folder
-
Copy this files into the data folder of your Sketch (4_DHT22Geeny)
-
In order to upload the certificates to the NodeMCE, you need this plugin for the Arduino IDE
-
In your Arduino sketchbook directory, create tools directory if it doesn't exist yet
-
Unpack the tool into tools directory (../Arduino/tools/ESP8266FS/tool/esp8266fs.jar)
-
Restart Arduino IDE
-
In the Tools menu set the CPU frequency to 160 MHz
-
Click on Tools>ESP8266 Sketch Data Upload
- In the Arduino IDE go to Sketch>Include Library>Manage libraries ... and search for PubSubClient
- Install the PubSubClient by Nick O'Leary library
- Open the Sketch 4_DHT22Geeny.ino
- Change the Wifi credentials (to your network)
- Change myThingID to the one you copied from the Device logs page
- Upload the sketch to your NodeMCU
- Check the serial monitor
That's all folks, but check out our Documentation Center to learn to build an application using the data we now connected.
Geeny.io @geeny.io
Stefan Hermann stefan.h@geeny.io @stefanhermann