Login

How to

22

Apr'20

Send data from NodeMCU to Raspberry Pi using MQTT

Objectives Set up NodeMCU to communicate to an MQTT server Set up an MQTT server on Raspberry Pi Send data from NodeMCU to Raspberry Pi Things NodeMCU Breadboard Raspberry Pi Micro USB cable Let’s begin! MQTT is a communication protocol used to communicate between connected devices. Devices can publish data and several other devices can subscribe to the data published by other devices. In our case, the NodeMCU will publish data and the Raspberry Pi will be subscribed to the NodeMCU’s data. Note: If for any reason, you do not have Arduino IDE or NodeMCU installed on your Arduino IDE, follow the steps in this unit. Setting up the NodeMCU for MQTT Communication Install PubSubClient by Nick O’Leary on the Arduino IDE Step 1: Navigate to Sketch->Include library->Manage libraries… Step 2: Search for PubSubClient Step 3: Install the library PubSubClient by Nick O’Leary   Interfacing NodeMCU with IR sensor (analog)   View the code on Gist. Setting up Raspberry Pi for MQTT Communication We will install paho MQTT to use in Python and Mosquitto to use from the terminal. Update everything by typing following command, sudo apt-get update sudo apt-get install build-essential python-dev python-openssl Now let’s install a package called Mosquitto…

Read More

22

Apr'20

Headless Setup of Raspberry Pi

Objectives Enabling the server configuration of Raspberry Pi Connect to Raspberry Pi via Secure Shell (SSH) Connect to Raspberry Pi via PuTTY Access Raspberry Pi from a remote computer Things For this project we will be needing the following components and software Raspberry Pi 3B (quantity: 1 no.) microSD card (quantity: 1 no.) 5V power adapter and Micro USB cable A to B (quantity: 1 no.) WiFi router / mobile hotspot (quantity: 1 no.) Raspibian Stretch SD Card Formatter software and BalenaEtcher software Wireless Network Watcher. VNC Viewer software PuTTY. Let’s Begin! The Raspberry Pi is a series of small single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote teaching of basic computer science in schools and in developing countries. It does not include peripherals (such as keyboards and mice) and cases. However, some accessories have been included in several official and unofficial bundles. Now let us get started with setting up the Raspberry Pi. SD Card Formatter In the following units we prefer using the Raspbian OS as it is more flexible and preferred OS for the Raspberry Pi (RPi). To install the Raspbian OS on the sd card make sure the sd card is formatted as it already has the NOOBs OS installer in…

Read More

22

Apr'20

Interface buzzer module with NodeMCU

Objectives Interface a buzzer module with NodeMCU Things NodeMCU board (quantity: 1 no.) Micro USB cable A to B (quantity: 1 no.) Breadboard (quantity: 1 no.) Buzzer module (quantity: 1 no.) Jumper wire – male to male (quantity: 3 no.) Arduino IDE on your computer Let’s begin! A buzzer is an audio signaling device. Buzzers can be categorized into active and passive ones. The difference between an active buzzer and a passive buzzer is: An active buzzer has a built-in oscillating source, so it will make sounds when electrified. But a passive buzzer does not have such source, so it will not tweet if DC signals are used; instead, you need to use square waves whose frequency is between 2K and 5K to drive it. The active buzzer is often more expensive than the passive one because of multiple built-in oscillating circuits.   Interfacing buzzer module with NodeMCU   Final Code View the code on Gist. To copy the code, right click on view raw at the bottom of the code, click on open link in new tab and then copy the code. There you go! Takeaway

Read More

22

Apr'20

Interface LDR sensor module and RGB LED module with NodeMCU

Objectives Interface LDR sensor module and RGB LED module with NodeMCU Things NodeMCU board (quantity: 1 no.) Micro USB cable A to B (quantity: 1 no.) Breadboard (quantity: 1 no.) Common Cathode RGB LED module (quantity: 1 no.) LDR sensor module (quantity: 1 no.) Jumper wire – male to male (quantity: 7 no.) Jumper wire – male to female (quantity: 2 no.) Arduino IDE on your computer Let’s begin!   Interfacing LDR sensor module and RGB LED module with NodeMCU   Final Code View the code on Gist. To copy the code, right click on view raw at the bottom of the code, click on open link in new tab and then copy the code. There you go! Takeaway

Read More

22

Apr'20

Interface ADXL335 accelerometer with NodeMCU

Objectives Interface an ADXL335 accelerometer with NodeMCU Things NodeMCU board (quantity: 1 no.) Micro USB cable A to B (quantity: 1 no.) Breadboard (quantity: 1 no.) ADXL335 accelerometer  (quantity: 1 no.) Multiplexer MUX  (quantity: 1 no.) Adafruit Unified Sensor library Adafruit ADXL335 library Jumper wire – male to male (quantity: 4 no.) Arduino IDE on your computer Let’s begin! An ADXL335 is an analog accelerometer that gives the values of acceleration in three axes – X, Y, and Z. ADXL335   As the ADXL335 has three analog outputs and the NodeMCU has only one analog input – A0, we will use an analog multiplexer (MUX) to allow us to send data from three analog channels to one analog channel. For this project, we will use a 16-channel MUX.   16-channel MUX   Interfacing ADXL335 accelerometer and MUX with NodeMCU   Interfacing ADXL335 accelerometer and MUX with NodeMCU   Final Code View the code on Gist. To copy the code, right click on view raw at the bottom of the code, click on open link in new tab and then copy the code. There you go! Takeaway

Read More

22

Apr'20

Toggle action to control a vibration coin motor using NodeMCU

Objectives Toggle action (press – motor ON and press – motor OFF)  to control a vibration coin motor using NodeMCU Things NodeMCU board (quantity: 1 no.) Micro USB cable A to B (quantity: 1 no.) Breadboard (quantity: 1 no.) Vibration coin motor (quantity: 1 no.) Push-button (quantity: 1 no.) 1kΩ resistor (quantity: 1 no.) Jumper wire – male to male (quantity: 3 no.) Arduino IDE on your computer Let’s begin! Vibration coin motors are compact and convenient to use. They integrate into many designs because they have no external moving parts, and can be affixed in place with a strong permanent self-adhesive mounting system.     Interfacing a vibration coin motor using NodeMCU   Final Code View the code on Gist. To copy the code, right click on view raw at the bottom of the code, click on open link in new tab and then copy the code. There you go! Takeaway

Read More
top

Knowledge and Content by Li2 Technologies | © 2021 NASSCOM Foundation | All rights reserved

X