Working with arduino and raspberry pi for sending information
Posted by : Tanveer Jan at
Category :
Application designed to sending data to user via MQTT. Arduino acts as the sensor connected via WiFi and communicate with broker, which is installed in Raspberry. MQTT Client app is required in ur phone to monitor the data you will receive.
###Hardware Requirements: Arduino Uno WiFi Rev2 Raspberry Pi 3B LCD Display (Optional) MQTTClient (Andriod/iOS).
Setting Up:
Raspberry Pi
First we need to setup the raspberry to work as broker, so we need to install mosquitto.
Here is the link to setup mosquitto on raspberry.
To use the new repository you should first import the repository package signing key follow the below comman, the wget command is used to download single file and stores in a current directory.
Then make the repository available to apt
Enter the following
for wheezy
for jessie
to install the mqtt mosquitto for the raspberry pi follow the below steps use sudo before the command if not using root
The above command is not mandatory ,it is if you wish to use root or you will need to prefix each below command with sudo eg sudo apt-get update
The below command is used to update the source list
After updating type the following commands to install mosquitto broker as shown in the image 1.
the above command is to install mqtt mosquitto broker.
Arduino
Below is the code to setup wifi connection and credential for connect to raspberry.
Certain things must be configured in order to make this network
WiFi credentials\n WiFi details are found in arduino_secrets.h file that is int he project directory, process is same as we did in the AWS IoT connection but without certificate. Certificate are only required if you are using SSL connection or some sort on encryption library like WolfSSL or SharkSSL.
MQTT broker details\n MQTT broker details are IP address of the broker, Port of broker and topic to which device is subscribed.