This is part of project to manage a coffee maker remotely. More details can be found here:
The script was developed in Javascript following ECMAScript 2016 and run on Node.JS. More details can be found here:
- Promise guide: Modern JavaScript Tutorial
- Arrow functions by Mozilla
- JavaScript: What the heck is a Callback? by Brandon Morelli
The full list of devices required are below:
- Android smartphone
- Raspberry PI 3
- Relay module
- Coffee maker
- Breadboard
- 2 float ball liquid sensor
- 2 resistors of 10k ohms
- Many jump wires with female and male header connectors
- Many jump wires with female and female header connectors
- Many jump wires with male and male header connectors
Then, the circuits should look like the image below:
The relay module is like our switch, it can open or close the electric circuit of the coffee maker. In other words, it's the device that turns on/off our machine. For more details of how a relay works, follow the next link:
First of all, we might end up accesing our Raspberry PI 3 on Wifi, so enabling SSH and setting up our SSID and password come handy.
Then, it's necessary to install Node.JS in order to be run the script on our Raspdian. Therefore, it's necessary to follow Node.JS. Nonetheless, it's thoroughly recommended to follow the NVM guide to manage both Node.JS and npm in an easier way.
Later, it's time to set up the libraries that will be part of our project.
- Onoff doc: The GPIO library that allow us to access GPIO Raspberry PI 3 pins.
- Firebase doc: Here's a complete guide detailed step by step to add Firebase library
Finally, install PM2 library globally in order to auto run our script on startup and monitor it.
Here's an article about Node.JS modules and an explanation about exporting primitive values by module.exports: