For introduction to NodeMCU and setting it up, visit here.
In this project we will print the latitude and longitude of the network host on an OLED Display with the help of NodeMCU. For this, we will use a NodeMCU, an OLED display as the hardware components and ipstack geolocation API, Aurdino IDE for the software components.
Using these OLEDs with Arduino sketches requires two libraries to be installed: Adafruit_SSD1306, which handles the low-level communication with the hardware, and Adafruit_GFX, which builds atop this to add graphics functions like lines, circles and text.The method of the installation of these libraries can be found in the inroductory section of the project.
NodeMCU is a system on a chip (SoC) design with components like the processor chip. The processor has around 16 GPIO lines, some of which are used internally to interface with other components of the SoC, like flash memory.
Since several lines are used internally within the ESP8266 SoC, we have about 11 GPIO pins remaining for GPIO purpose.
Now again 2 pins out of 11 are generally reserved for RX and TX in order to communicate with a host PC from which compiled object code is downloaded.
Hence finally, this leaves just 9 general purpose I/O pins i.e. D0 to D8.
The OLED we use here is a 0.96" 128x64 display. It has 4 pins-
- Power: It is used to power up the OLED,connected to the 3.3V pin on the NodeMCU.
- Ground: It is connected to the ground pin in the NodeMCU.
- SCL: It is a serial clock pin for OLED-NodeMCU interface.
- SDA: It is a serial data pin for OLED-NodeMCU interface.
- Open ipstack.
- Click on SIGN UP FREE then click on GET FREE API KEY.
- Fill the form and click on Sign Up.
- Copy the API access key.
For instructions on how to setup the google spreadsheet-NodeMCU communication refer to this link. The code for the spreadsheet can be found in this file.
- Copy the code from this file.
- Write your host name in place of 'SSID' and your password in place of 'PASS'.
- Replace 'YOUR_API_KEY' by the API key copied( see the process of setting up the api in the previous section).
Now connect your laptop with NodeMCU using a USB cable and upload the code.