A little box that monitors the mains current and average room temperature and sends the data through WiFi to a server for storage, display and analysis.
Uses a TMP36 temperature sensor (like this) and a non-invasive current sensor (like this one), coupled with a Wifi Shield (this one here).
The box is the same size as a conventional NF EN 60898-1, and NFC 61-410 compliant circuit breaker, so it fits in your electrical panel.
The repo contains :
The Arduino code is separated in different files, for ease of comprehension.
CentralCurrentAndTempLogger.ino
is just here so the Arduino IDE is happyhelpers.ino
define a general set of helper functions, like readVcc()
display.ino
contains all the initialization processes for the 7-segment and the led stripwifi.ino
contains all the functions to work with WiFicurrent.ino
has all we need to compute current and temperature sensorsmain.ino
and setup.ino
are self-explanatory.NB : these files are prefixed so that the compiler knows in which order to process them. This is required because in the Arduino IDE, there is no general file that imports every single file, so in order to define the compilation order, we need to rely on the filenames.
The configuration is stored in config.h
. You need to copy config.h.dist
to config.h
and put your own settings (wifi, key) in there.
If you want to change the payload, you might want to look at lines 66
to 72
in wifi.ino
:
client.print(encodedLength(str_temp) + encodedLength(str_power) + encodedLength(private_key) + 10);
client.fastrprint(F("\r\n\r\nt="));
urlEncode(client, str_temp, false, false);
client.fastrprint(F("&w="));
urlEncode(client, str_power, false, false);
client.fastrprint(F("&key="));
urlEncode(client, private_key, false, false);
NB : it is advised to compile and upload the code with the Arduino IDE 1.0.5 version that can be found here because the CC3000 shield is not really a big fan of the newer IDE releases.
Of course, the server can be any application that can accept and process requests such as :
POST 1.0 /data key=123456789ABCD&w=346&t=23.5
The Node.js server provided is a very simple logger that stores the values in a file.
To launch the server, you first need to copy config.json.dist
to config.json
and put your own settings (log name, api path, key) in there.
Then, as for every standard Node.js app :
node index.js
key
parameterIt's a very simple authentication system to prevent unwanted request to the server. Change for something only you know. The key must obviously be the same on the Arduino and on the server.
I created a custom PCB to hold the electronics (apart from the Arduino shield). It's designed on Fritzing which is a very practical tool.
The custom shield holds the connectors and some basic electronics. It is very simple to solder on your own.
BOM for the custom shield :
To create the PCB, I use Fritzing Fab as well.
Other parts needed :
The casing consists of 3 3D-printable parts :
All these parts are 3D printable on a regular Rep Rap or Makerbot Replicator 2 for instance. The STL files (watertight, ready for print) are available in the Design/Boîtier folder.
A first prototype
The CATIA files (.catpart and .catproduct) are available as well if you want to refactor them for your need.
To dim the displays and add a somehow nice touch to the objet, the fourth part is a little 3mm-thick plexiglass slap that can be cutted on a conventional laser cutter.
You can find the Illustrator file here.
Everything is released under the GNU GPL v2. Basically, you can reuse everything as long as you credit me somehow :)