0% found this document useful (0 votes)
67 views28 pages

Raspberry Pi4 Project Board User Manual VTU

Uploaded by

Lohit Dalal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views28 pages

Raspberry Pi4 Project Board User Manual VTU

Uploaded by

Lohit Dalal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

TMI-ALS.

ALS-XT-IoT-PRJBRD-RBPi-01

RASPBERRY Pi IoT
PROJECT BOARD
USER MANUAL

1 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

TABLE OF CONTENTS
1. INTRODUCTION........................................................................3
2. RASPBERRY Pi 4 PROJECT BOARD SPECIFICATIONS....................4
3. HARDWARE DETAILS.................................................................6
3.1. Raspberry Pi 4 Model B.......................................................6
3.2. Connection Details..............................................................7
4. INSTALLATION PROCEDURE...................................................11
5. ON BOARD INTERFACE...........................................................13
5.1 OLED Display.....................................................................13
5.2 MCP3008...........................................................................13
5.3 Switches and LED's............................................................14
5.4 Stepper Motor...................................................................15
5.5 Buzzer...............................................................................15
5.6 Relays...............................................................................16
5.7 LM35.................................................................................16
5.8 Light Sensor.......................................................................17
5.9 Temperature and Humidity Sensor....................................18
6. LIST OF EXPERIMENTS...........................................................19
7. EXTERNAL SENSORS SUPPORT..............................................22
8. THINGSPEAK CLOUD.............................................................23
9. TROUBLESHOOTING..............................................................27
10. REFERENCES.........................................................................27

2 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

1. INTRODUCTION
The Raspberry Pi IoT Project Board designed to be a comprehensive tool to accelerate
learning of IoT Fundamentals and apply the concepts to get Hands-On experience by
performing different experiments. It can also be used by students and faculty alike to
implement projects based on IoT concepts. Flexibility is at the heart of the Kit, and
accordingly the students and faculty can not only use the hardware on the board in
imaginative ways, but also innovatively write programs to try their own use cases. This user
manual provides the descriptions of the features and also examples of use cases, to guide
the students to use it effectively.

This Raspberry Pi Project Board has a Raspberry Pi 4 Model B Controller. It helps the
students perform IoT related experiments based on the requirement. It provides all the
open ports to connect various multiple sensors which helps the students to develop number
of applications based on IoT. It also supports different hardware communications protocols
like i2C and SPI. The kit has two on board sensors like temperature sensor; light sensor and
an externally connected DHT11 sensor to perform IoT end to end operation from sensors to
cloud. As the kit has internal Wi-Fi module the students can send the different sensors
information to the cloud. One can write the code using different Python IDEs like Thonny,
IDLE and Geany.

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01
3 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

2. RASPBERRY Pi 4 PROJECT BOARD SPECIFICATIONS

Fig. 2: Raspberry Pi 3 IoT Project Board

Hardware Description:
1. Raspberry Pi 4 Model B.
2. 5V & 3.3V Power Supply Section.
3. MCP3008.
4. OLED.
5. Stepper Motor Interface.
6. Relay Modules – 2 nos.
7. Buzzer.
8. Switches – 2 nos.
9. LEDs – 2 nos.
10. Light Sensor.
11. LM35 Temperature Sensor.
12. DHT11 Humidity and Temperature Sensor (External).
13. DC Motor (External).

4 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

Specifications:
 The Board is driven using Raspberry Pi 4 Controller.
 Facilitates MQTT or HTTP application protocol connection to various IoT cloud
platforms such as Thingspeak, AWS.
 It can be connected to a Private Cloud.
 On board voltage regulator for generating 3.3V from +5V input through power supply
/adapter.
 Internal Wi-Fi connectivity through which board can be connected to internet
through Router.
 On board simple analog sensors like Temperature and Light.
 Onboard ADC MCP3008 to connect analog sensors to raspberry pi 3.
 On board Organic LED Display to display colorful text as well as images.
