Intro: Nabito [Open Socket V2]: Smart Meter for EV Charging
This is the second build guide for Nabito [open socket), the first version can be found at: Nabito [open socket] v1
I list the reasons for creating this project in this blog post: EVs are pointless for apartment people
What is it?
Nabito - the open socket is an IoT smart meter with electricity metering, on/off high amperage switching, NFC sensor, user authorization, billing capabilities and user management.
The project consists of two parts: 1. control box (IoT device) 2. web app frontend/backend, both completely open-source.
1. The control box consists of easy-to-get-online parts and is designed to be an intelligent and yet inexpensive electric socket solution for public and private parking lots for slow charging of electric vehicles. It runs on Raspberry Pi Zero W and Arduino Nano.
2. The web app runs on Ruby on Rails and is available as open source on Github: https://github.com/sysdist/nabito-server The connection between the box and the web app is done through MQTT protocol.
The aim of the project is to develop an open source charging network that anyone could adopt and implement or extend.
The control box consists of easy-to-get-online parts and is designed to be an intelligent and yet inexpensive electric socket solution for public and private parking lots for slow charging of electric vehicles.
It runs on Raspberry Pi Zero W single-board computer (SCB). The total cost of the control box is around €60.
Nabito - the open socket is currently designed for charging on ordinary sockets, in continental Europe it's 230V and 10 -13A, i.e. cca. 2.9kW continuous. But the concept applies to any socket, Euro, US or UK or any other, future versions of the project will cover also 2 and 3 phase installations.
- Single PhaseVoltage: 230 V
- ACMax. current: 13 A
- Power: 2.9 kW
- Size: 240x200x90mm
- Interface: RJ45 LAN connection or WIFI
- IP compliance: IP55
The following build guide is not complete, it's missing some wiring diagrams, some assembly steps, etc.), I wanted to get it out there as soon as possible, will work on improving it gradually, so please, if this build guide does not cover everything you need to know or if you have any questions, send me a mail. Thanks for understanding.
Step 1: What Does It Do?
The project consists of two parts, the physical control box which is an IoT thing (client side) and there is a Web application that controls it (server side).
1. On/Off switching
With a mains relay and a contactor it can switch the outlet socket on/off based on user interaction.
2. Energy metering
The control box measures AC current and logs power usage. Standard metering function. The energy metering is done per user. Currently there is only AC current monitoring, no voltage monitoring at this point.
3. User authentication
You need to create user accounts for the users who will be using the socket/s. The user authorizes by reading the QR code or using an NFC tag. The web user interface allows users to sign up, log in and use the control box or the NFC tag switches the box on/off directly. Admin can approve, disapprove users.
Based on admin's socket configuration and price per 1kWh bills are created for individual users based on their energy usage. Monthly bills will be created later for admin convenience.
Step 2: HW and SW Stacks
- Raspberry Pi Zero, 1pcs, €11.32, http://rpishop.cz/rpi-zero-sady/647-raspberry-pi-...
- heat sink, 1pcs, €1.2, https://www.aliexpress.com/item/Orange-Pi-Pc-Alum...
- NFC sensor, 1pcs, €3.93 https://www.aliexpress.com/item/PN532-NFC-RFID-Mo...
- micro SD card 16GB, 1pcs, €9.4, https://www.hej.sk/pamatova-karta-sandisk-micro-s...
- Arduino Nano, 1pcs, €1.74, https://www.aliexpress.com/item/Freeshipping-20PC...
- CT sensor - YHDC 30A SCT013 , 1pcs, €4.28, https://www.aliexpress.com/item/KSOL-YHDC-30A-SCT013-0-100A-Non-invasive-AC-New-Sensor-Split-Core-Current-Transformer-New/32768354127.html
- mobile phone charger, 1pcs, €5, price is approximate, used one of my old chargers that came with a phone
- Household AC contactor 25A NO, 1pcs, €4.79, https://www.aliexpress.com/item/CT-1-2P-25A-220V-...
- Mains relay, 1pcs, €0.84, https://www.aliexpress.com/item/5V-One-1-Channel-...
- plastic junction box (S-box), 1pcs, €5, https://eshop.vikon.sk/s-box-250x200x90mm-ip65-g1...
- Dupont junction wires for low voltages, 1pcs, €2.29, https://www.aliexpress.com/item/120pcs-Dupont-10C...
- IP54 230V Euro socket, 1pcs, €2 bought at a local hardware store
- small parts: 3.5mm jack female, 10uF capacitor, 2x 10kOhm resistors, LED diodes, cables, 1pcs, €3, bought at a local electronics store
- Wago 2-conductor terminal block, 3pcs, €2, bought at a local electronics store
- Wago 5-conductor terminal block, 2pcs, €2, bought at a local electronics store
- USB mini-to-micro cable (Arduino->RPi), 1pcs, €1.8, bought at a local computer's store
Total HW cost: €60.59 ($70.40)
- Control Box stack:
- Raspbian Linux (Ubuntu based), open source, $0 (all glory to Linus Torvalds + 20k people who worked on Linux kernel + the kind people behind Raspberry Pi and Raspbian Linux image)
- Node-RED, open source, $0 (kind people from IBM that are behind the development of Node-RED)
- Nabito-server app: https://github.com/sysdist/nabito-server
- Ruby on Rails (RVM, Ruby, Gems), open source, $0
- Postgres DB, open source, $0
- Git, open source (more glory to Linus), $0
- MQTT protocol
Total SW stack cost: €0 (*THUMBS_UP*)
Step 3: The Control Box: SW Setup
- Install RASPBIAN STRETCH LITE (we don't need the desktop version) on Raspberry Pi Zero W
- configure Raspbian to use your local home Wifi
- Install Node-RED on Raspbian
- Copy Nabito Node-RED flow and deploy it
- Edit default Node-RED settings.js and add this to the functionGlobalContext:
- Configure your Node-RED MQTT brokers towards your preferred Nabito-server installation (or towards http://nabito.org)
- Restart Node-RED
- Check the MQTT connectivity in Node-RED
- Download, compile and upload this sketch to Arduino Nano
- Done! ;-)
Step 4: Wiring: Mains Cables
The AC mains cables supply power to the:
- AC contactor
- Mains relay
- Mobile charger that powers Raspberry Pi and Arduino
The output from the AC contactor goes to the outlet socket. Protective earth is connected from the source mains line to the outlet socket.
Raspberry Pi controls the mains relay and the relay in turn switches on/off the contactor.
Step 5: Wiring: Arduino, CT Sensor, NFC Sensor
Wire the Arduino with the CT sensor according to the following manual:
- Arduino (you can use any Arduino: Uno, Nano, Mega, whichever you like, as long as it has an ADC)
- 10uF capacitor2x 10kOhm resistors
- 3.5mm female jack socket
- CT sensor 30A/1V
- PN532 sensor (RFID/NFC)
- small PCB
- small wires for connections
I soldered the Arduino Nano, the capacitor, the resistors and the female jack to the PCB according to the above manual from the openenergymonitor.org site.
The NFC sensor is connected to the Arduino Nano through SPI (pins on Arduino Nano: 10, 11, 12 and 13).
The Arduino is connected to the Raspberry Pi via the micro USB.
Step 6: Wiring: Raspberry Pi
Connect Arduino to the Raspberry Pi via the USB port, this way it serves as a serial port and a power supply for the Arduino, it should map to /dev/ttyUSB0.
The mains relay is connected through pins 2 (5V), 6 (GND), 12 (GPIO).
The front-panel LEDs are connected through pins 14 (GND),16 (GPIO),18 (GPIO)
Step 7: Wiring Everything Together
- Clamp the CT sensor on the mains line going out of the mains relay
- Connect power source for Raspberry Pi
- Screw in the junction box lid
- And you're done wiring/assembling!
Step 8: Web App Setup
You need a linux server to run the web app. You can either:
- run the server locally on your PC/notebook or your local Linux server and point the control box[es] to your local installation
- create your own domain and run the web app as a website
- use http://Nabito.org (it's free) to manage your control boxes
Nabito-server app runs on Ruby on Rails and is open source:
For web app installation and setup refer to the project's README.md on Github.
Step 9: Running and Testing
For local setup:
- Deploy the Nabito-server app on your local PC/notebook
- Configure mosquitto MQTT broker on your PC (or any other MQTT broker of your preference)
- Connect the Nabito control box to your local WiFi
- SSH into the box and direct it to use your PC's MQTT broker
- start the rails nabito-server app
- connect a small electrical load (e.g. a table lamp) to the outlet socket
- use the web app to start/stop the socket id 1 to check the actual and total energy consumption
- use an NFC tag (if you have one) to toggle the socket
- check the billing for the last socket usage
- After successful testing, start creating your own EV charging network
- Profit ;-)
Step 10: The Conclusion, Issues and Product Roadmap
In this version of the Nabito control box I was able to decouple the control box and the web app essentially creating an IoT (Internet of Things) project with both the physical thing that does something useful and a back-end app and service that manages the physical thing.
The price of the box increased a little bit from the last version (v1 before: €50, v2 now: €60), because I added a contactor for safety purposes to serve higher amps and also RPi is a bit more expensive then OrangePi boards.
MQTT is used as the main protocol for data logging and controlling the box.
Since the last version of Nabito, I was able to solve most of the issues (Wifi, contactor, processor overheating, integrated outlet socket, etc.). However the list of current issues and opportunities grows further:
- Raspberry Pi Zero W is a very nice board, with Wifi and Bluetooth and 2 GPIO pins, but still the processor heats up to 34C when idling which could be problematic in warm climates and summer months with direct sunlight
- Running Linux in the control box is good for prototyping, but the production model of this product should probably run on a leaner board which is capable of TLS/SSL (chip ESP32 looks very promising)
- create versions for higher currents (functionality the same, but use contactors with higher amps and different CT sensors/energy monitor modules)
- create versions for 2 and 3 phases
- integrate energy monitor module (like the Peacefair PZEM-004T Energy monitor)
- migrate to ESP32 for increased power and heat efficiency
- integrate to AWS IOT cloud and use client certificates for best security setup (right now only MQTT user/password is used)
- manage certs and MQTT credentials from the web app (currently this is manually configured thru back-end)
- add small LCD panel to present info directly on the Nabito control box
- add numpad to provide button interaction with the box (pin possibility for increased security)
- include additional thermometer to monitor the ambient temperature of the box
If you like this project or have any questions/comments please feel free to contact me at firstname.lastname@example.org
Systems distributed website: www.sysdist.com
Have a nice day and happy making!