Build Your Own Charging Point for an Electric Car
ELIFTECHELIFTECH
It’s no secret that the Earth is running out of fossil fuels, so increasingly more people are hurrying to find alternative sources of energy and ways to produce them. Driving electric vehicles could be one of the solutions to reduce the use of fossil fuels and also mitigate a separate issue - the amount of CO2 emissions.
If electric cars are so useful, why isn’t everyone driving them yet? Two words: price and charging. Electric vehicles (EV) are currently too expensive for the mass market, and finding a decent charging station is no piece of cake. And while we cannot do anything about the first problem, we can help you build an EV charging point at home while smart cities play catch up.
Take a look at these statistics.
[caption id="attachment_13733" align="alignnone" width="750"]
EV batteries statistics[/caption]As you can see, the price of batteries (per kilowatt) has dropped more than 50%, and their capacity has more than tripled in the last five years. It seems that this trend will continue, especially when you look at countries like the Netherlands that have promised to give up petrol engines completely by 2025-35.
[caption id="attachment_13734" align="alignnone" width="750"]
Charging stations presented at the Plug-in Ukraine exhibition, March 2-4, 2018[/caption]In most cases, you can buy electricity for your vehicle using a specific mobile application. It will activate the power outlet that’s going to charge your electric car. But how does the power outlet know when and which electric vehicle to charge?
[caption id="attachment_13735" align="alignnone" width="750"]
Image Credit: Eliftech[/caption]Because the number of charging station constructors and supervision system suppliers has grown, there is a critical need for a standard communication protocol. The Open Charge Alliance (OCA) has decided to develop a standard communication protocol titled Open Charge Point Protocol (OCPP). It will allow different users to have a standard communication protocol and interconnect their systems.
Currently, protocol versions 1.0, 1.5 and 1.6 are available, while 2.0 is still in the draft stage. Versions 1.x support two data formats: SOAP and JSON. Depending on the format, you can find either OCPP-1.x-S or OCPP-1.x-J respectively. The Version 1.6 of the OCPP protocol consists of 28 operations, 10 of which are initiated by the charging station and 18 by the central system. You can find all these commands in the documentation.
The OCPP Version 2.0 will only support the JSON format. SOAP uses XML for data transmission and is too redundant. This is critical since filling stations connect to the Internet via mobile providers.
 // https://github.com/elifTech/cpd-ocpp/blob/pi/examples/centralSystem.js