2 LED's and 2 Switches.
 On board stepper motor driver to drive 5V stepper motor.
 One Buzzer.
 Internal Bluetooth 4.2 to communicate with other Bluetooth modules or mobile Apps.
 Provided extra connectors for connecting external analog and digital sensors so that
students can explore their projects.
 I2C, SPI communication protocols.
 On board Relay to drive external device (DC Motor).
 DHT11 Sensor (External Interface).
 Several onboard outputs can be accomplished through events from cloud such as
turning on LED’s or sending a test message to the display is possible.
 Outputs can be programmed to be event or threshold driven.
 Performance of IoT experiments and design / implementation of student projects
possible including provision to write their own programs.

5 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

3. HARDWARE DETAILS
3.1. Raspberry Pi 4 Model B.

Fig. 3.2: Raspberry Pi 3 B+.

Specifications:

 Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.8GHz
 1GB, 2GB, 4GB or 8GB LPDDR4-3200 SDRAM (depending on model)
 2.4 GHz and 5.0 GHz IEEE 802.11ac wireless, Bluetooth 5.0, BLE
 Gigabit Ethernet
 2 USB 3.0 ports; 2 USB 2.0 ports.
 Raspberry Pi standard 40 pin GPIO header (fully backwards compatible with
previous boards)
 2 × micro-HDMI® ports (up to 4kp60 supported)
 2-lane MIPI DSI display port
 2-lane MIPI CSI camera port
 4-pole stereo audio and composite video port
 H.265 (4kp60 decode), H264 (1080p60 decode, 1080p30 encode)
 OpenGL ES 3.1, Vulkan 1.0
 Micro-SD card slot for loading operating system and data storage
 5V DC via USB-C connector (minimum 3A*)
 5V DC via GPIO header (minimum 3A*)
 Power over Ethernet (PoE) enabled (requires separate PoE HAT)
 Operating temperature: 0 – 50 degrees C ambient

6 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

3.2. Connection Details.


3.2.1 U1 Connector: 40 pin 20X2 Header is connected to the Raspberry pi 4 B.
Pin Description Pin Description
1 (3.3V) 2 (5V)
3 I2C1 SDA / GPIO 2 4 (5V)
5 I2C1 SCL / GPIO 3 6 GND
7 P7/GPIO 4 8 P8/GPIO 14/ TXD (UART)
9 (GND) 10 P14/GPIO 15/ RXD (UART)
11 P11/GPIO 17 12 P12/GPIO 18/ CM_CLK
13 P13/GPIO 27 14 (GND)
15 P15/GPIO 22 16 P16/GPIO 23
17 (3.3V) 18 P18/GPIO 24
19 P19/GPIO 10/ MOSI (SPI0) 20 (GND)
21 P21/GPIO 9/ MISO (SPI0) 22 P22/GPIO 25
23 P23/GPIO 11/ SCLK (SPI0) 24 P24/GPIO 8/ CS0 (SPI0)
25 (GND) 26 P26 /GPIO 7/CS1 (SPI0)
27 Reserved (P27/ID_SD(I2C)) 28 Reserved (P28/ID_SC(I2C))
29 P29/GPIO 5/ GPCLK1 30 (GND)
31 P31/GPIO 6 32 P32/GPIO 12
33 P33/GPIO 13 34 (GND)
35 P35/GPIO 19 MISO (SPI1) 36 P36/GPIO 16/ CS0 (SPI1)
37 P37/GPIO 26 38 P38/GPIO 20/ MOSI (SPI1)
39 (GND) 40 P40/GPIO 21/ SCLK (SPI1)
3.2.2 J1 Connector: 2 Pin Male Burg connector From LM35.
Pin Description
1 DATA
2 VCC
3.2.3 J1A Connector: 2 Pin Male Burg connector to Raspberry Pi 4 from LM35.
Pin Description
1 A0
2 VCC
3.2.4 J2 Connector:2 pin Male Burg Pins from LDR Module.
Pin Description
1 DATA
2 VCC
3.2.5 J2A Connector:2 pin Male Burg Pins to Raspberry Pi 4 from LDR Module.
7 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

