My NodeMCU development board arrived the other week and I was keen to get it in a project as soon as possible. Way before I started to tinker with electronics I was browsing one of my favorite sites hackster.io and remember seeing an air quality IoT project done with a Raspberry Pi which was embedded in taxi signs which was very impressive. I decided that this would be the first project (or at least a flavor of) I would use my new board for.

The Project

Despite owning a variety of Raspberry Pi models, I decided that this would not be the approach I would take. This is due to the fact that it is maybe a little overkill hardware wise in my opinion. The only requirement that I needed was the ability to make a POST request to a URL to persist sensor/module readings. I didn’t want to store any data within the EEPROM on the Arduino, nor to an SD card (though that could have been a better possibility).

Initial prototype

For the initial prototype, It was more of a proof of concept. I wanted to make sure that whatever I built could utilize my phones personal hotspot and make a connection to a server to persist readings successfully.

 

The hardware

  • Arduino Nano
  • Jumper Wires
  • Breadboard
  • Ublox NEO-6M GPS Module.
  • ESP8266 WiFi Module.
  • 3.3v/5v Breadboard Power Supply

The Software

  • .NET Core API
  • Entity Framework Core with SQLite
  • C/C++ (Arduino) for hardware interfacing and network request code.

Apart from the wires being messy, the prototype worked. Every two minutes or so, if the circuit had a valid GPS fix and a network connection, it would form a POST request to the API and persist the Longitude and Latitude readings. There was a bit of setup with DNS and port forwarding to get it working with the IIS website it was running on, but apart from that, it was pretty smooth sailing.

The main reason my go to Arduino was the Nano was due to its form factor. There are fewer pins available but that wasn’t a problem, I could easily fit what I needed on there whilst taking up much less space, which is important for project housing at a later stage.

However, this design became a little bit of a nightmare due to the fact that the Arduino Nano needed the ESP8266 module for network connectivity which is 3.3v, the GPS module also needs 3.3v at the same time. My 5v power bank I was using to power the project barely managed to do this and so I had to use the breadboard power supply set at 3.3v for the GPS and the 3.3v output from the Arduino for the ESP8266.

This was both ugly and annoying. It wasn’t even on perfboard yet, not even to mention the fact I hadn’t even wired up the sensor either (which is another 5v). The way around this could have been using something like a 5v/3.3v Logic level converter like one of these. I sought to find something more streamlined for this project and settled with the NodeMCU, pretty much because of the integrated ESP8266.

 

 

Current Prototype

The current prototype I have built over the past few days uses a different board, includes the Gas sensor used for air quality and now runs using serverless functions in Azure cloud.

The hardware

  • NodeMCU 12-E Board
  • Jumper Wires
  • MQ-135 Gas Sensor
  • Ublox NEO-6M GPS Module.

The Software

  • Azure Serverless Functions
  • Azure CosmosDB
  • C/C++ (Arduino) for hardware interfacing and network request code.

The current prototype works pretty much the same way as the previous one besides the fact that now the requests are now handled by serverless functions that persist and retrieve the data to & from an Azure CosmosDB instance. I plan to use the JSON data in an Ionic app with the Google Maps Javascript SDK for getting pinned location & sensor readings onscreen.

Code?

Oh, I forgot about that. Here is a Gist for the microcontroller code. Essentially, the code attempts to connect to a network and sends the GPS & sensor readings to Azure once initialized. There are also other code Gists for the insertion and the retrieval of data via the serverless functions in Azure.

Whats Next?

Whats next is trying to persist the design to perfboard or something similar. I have created a socket for the NodeMCU board that looks something like this:

 

I have done this to prevent anchoring the board to the project. If I fancy using this board for anything else, It will solve desoldering wires. Not to mention, the version of board I have IS NOT breadboard friendly, for it is too wide. This method allows you to hook it up to a breadboard.

 

Besides that, I’m trying to find a SIM module such that I can stop depending on my phones personal hotspot (I guess this then makes the WiFi module redundant anyway). I have ordered a SIM 800L module and will update the post should I have any luck with that, I think that apart from GPRS connectivity and creating the app there isn’t much else to do.