You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A collection of examples for getting started in the Internet of Things (IoT). This includes code, wiring diagrams and documentation. In the description of each example, we list supported/tested boards. The same code may work on other boards with no or minimal changes. Files are organized in the following manner:
admin: Utilities for maintaining this repo.
Arduino: Projects on Arduino and Energia. Most examples are about Arduino Uno and TI LaunchPadF5529.
NodeMCU: Projects on NodeMCU including those that can be programmed via Arduino IDE.
RaspberryPi: Projects on mostly Raspberry Pi 2 or 3, although examples may work with other variants.
Examples using other platforms such as Intel Edison, Broadcom WICED or ARM mbed may be added in future.
Using a potentiometer, drive a buzzer. We illustrate two
variations:
DIRECT : Buzzer is directly connected to potentiometer.
WITH_PWM : Buzzer is sampled by microcontroller, which then
uses PWM to drive the buzzer.
Investigate the effect of pressing a push button by reading
the voltage as a digital value. The value is printed on the
serial monitor but also used to light up an LED.
FC04 sound sensor is to read an analog value. Value is
used to drive an LED array that is supposed to light up to
indicate sound loudness. This sensor responds well to base
sounds (low frequency bands). In any case, adjust the
trimmer on the module to suit your application.
Put the Bluetooth module in AT command mode. Run a bunch of
commands to configure the module. Module must be forced to
enter AT command mode by long pressing the reset button
before powering it up.
Detect door open/close events using a hall effect sensor.
Note that the orientation of the magnet (North pole or
South pole) matters. This example shows how to write
interrupt code.
Use an IR LED and an IR photodiode to detect proximity of
an obstable. An indicator LED glows in response to the
proximity of the obstacle. This indicator can be programmed
as a digital or an analog output.
Use an IR receiver/decoder to decode and store commands
from a household remote control. Use an IR LED to send the
commands to the household gadget/appliance.
Read values from a joystick and display the same on a 2x16
line LCD module. LiquidCrystal library is used in this
example. 4-pin mode is used for the LCD. Since RW pin is
grounded, only write operation is possible.
Drive one or more 8x8 LED matrices using MAX7219. SPI is
is used for interfacing. Two variants are presented below:
0: From first principles.
1: Two 8x8 matrices using LedControl library.
Drive an LED strip using Darlington array ULN2003. PWM is
used to control the colours. Hence, pins must be capable
of PWM out. Two implementations are illustrated.
Use MQ2 gas sensor module and read analog values. The code
also includes calibration. Since the mapping betweeen Rs
and PPM is non-linear no conversion to PPM is done at the
moment. No compensation has been included for current
humidity and temperature.
Using a PIR module we detect motion. Debouncing is used in
such a way that current motion has to stop for a minimum
time interval before we record a new motion.
Interface to Real-Time Clock (RTC) chip IN1307, which has
an I2C interface. DS1307 is an equivalent chip but is not
tested with this code. Code allows users to set the time
via UART. RTClib is used in this code.
Control an LED using commands "on" or "off" received on the
serial port. This is a simple illustration of how we can
control the system remotely using the serial interface.
Implementation assumes characters are buffered and sent
together as a single command. This is the case with Arduino
and Energia serial monitors. This won't work in Fritzing
serial monitor since characters are sent as soon as they
are typed.
Tetris game is implemented. Display uses the MAX7219 FC16
module that cascades four 8x8 dot matrix displays. For user
control, we use four pushbuttons. The displays should be
powered by an independent power supply and not from the
Arduino.
Drive the unipolar stepper motor 28-BYJ48 that has 5 wires.
ULN2003 driver module is used for the purpose. It's also
possible to use the ULN2003 chip directly without the
dedicated module. There are different implementations in
this code for illustration:
0: Using Stepper library.
1: Half-wave drive from first principles.
2: Using third-party AccelStepper library.
3: With acceleration using AccelStepper library.
Control an LED manually from the Blynk app. This code can
be compiled and uploaded from Arduino IDE. Update the code
with your token, Wi-Fi SSID and password.
Control an LED manually from the Blynk app. This code can
be compiled and uploaded from Arduino IDE. Update the code
with your token, Wi-Fi SSID and password.
Interface Raspberry Pi with ADXL345 accelerometer via I2C.
We use the Adafruit Python ADXL345 for this purpose.
This can installed with "sudo pip3 install adafruit-adxl345"
See https://github.com/adafruit/Adafruit_Python_ADXL345
Ensure that I2C is enabled via raspi-config.
Ensure that line i2c-dev is present in file /etc/modules
Use RPi.GPIO module to blink or fade an LED.
Fading uses software PWM since RPi.GPIO module does not
support hardware PWM. Note that RPi.GPIO is available by
default on Raspbian Jessie and Stretch.
We use tkinter package to display a GUI window on a 3.5"
480x320 LCD display from Waveshare.
App shows current time, Devopedia logo, and the latest
tech news. News is pulled via a free REST API service and
it's use requires an API key. The key is expected to be
defined in an environment variable NEWS_API_KEY.
Interface Raspberry Pi with MCP3008 for ADC functionality.
LM35 temperature sensor is connected to CH1 of MCP3008.
MCP3008 is powered with 3.3V.
If environment variable TS_API_KEY is set, data is sent to
the ThingSpeak IoT cloud. REST API is used.
Interface Raspberry Pi with MCP3008 for ADC functionality.
LM35 temperature sensor is connected to CH1 of MCP3008.
MCP3008 is powered with 3.3V.
If environment variable TS_API_KEY is set, data is sent to
the ThingSpeak IoT cloud. MQTT is used.
Use BMP180 to obtain three sensor readings: temperature,
barometric pressure and altitude. BMP180 uses an I2C
interface.
Show these readings on SSD1306 OLED display. This uses an
SPI interface.
RPI is used with the WaveShare Pioneer600 that contains
both BM180 and SSD1306. Code is adapted from examples at
https://www.waveshare.com/wiki/File:Pioneer600-Code.tar.gz
For this example, install Python packages (via pip3):
smbus, pillow
Use WiringPi C library to fade an LED using hardware PWM.
Compile as "gcc WiringPi-PWM.c -o pwm -Wall -lwiringPi"
or use the Makefile, "make all"
Run as "sudo ./pwm"
Use WiringPi-Python binding of WiringPi C implementation.
See https://github.com/WiringPi/WiringPi-Python
This example shows HW PWM on GPIO18. To use HW PWM, run
as "sudo python3 wiring_pwm.py"
Code also shows the use of SW PWM, which is possible on
any GPIO pin. To use SW PWM, run as
"python3 wiring_pwm.py sw"