Pin Description
1 A1
2 VCC
3.2.6 J3 Connector: 4 Pin Male Burg Pins from OLED.
Pin Description
1 GND
2 VCC
3 SCL
4 SDA
3.2.7 J3A Connector: 4 Pin Male Burg Pins to Raspberry Pi 4 from OLED.
Pin Description
1 VCC (GND)
2 GND(VCC)
3 SCL
4 SDA
3.2.8 J4 Connector: 5 Pin Male Burg Pins from LED & Switches.
Pin Description
1 L1
2 L2
3 S1
4 S2
5 VCC
3.2.9 J4A Connector: 5 Pin Male Burg Pins to Raspberry Pi 4 from LED & Switches.
Pin Description
1 P31
2 P33
3 P35
4 P37
5 VCC
3.2.10 J8 Connector: 4 Pin Male Burg Pins from Relays & Buzzer.
Pin Description
1 RLY1
2 RLY2
3 BUZ
4 VCC
3.2.11 J8A Connector: 4 Pin Male Burg Pins to Raspberry Pi 4 from Relays & Buzzer.

8 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

Pin Description
1 P36
2 P12
3 P38
4 VCC
3.2.12 J9 Connector: 5 Pin Male Burg Pins from Stepper Motor.
Pin Description
1 IN1
2 IN2
3 IN3
4 IN4
5 VCC
3.2.13 J9A Connector: 5 Pin Male Burg Pins to Raspberry Pi 4 from Stepper Motor.
Pin Description
1 P16
2 P18
3 P22
4 P32
5 VCC
3.2.14 J12 & J13 Connectors: 2 Pin Male Burg Pins for I2C
Pin Description
1 SDA
2 SCL
3.2.15 J10 & J11 Connectors: 4 Pin Male Burg Pins for SPI Connection.
Pin Description
1 D10 (P23)
2 D11(P21)
3 D12(P19)
4 D13(P24)

3.2.16 J14 & J15 Connector: 15 Pin Male Burg Pins for External GPIO Pins.
Pin Description
1 P11
2 P13
3 P15
4 P29

9 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

5 SDA
6 SCL
7 P16
8 P18
9 P22
10 P26
11 P27

12 P28
13 P32
14 P40
15 P12
3.2.17 J16 & J17 Connector: 12 Pin Male Burg Pins for External GPIOs.
Pin Description
1 P29
2 P31
3 P7
4 P33
5 P35
6 P37
7 P36
8 P38
9 P24
10 P19
11 P21
12 P23

3.2.18 J18 Connector: 10 Pin Male Burg Pins for GND.


3.2.19 J19 Connector: 10 Pin Male Burg Pins for VCC (5V).
3.2.20 J20 Connector: 10 Pin Male Burg Pins for 3.

10 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

4. INSTALLATION PROCEDURE
Installing Raspbian OS for Raspberry Pi 4 Model B using Raspbian Stretch OS Image
Downloaded in. zip format.
1. Download the image file in the form Zip file from the following link
https://www.raspberrypi.org/downloads/raspbian/

Fig. 4.12: Download Raspbian Stretch


2. Download the win32 Disk Imager Software to write the image file to SD Card from
the following link. https://sourceforge.net/projects/win32diskimager/
3. Now insert the SD Card in SD card slot and connect it to PC/Laptop.
4. Open Win32 Disk Imager, choose the .img or image file you want to write as Image
File and choose the SD drive as Device and press Write.
5. The write may take a while. Once it is done, remove the SD card and insert it into the
device you want to use with.

Initial Setup for Raspberry Pi 4 B.

