Smart MDB Controller
- About
- Getting Started
- Prerequisites
- Installation and Config
- Test
- Circuit
- Dashboard
- Built Using
- Authors
This repo contains circuit, firmware and backend for Smart MDB Controller Project.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
What things you need to install the software and how to install them.
- Raspberry Pi Model 3B, 3B+, 4B or CM4
A step by step series that covers how to get the Firmware running.
- Download and install the latest Raspberry Pi OS Desktop image to your SD card
- Open the terminal and execute the following command
sudo raspi-config
- Then follow the following pictures to enable I2C bus on you raspberry pi
- Copy FirmwareRPi folder to the desktop of your Raspberry Pi, open the terminal of your Raspberry Pi and execute the following commands
- sudo apt-get update
- sudo apt-get upgrade
- sudo apt install python3-pip
- pip3 install pyserial
- pip3 install paho-mqtt
- sudo adduser $USER dialout
- cd ~/Desktop/FirmwareRPi
- sudo chmod a+rx starter.sh
- To run the program just double click on starter.sh file
- or execute
python3 /home/pi/Desktop/FirmwareRPi/Firmware.py
This program make use of MQTT to communicate with the webapp.
+ broker used is borker.hivemq.com
+ vending can be done by publishing an ammount to mdb/invoke topic
The following packages should be installed on your PC
- AVR-GCC
- AVRDUDE
- avr-libc
On Ubuntu or any Debian based Linux distro execute the following commands
- sudo apt-get install -y gcc-avr
- sudo apt-get install -y avrdude
- sudo apt-get install avr-libc
- Open terminal in the atmega2560FW folder and execute
make clean
- Open makefile, replace P=COM1 to the COM port of your arduino mega and save the file
1. Compile it with
make all
- Upload it to your Arduino with
make program
- The Firmware can be tested on Raspberry Pi 3B, 3B+ or 4B with the following modifications
- Connect the sensor as shown in the Circuit Diagram section below.
- RPi 3,4 GPIOs Pinout
- Arduino Mega Pinout
Pins connections
Arduino Mega | Logic Level Shifter |
---|---|
TX2 |
RX1 |
GND |
GND |
HV |
5V |
RX2 |
TX0 |
Logic Level Shifter | Raspberry Pi |
---|---|
RX0 |
UART0_TX |
GND |
GND |
LV |
3.3V |
TX1 |
UART0_RX |
SN74HC14 | Arduino Mega |
---|---|
2 |
RX1 |
3 |
TX1 |
4 & 5 |
Shorted |
14 |
5V |
You can use the dashboard with the link below:
https://nodered-proxy.production.wrapdrive.tech/ui/#!/0
- The dashboard is running on a production server that is meant for testing only.
-You should install and configure the dashboard on your Raspberry Pi or local server to keep it running.
Conifguring NodeRED, MQTT is required only one time.
Open the terminal and execute the following commands
- sudo chmod a+rx starter.sh
- sudo apt install ufw
- sudo ufw enable
- sudo ufw allow tcp http https 1883 8883 1880
Open the terminal and execute the following commands
- sudo apt install -y mosquitto mosquitto-clients
- sudo systemctl enable mosquitto.service
- mosquitto -v
Open the terminal and execute the following commands
- bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
- sudo systemctl enable nodered.service
- npm install node-red-dashboard
- sudo npm install node-red-dashboard
- sudo systemctl restart nodered.service
Then open NodeRED in your raspberry pi or using any other device which is connected to the same network as your Raspberry Pi is. In the browser you can type http://raspberrypi.local:1880 to open the node-red
- Once node-red is opened, click on the menu button on the top left corner of the app and click on import.
- Click on
select file to import
and select flows.json present in thedashboard
directory of this repo. - After flows are imported, click on Deploy button on the top of the screen to save the changes.
- You can access the Dashboard using http://raspberrypi.local:1880/ui
- Raspberry Pi
- Logic Level Converter
- SN74HC14 Hex Inverter
- PC817 Optocoupler
- Arduino Mega
- 330 Ohm Resistor
- 1N4007 Diode
- Optocoupler OHPC 817C F919G
- Schimitt Trigger Hex Inverter PHILIPS 74HC14N B9784PS Hnn9840 E
- Diode 1N4007 MIC AXIAL SILASTIC GUARD JUNCTION STANDARD RECTIFIER
- @Nauman3S - Development and Deployment