cSystem.onRequest = async function (client, command) {
const connection = client.connection;
console.info(New command from ${connection.url}
);
switch (true) {
case command instanceof OCPPCommands.BootNotification:
client.info = {
connectors: [],
...command
};
return {
status: BootNotificationConst.STATUS_ACCEPTED,
currentTime: new Date().toISOString(),
interval: 60
};
case command instanceof OCPPCommands.Authorize:
return {
idTagInfo: {
status: AuthorizeConst.STATUS_ACCEPTED
}
};
case command instanceof OCPPCommands.StartTransaction:
return {
transactionId: 1,
idTagInfo: {
status: StartTransactionConst.STATUS_ACCEPTED
}
};
case command instanceof OCPPCommands.StopTransaction:
return {
transactionId: 1,
idTagInfo: {
status: StartTransactionConst.STATUS_ACCEPTED
}
};
case command instanceof OCPPCommands.Heartbeat:
return {
currentTime: new Date().toISOString()
};
case command instanceof OCPPCommands.StatusNotification:
const connectorIndex = client.info.connectors.findIndex(item => command.connectorId === item.connectorId);
if (connectorIndex === -1) {
client.info.connectors.push({
...command
});
} else {
client.info.connectors[connectorIndex] = {
...command
};
}
await cSystem.onStatusUpdate();
return {};
default:
throw new OCPPError(ERROR_NOTIMPLEMENTED, 'Unknown command');
}
};
cSystem.toggleChargePoint = async (client, connectorId) => {
const connector = client.info.connectors.find(item => connectorId.toString() === item.connectorId.toString());
if (!connector) {
return null;
}
if (connector.status !== StatusNotificationConst.STATUS_AVAILABLE) {
let command = new OCPPCommands.RemoteStopTransaction({
transactionId: connectorId
});
await client.connection.send(command);
return;
}
let command = new OCPPCommands.RemoteStartTransaction({
connectorId: connectorId,
idTag: '' + connectorId
});
await client.connection.send(command);
};
// https://github.com/elifTech/cpd-ocpp/blob/pi/examples/chargingPoint.js const client = new ChargePoint({ centralSystemUrl: `https://ocpp-example.herokuapp.com/webServices/ocpp/CP${Math.floor(Math.random() * 9999)}`, connectors: [ connector1, connector2 ] }); try { await client.connect(); client.onRequest = async (command) => { switch (true) { case command instanceof OCPPCommands.RemoteStartTransaction: setTimeout(() => startTransaction(command), 1); return { status: RemoteStartTransactionConst.STATUS_ACCEPTED }; case command instanceof OCPPCommands.RemoteStopTransaction: setTimeout(() => stopTransaction(command), 1); return { status: RemoteStartTransactionConst.STATUS_ACCEPTED }; } }; const boot = new OCPPCommands.BootNotification({ chargePointVendor: 'BrandX', chargeBoxSerialNumber: 'SR' + Math.round(Math.random() * 100000), chargePointSerialNumber: '123', chargePointModel: '12' }); let answer = await client.send(boot); await client.sendCurrentStatus(); } catch (err) { console.error('--- Err', err); } async function startTransaction({ connectorId }) { const idTag = 'test'; const authCommand = new OCPPCommands.Authorize({ idTag }); await client.send(authCommand); const statusCommand = new OCPPCommands.StatusNotification({ connectorId, errorCode: StatusNotificationConst.ERRORCODE_NOERROR, status: StatusNotificationConst.STATUS_CHARGING }); await client.send(statusCommand); const startCommand = new OCPPCommands.StartTransaction({ connectorId, idTag, meterStart: 0, timestamp: new Date().toISOString(), }); await client.send(startCommand); connectorId === 1 ? pin17.reset() : pin27.reset(); } async function stopTransaction({ transactionId }) { const statusCommand = new OCPPCommands.StatusNotification({ connectorId: transactionId, errorCode: StatusNotificationConst.ERRORCODE_NOERROR, status: StatusNotificationConst.STATUS_AVAILABLE }); await client.send(statusCommand); const startCommand = new OCPPCommands.StopTransaction({ transactionId, meterStop: 1, timestamp: new Date().toISOString(), }); await client.send(startCommand); transactionId === 1 ? pin17.set() : pin27.set(); }
[caption id="attachment_13736" align="aligncenter" width="336"]
Example of web user interface[/caption][caption id="attachment_13737" align="aligncenter" width="750"]
Existing commercial EV car charging station[/caption][caption id="attachment_13738" align="alignnone" width="750"]
EV Charger prototype components[/caption]To build a charging point prototype, you’ll need the following components:
Â
Â
Â
Â
No soldering required!
Now, let’s combine all the components into the right model. First things first — draw a simplified scheme of your product:
[caption id="attachment_13739" align="alignnone" width="750"]
Simplified scheme of your product[/caption]Next, attach the relay module to Raspberry PI 3 using a built-in GPIO port. We will connect Raspberry 3.3V, GPIO 17 and GPIO 27 and ground them according to the diagram. Keep in mind that your relay module should support 3.3V level triggering (the Raspberry port will not trigger 12V actuated models).
Check the Raspberry PI GPIO layout below to locate the GPIO17 and GPIO27 pins.
[caption id="attachment_13740" align="alignnone" width="750"]
Raspberry PI GPIO layout[/caption]Power up your Raspberry PI and verify the relay module:
[caption id="attachment_13741" align="alignnone" width="750"]
EV Charger prototoype components[/caption]Now, let’s make some power wire connections. The most convenient way to do this is using the WAGO conductors. We also recommend crimping the wire with proper connectors. The wiring should look like this:
[caption id="attachment_13742" align="alignnone" width="740"]
EV Charger prototype[/caption]Make sure to test the wiring before powering the high voltage part. We recommend that you do it with a multimeter and by replacing the 220V with a low voltage supply (like a 1.5V or a 12V DC battery).
[caption id="attachment_13745" align="alignnone" width="550"]
EV Charger prototype[/caption]Now, you are ready to install the software and set up your personal EV car charging station!
[caption id="attachment_13746" align="alignnone" width="750"]
EV Charger prototype[/caption]Written by Vitalii Savchuk, Head of Development Center, and Andrii Oleksiyuk, Software Architect at ElifTech.
The Most Comprehensive IoT Newsletter for Enterprises
Showcasing the highest-quality content, resources, news, and insights from the world of the Internet of Things. Subscribe to remain informed and up-to-date.
New Podcast Episode
Recent Articles