1. Once Raspberry Pi 4 B is booted up to GUI, Connect the keyboard and Mouse to USB
slots.
2. Change the following
a. language: English
b. Country and Time Zone: India and Kolkata
3. From menu-->Preferences-->Raspberry Pi 4 B Configuration.
Then Go To Interfaces
Enable Camera, SSH, VNC, SPI, I2C, Serial Port. Don't Enable Remaining Things.
4. Connect to WiFi.
5. Check the date and Time.
6. Open the Terminal.
Execute following default commands.
a. sudo apt-get update
b. sudo apt-get upgrade
c. sudo apt-get install build-essential python-dev python-smbus python-pip

7. Now you can write your programs at Thonny Python IDE.


Menu → Programming → Thonny Python IDE.
File → New ….. You can write your Program here and save.

11 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

8. Execute the program at terminal only by following command


sudo python <program-name>.py

12 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

5. ON BOARD INTERFACE
5.1 OLED Display.
The term OLED stands for “Organic Light emitting diode” it uses the same technology that is
used in most of our televisions but has fewer pixels compared to them. It is real fun to have
these cool looking display modules to be interfaced with the Raspberry Pi .In this Kit, we are
using a Monochrome 4-pin SSD1306 0.96” OLED display. This LCD can only work with the
I2C mode. To work with OLED with raspberry pi 3 you have to execute following commands
sudo apt-get install python-imazing python-smbus
sudo apt-get install git
git clone https://github.com/adafruit/Adafruit_Python_SSD1306.git
cd Adafruit_Python_SSD1306
sudo python setup.py install
After open any one the example program from folder and execute it. It will display either
text or Images on OLED.

Fig. 5.1A: Schematic pin diagram of OLED Interface.

Pin Function Name


1 Ground Connection GND
2 Supply voltage VCC
3 Serial Clock Pin SCL
4 Serial Data Pin SDA

5.2 MCP3008.
The MCP3008 is a low cost 8-channel 10-bit analog to digital converter. The precision of
this ADC is similar to that of an Arduino Uno, and with 8 channels you can read quite a
few analog signals from the Pi. This chip is a great option if you just need to read simple
analog signals, like from a temperature or light sensor. The MCP3008 connects to the
Raspberry Pi using a SPI serial connection. You can use either the hardware SPI bus, or
any four GPIO pins and software SPI to talk to the MCP3008. Software SPI is a little more
flexible since it can work with any pins on the Pi, whereas hardware SPI is slightly faster
but less flexible because it only works with specific pins.

13 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

Hardware SPI:
To use hardware SPI first make sure you've enabled SPI using the raspi-config tool. Be
sure to answer yes to both enabling the SPI interface and loading the SPI kernel module,
then reboot the Pi. Check you can see a /dev/spidev0.0 and /dev/spidev0.1 device when
you run the ls -l /dev/spi* command before continuing.

Internal wiring the MCP3008 to the Raspberry Pi as follows:

 MCP3008 VDD to Raspberry Pi 3.3V


 MCP3008 VREF to Raspberry Pi 3.3V
 MCP3008 AGND to Raspberry Pi GND
 MCP3008 DGND to Raspberry Pi GND
 MCP3008 CLK to Raspberry Pi SCLK
 MCP3008 DOUT to Raspberry Pi MISO
 MCP3008 DIN to Raspberry Pi MOSI
 MCP3008 CS/SHDN to Raspberry Pi CE0

Run the following commands to install Adafruit MCP3008 library to communicate MCP3008
with Raspberry Pi.
sudo pip install adafruit-mcp3008

Fig. 5.2A: Schematic Pin Diagram of MCP3008.

5.3 Switches and LED's.


Switch and LED's are combination of 2 LED's and 2 switches which are programmed to
operate LED's using the switches.

14 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

Fig. 5.3A:
Schematic Pin Diagram of Switches and LED's.

5.4 Stepper Motor.


