/BCEnergy-Application

Ethereum & MERN stack energy trading application

Primary LanguageJavaScriptMIT LicenseMIT

Introduction

In recent years, blockchain technology has gained increasing attention for its potential to create transparent and secure applications in various industries, including energy. By leveraging blockchain's decentralized and immutable nature, it is possible to develop a more efficient and trustworthy energy trading platform that enables consumers and prosumers to buy and sell energy using smart contracts. As part of my dissertation, I have created an energy trading platform that utilizes blockchain and smart contracts, incorporating both hardware and software components. This platform aims to provide a secure, scalable, and sustainable solution for energy trading while promoting the adoption of renewable energy sources.

Blockchain Energy Application

Blockchain Energy Application is an Ethereum-based MERN stack energy trading platform that provides a decentralized and secure environment for energy trading. The platform allows consumers and prosumers to trade energy using smart contracts, which are executed automatically once the terms of the contract are met. The platform also includes a smart meter prototype, which can be used to monitor energy usage and track energy transactions. The smart meter prototype is connected to the mongDb until reconcilation of the usage data to the blockchain, which ensures the accuracy and transparency of the data collected.

The energy usage data is stored in the smart contract, which allows for real-time tracking of energy consumption and billing. This provides consumers and prosumers with a more accurate and transparent view of their energy usage, and eliminates the need for traditional energy billing methods.

Features

Blockchain Energy Application offers several features, including:

  • Decentralized and secure energy trading platform
  • Smart meter prototype for real-time monitoring of energy usage
  • Automatic execution of smart contracts
  • Real-time tracking of energy consumption and billing

Running the Application

To run the application, follow these steps:

  1. Clone the repository to your local machine.
  2. Set up a MongoDB Atlas or Compass account and create a new cluster.
  3. Create a .env file in the root directory with the following variables:
    • NODE_ENV = [development or production]
    • port = [Port number for backend]
    • MONGO_URI = [MongoDB Atlas or MongoDB Compass URI]
    • JWT_SECRET = [Add secret key]
    • JWT_COOKIE_EXPIRE = [set number of days before cookie expires]
  4. Open a terminal and navigate to the project directory.
  5. Run npm install to install the project's dependencies.
  6. Start the server using npm run dev.
  7. Open a web browser and navigate to http://localhost:PORT to access the application.
  8. If MetaMask is not installed the broswer extension will need to be added.
  9. If running in development mode, truffle ganache can be used to imitate the main ethereum blockchain.

Technologies Used:

  • Ethereum
  • React
  • Node.js
  • MongoDB
  • Express
  • Axios
  • Toastify
  • MetaMask
  • Truffle ganache
  • Remix IDE
  • Aruino IDE
  • VS Code

Contributing

If you would like to contribute to the project, please follow these steps:

  1. Fork the repository
  2. Make your changes
  3. Submit a pull request

Roadmap

  • Add functionality so that the smart meter is recognised from the user "smart meter id" input unstead of mondogDB User collections id object.
  • Add support for energy generation, distribution and transmission.
  • Improve the user interface.
  • Add support for more currencies.

License

This project is licensed under the MIT License.

Smart Meter Prototype

Hardware Setup:

  1. Connect the INA219 power sensor to the ESP8266 dev board as shown in the schematic diagram provided in the Smart Meter Prototype folder.
  2. Connect the ESP8266 dev board to your computer using a USB cable.

Software Setup:

  1. Open the Arduino IDE on your computer.
  2. Select the correct board and port from the Tools menu.
  3. Open the ConsumerSmartMeter.ino or the ProsumerSmartMeter.ino sketch from the Smart Meter Prototype folder.
  4. Update the variables in the sketch to match your network settings and your Blockchain Energy Application's IP address.
  5. Copy the users objectID from the MongoDB Users ccollection to the UUID in the sketch.
  6. Open the Serial Monitor in the Arduino IDE to view the output from the ESP8266 dev board.

Integrating with Blochcain Energy Application:

  1. When the smart meter prototype is set up and connected to the network, open the BLockchain Energy Application.
  2. The application will now display the real-time energy usage data from the smart meter prototype.