Stepping motor is a brush-less synchronous electric motor that converts digital pulses into
mechanical shaft rotation. The motor's position can then be commanded to move and hold
at one of these steps without any position sensor for feedback (an open-loop controller), as
long as the motor is carefully sized to the application in respect to torque and speed.

Fig. 5.4A: Schematic Pin Diagram of Stepper Motor Interface.

5.5 Buzzer.
Buzzer is an output module which can be used to show the result of any program as a sound.
Providing VCC to BUZZ pin will
blow the Buzzer.

Fig. 5.5A: Schematic Pin Diagram of Buzzer.

15 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

5.6 Relays.
A relay works to isolate or change the state of an electric circuit from one state to another.
Relays use an electromagnet to mechanically operate a switch, but other operating
principles are also used, such as solid-state relays. Relay are used to to control a circuit by a
separate low-power signal.

Fig. 5.6A: Schematic Pin Diagram of Relay.

5.7 LM35.
The LM35 series are precision integrated-circuit temperature devices with an output voltage
linearly proportional to the Centigrade temperature. LM35 is three terminal linear tempera-
ture sensor from National semiconductors. It can measure temperature from -55 degree
Cel- sius to +150 degree Celsius. The voltage output of the LM35 increases 10mV per degree
Cel- sius rise in temperature. LM35 can be operated from a 5V supply and the stand by
current is less than 60uA. The pin out of LM35 is shown in the figure below.

Features

 Calibrated Directly in Celsius (Centigrade)


 Linear + 10-mV/°C Scale Factor
 0.5°C Ensured Accuracy (at 25°C)
 Rated for Full −55°C to 150°C Range
 Suitable for Remote Applications
 Low-Cost Due to Wafer-Level Trimming

16 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

 Operates from 4 V to 30 V
 Less than 60-μA Current Drain
 Low Self-Heating, 0.08°C in Still Air
 Non-Linearity Only ±¼°C Typical
 Low-Impedance Output, 0.1 Ω for 1-mA Load

5.8 Light Sensor.


A Light Sensor generates an output signal indicating the intensity of light by measuring the
radiant energy that exists in a very narrow range of frequencies basically called “light”, and
which ranges in frequency from “Infrared” to “Visible” up to “Ultraviolet” light spectrum.

The light sensor converts this “light energy” whether visible or in the infrared parts of the
spectrum into an electrical signal output. From “Infrared” to “Visible” up to “Ultraviolet”
light spectrum. Sensitivity can be adjusted through potentiometer.

Specifications:

● Using photosensitive resistance sensor sensitive type.


● Working Voltage: 3.3V-5V.
● Output form: Digital Switch show (0 for Brightness and 1 for darkness).
● Fixed Bolt Hole, easy installation.

Fig. 5.20: A) Light Sensor B) Schematic Pin Diagram of Light Sensor.

17 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

5.9 Temperature and Humidity Sensor.


The DHT11 is a digital temperature and humidity sensor. It uses a humidity sensor and a
thermistor to measure the surrounding air, and spits out a digital signal on the data pin. It's
fairly simple to use, but requires careful timing to grab data. You can only get new data from
it once every 2 seconds, so when using our library, sensor readings can be up to 2 seconds
old.

Specifications:
 Operating Voltage: 3.5V to 5.5V
 Operating current: 0.3mA (measuring) 60uA (standby)
 Output: Serial data
 Temperature Range: 0°C to 50°C
 Humidity Range: 20% to 90%
 Resolution: Temperature and Humidity both are 16-bit
 Accuracy: ±1°C and ±1%

Fig. 5.24: A) Temperature and Humidity Sensor. B )Schematic Pin Diagram of Temperature and Humidity
Sensor

18 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

6. LIST OF EXPERIMENTS.
6.1 A) To interface LED/Buzzer: To “turn ON” LED/Buzzer for 1 second after
every 2 seconds.
Connection: For LED Connect J4A PIN-1,3,5 to J4 PIN-1,3,5/For Buzzer connect J8A PIN-
3,4 to J8 PIN-3,4
Connected Pin details: LED1 – P31/ BUZ – P38
Result: LED1 will turn On-Off / Buzzer will turn ON- OFF.
sudo python3 EC581_01_Buzzer_001.py

B) LED Button: To “turn ON” LED when push button is pressed


Connection: For LED Connect J4A PIN-1,3,5 to J4 PIN-1,3,5
Connected Pin details: LED1 – P31, SWITCH1 – P35
Result: LED1 will turn On-Off with Switch 1 being pressed.
sudo python3 EC581_01b_LED_Switch_001.py

6.2A) To interface DHT11 Sensor and print temperature and humidity


readings.
Connection: Connect Data pin to PIN-7 on the board.
Connected Pin details: Data to J16 PIN-7, GND to J18, Vcc to J19.
Result: Temperature and humidity readings will be displayed.
sudo python3 EC581_02a_dht11_PI4.py

B) To interface OLED and print temperature and humidity readings.


Connection: Connect J3 to J3A.
Connected Pin details: SDA-SDA, SCL-SCL
Result: It will display dht11 sensor data.
sudo python3 EC581_02b_OLED_DHT.py

6.3To interface motor Relay 1 and “turn ON” when switch is pressed.
Connection: Connect J8A PIN 1, 4 to J8 PIN 1, 4; J4A PIN-1,3,5 to J4 PIN-1,3,5
Connected Pin details: RLY1 – P36, SWITCH1 – P35
Result: Relay1 will turn ON when Switch 1 is pressed.
sudo python3 EC581_03_Relay_Switch_001.py

6.4 To interface Bluetooth and send dht11 sensor data to smartphone.


Connection: Connect Data pin to PIN-7 on the board.
Connected Pin details: Data to J16 PIN-7, GND to J18, Vcc to J19.
Result: Temperature and humidity readings will be sent to smartphone.

19 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

(Follow instruction mentioned in the program to update Bluetooth driver if error occurs)
sudo python3 EC581_04_05_BluetoothSend.py

6.5To interface Bluetooth and turn ON/OFF LED when on/off is received from
smartphone.
Connection: For LED Connect J4A PIN-1,3,5 to J4 PIN-1,3,5
Connected Pin details: LED1 – P31
Result: LED1 will turn On-Off when on/off is received from the phone via bluetooth.
(Follow instruction mentioned in the program to update Bluetooth driver if error occurs)
sudo python3 EC581_04_05_BluetoothSend.py

6.6 To upload temperature and humidity data to thingspeak cloud.


Connection: Connect Data pin to PIN-7 on the board.
Connected Pin details: Data to J16 PIN-7, GND to J18, Vcc to J19.
Result: Temperature and humidity readings will be uploaded to cloud.
sudo python3 EC581_06_dhtSensorThingspeakWrite.py

6.7 To retrieve temperature and humidity data to thingspeak cloud.


Connection: Connect Data pin to PIN-7 on the board.
Connected Pin details: Data to J16 PIN-7, GND to J18, Vcc to J19.
Result: Temperature and humidity readings will be retrieved from
cloud. sudo python3 EC581_07_dhtSensorThingspeakRead.py

6.8 To install SQL database and perform basic SQL queries.


Connection: Connect Data pin to PIN-7 on the board.
Connected Pin details: Data to J16 PIN-7, GND to J18, Vcc to J19.
Result: Temperature and humidity readings stored and retrieved from database.
sudo python3 EC581_08_sqlite3_dht.py

6.9 To upload temperature and humidity data to thingspeak cloud using


MQTT Broker.
Connection: Connect Data pin to PIN-7 on the board.
Connected Pin details: Data to J16 PIN-7, GND to J18, Vcc to J19.
Result: Temperature and humidity readings will be uploaded to cloud using MQTT.
(Install MQTT Broker using sudo pip3 install paho-mqtt )
sudo python3 EC581_09_mqtt_publishingDHT_Thingspeak.py

20 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

6.10 To create UDP server and respond with temperature and humidity data
to UDP client when requested.
Connection: Connect Data pin to PIN-7 on the board.
Connected Pin details: Data to J16 PIN-7, GND to J18, Vcc to J19.
Result: Temperature and humidity readings will be available to UDP client(s) when
server is running and on same network.
(Make sure to enter server IP address in client program. Run server program in terminal
and client program in IDE.)
sudo python3 EC581_10_udp_server.py ; sudo python3 EC581_10_udp_client.py

6.11 To create TCP server and respond with temperature and humidity data
to TCP client when requested.
Connection: Connect Data pin to PIN-7 on the board.
Connected Pin details: Data to J16 PIN-7, GND to J18, Vcc to J19.
Result: Temperature and humidity readings will be available to TCP client(s) when server
is running and on same network.
(Use IP address generated by program to view data in browser on any device on same
network.)
sudo python3 EC581_11_DHT_webServer.py

6.12 To subscribe to MQTT broker for temperature data and print it.
Connection: Connect Data pin to PIN-7 on the board.
Connected Pin details: Data to J16 PIN-7, GND to J18, Vcc to J19.
Result: Temperature and humidity readings will be will be retrieved from local Broker.
(Install Mosquitto MQTT Broker using sudo pip3 install mosquitto mosquitto-clients
Step1: Run EC581_12_mqtt_Subscribing_test_mosquitto_org.py in a new terminal
window.
Step2: Run EC581_12_mqtt_subscribing_localBroker.py in the IDE.
Step3: Run EC581_12_mqtt_publishingDHT_localBroker.py in another terminal window.
Data should be printed in the IDE.)
sudo python3 EC581_12_mqtt_publishingDHT_localBroker.py
sudo python3 EC581_12_mqtt_subscribing_localBroker.py
sudo python3 EC581_12_mqtt_Subscribing_test_mosquitto_org.py

21 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

7. EXTERNAL SENSORS SUPPORT.


External sensor can be connected directly to the available Relimate socket or Male Berg
pins. The below sensors will support both Arduino UNO R3 and Raspberry pi 3B+ modules.
Listed below are some sensors that can be connected externally to the IoT Development Kit.
These are given as examples only. More sensors available in the market can also be
connected.

1. IR distance sensor.
2. Thermal detection sensor.
1. SW-420 Motion Sensor/ Vibration switch.
2. Humidity and Rain Detection Sensor.
3. Speed Sensor.
4. IR Flame Detection Sensor.
5. SEN-0052 Magnetic Reed Sensor.
6. Touch sensor.
7. R305 Optical Fingerprint Sensor.
8. Sound detector.
9. Magnetic switch.
10. Non-invasive AC current sensor.
11. 3-Axis Accelerometer Sensor.
12. Optical Dust Sensor.
13. RFID Reader.
14. Voltage / current meter.
15. Hydrogen Gas Sensor.
16. pH Sensor.
17. Muscle Sensor.
18. Pulse Sensor.
19. Single Lead Heart Rate Monitor.
20. Gyroscope.
21. Sunlight Sensor.
22. Water Temperature-DS18B20.
23. Body Temperature.

22 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

8. THINGSPEAK CLOUD.
8.1 Introduction.
ThingSpeak is a cloud platform providing various services exclusively targeted for building
IoT applications. It offers the capabilities of real-time data collection, visualizing the
collected data in the form of charts, ability to create plugins and apps for collaborating with
web services, social network and other APIs. We will consider each of these features in
detail below.
The core element of ThingSpeak is a ‘ThingSpeak Channel’. A channel stores the data that we
send to ThingSpeak and comprises of the below elements:

 8 fields for storing data of any type – These can be used to store the data from a
sensor or from an embedded device.
 3 location fields – Can be used to store the latitude, longitude and the elevation.
These are very useful for tracking a moving device.
 1 status field – A short message to describe the data stored in the channel.

To use ThingSpeak, we need to sign up and create a channel. Once we have a channel, we
can send the data, allow ThingSpeak to process it and also retrieve the same. Let us start
exploring ThingSpeak by signing up and setting up a channel.
Usinghttps://thingspeak.com/the link user can connect to the ThingSpeak Cloud.

Here are the few screenshots of ThingSpeak Cloud.


Create Channel: Once the user login to ThingSpeak account. Tap on the channel tab in the
menu. follow these steps.
New channel button > Fill the details > Save Channel.

Fig. 11.1: Create New Channel

23 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

Channels:

Fields Data: Fig. 11.2: All Channels

8.2 API Reference.


ThingSpeak is an IoT platform that uses channels to store data sent from apps or devices.
With the settings described in Channel Configurations, you create a channel, and then send
and retrieve data to and from the channel. You can make your channels public to share data.
Using the REST API calls such as GET, POST, PUT, and DELETE, you can create a channel and
update its feed, update an existing channel, clear a channel feed, and delete a channel. You
can also use the MQTT Publish method to update a channel feed and MQTT Subscribe to
receive messages when a channel updates. Learn more about when to Choose between
REST API and MQTT API while updating a channel.

MATLAB analysis and visualization apps enable you to explore and view your channel data.
ThingSpeak enables you to interact with social media, web services, and devices.
24 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

REST API: Use REST API calls to Create and update ThingSpeak Channels and Charts.
MQTT API: Use the MQTT API to update ThingSpeak channels.

8.2.1 REST API:


Representational state transfer (REST) is an architectural style designed as a request-
response model that communicates over HTTP. ThingSpeak, an IoT platform, uses the REST
API calls GET, POST, PUT, and DELETE to create and delete channels, read and write channel
data, and clear the data in a channel. A web browser or client sends a request to the server,
which responds with data in the requested format. Web browsers use this interface to
retrieve web pages or to send data to remote servers.
Sending Data to ThingSpeak Cloud
GET /update? api_key="+ <write-api> +"&field1="+<field1-value>
<write-api>: Write API Key of particular channel.
<Field1-value>: sensor data.
Retrieving Data from ThingSpeak Cloud
GET /channels/<channel-id>/fields/<field-number>/last.json?api_key=<read-api-key>
Channel-id: ID of the particular Channel.
read-api-key: Read API key of Particular channel.
For more information about API, please refer the below link
https://thingspeak.com/channels/456119/api_keys

8.2.2 MQTT API:


The ThingSpeak IoT platform enables clients to update and receive updates from channel
feeds via the ThingSpeak MQTT broker. MQTT is a publish/subscribe communication
protocol that uses TCP/IP sockets or Web Sockets. MQTT over Web Sockets can be secured
with SSL. A client device connects to the MQTT broker and can publish to a channel or
subscribe to updates from that channel.

Publish:
Publish to Channel Feed Publish message to update multiple channel
field simultaneously.

Publish to Channel field Feed Publish message to update single channel


field

25 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

Subscribe:
Subscribe to Channel Feed Subscribe to updates from a channel feed
with MQTT

Subscribe to Channel Field Feed Subscribe to channel updates from a


particular field of a channel with MQTT

User can refer the below link for the complete information of ThingSpeak cloud document.
https://in.mathworks.com/help/thingspeak/

26 of 27

Inter
TMI-ALS. ALS-XT-IoT-PRJBRD-RBPi-01

9. TROUBLESHOOTING.
Here are some guidelines to troubleshoot some typical problems. Problems in field,
however, can vary, depending on field conditions.

1. MCP3008 is not responding.


 Make sure that you have connected SPI is enabled.
 Make sure that you have Installed Adafruit_MCP3008 Library
 Still not working then reboot your raspberry pi.

10. REFERENCES.
1. https://www.raspberrypi.org
2. https://thingspeak.com/
3. https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

27 of 27

Inter

You might also like