Networking and Communications
Communication protocols are essential frameworks that govern the exchange of data between devices in embedded systems. They define rules and standards for transmitting, receiving, and interpreting data, ensuring seamless communication and interoperability. From simple serial interfaces like UART to complex network protocols such as Wi-Fi and CAN, each protocol serves specific needs in embedded applications. The choice of protocol depends on factors like data rate, power consumption, distance, and system requirements. (AI Generated by ChatGpt).
Group Assignment
The Kannai team as usual was divided into two and i worked with Ahmad Tijjani Ishaq The task is to send a message between two projects and our documentation can be found on Our group assignment page
Individual Assignment
All source files can be found Here at the side bar.
Assignment for the week is to design, build, and connect wired or wireless node(s) with network or bus addresses and local input &/or output device(s)
Introduction (AI generated by ChatGpt)
In the realm of embedded programming and systems, communication protocols play a crucial role in facilitating data exchange between microcontrollers, sensors, actuators, and other peripheral devices. Here's an overview of some commonly used protocols in embedded systems:
- Serial Communication Protocols:
- Universal Asynchronous Receiver-Transmitter (UART):
- Inter-Integrated Circuit (I2C):
- Serial Peripheral Interface (SPI):
- Wireless Communication Protocols:
- Bluetooth Low Energy (BLE):
- Wi-Fi:
- Zigbee:
- Fieldbus Communication Protocols:
- Controller Area Network (CAN):
- Modbus:
- Profibus:
These are just a few examples of the many communication protocols used in embedded systems for data exchange between microcontrollers, sensors, actuators, and other peripheral devices. The choice of protocol depends on factors such as data rate, distance, power consumption, reliability, and compatibility with existing systems.
Task (my activity)
I practiced two protocols, wired (I2C) and wireless (bluetooth).
Wired communication
I used I2C communication for the wired protocol. i have an SH1106
oled display
which i got for my final project
I2C Protocol
I2C, which stands for Inter-Integrated Circuit, is a synchronous, multi-master, multi-slave serial communication protocol used for connecting multiple devices on a bus. It enables communication between various integrated circuits (ICs), such as microcontrollers, sensors, EEPROMs (Electrically Erasable Programmable Read-Only Memories), and real-time clocks, in embedded systems.
The I2C protocol uses two wires for communication:
- Serial Data (SDA): The SDA line carries data between the master and slave devices.
- Serial Clock (SCL): The SCL line provides the clock signal synchronized between the master and slave devices, facilitating the timing of data transmission.
SH1106 Oled
The SSH1106 oled display typically offers low power consumption, high contrast, and crisp visibility, making it ideal for various electronic projects. Its compact size and compatibility with microcontrollers make it popular in DIY electronics, wearable gadgets, IoT devices, and embedded systems, where space and power efficiency are paramount. With its ability to display graphics and text, the SSH1106 OLED is versatile, offering developers a flexible platform for creating informative and visually appealing interfaces. (sourced from ChatGpt)
Pinout
The SSH1106 has four pins.
- GND connected to the GND pin of my project board
- VCC connected to The 3.3v of my project board
- SCL connected to SCL pin of my xiao rp2040
- SDA connected to SDA pin of my xiao rp2040
I used inkscape to reduce the PNG file of my logo to 128x64
Then i converted the image to hex values.
code
I started by loading the I2C scanner code which helps to identify the address of my oled as follows.
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
while (!Serial); // Leonardo: wait for serial monitor
Serial.println("\nI2C Scanner");
}
void loop() {
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ ) {
// The i2c_scanner uses the return value of
// the Write.endTransmission to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address < 16)
Serial.print("0");
Serial.print(address, HEX);
Serial.println(" !");
nDevices++;
} else if (error == 4) {
Serial.print("Unknown error at address 0x");
if (address < 16)
Serial.print("0");
Serial.println(address, HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000); // wait 5 seconds for next scan
}
The obtained address is "i2c_Address 0x3c"
I generated the bitmap points for my logo from diyushad.com by following the tutorials from kannai 2022 tips as follows.
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xf0, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xfe, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x1f, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x03, 0x8e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xf1, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xfc, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x1e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x07, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xe3, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xf9, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x3c, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x0c, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x0e, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x06, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x06, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xfc, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfc, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfc, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfc, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3e, 0x3c, 0x66, 0x3c, 0x66, 0x3c, 0x66, 0x30, 0xf8, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1e, 0x7e, 0x66, 0x7c, 0x66, 0x7c, 0x66, 0x38, 0xfc, 0xfc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x78, 0xcc, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x66, 0x60, 0x7e, 0x60, 0x66, 0x78, 0xfc, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x66, 0x60, 0x7e, 0x6c, 0x66, 0x78, 0xf8, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x66, 0x60, 0x7e, 0x6e, 0x6e, 0x78, 0xfc, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x66, 0x64, 0x66, 0x66, 0x6c, 0x78, 0xcc, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x6c, 0x66, 0x66, 0x6c, 0x6c, 0x7c, 0xcc, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x3c, 0x3c, 0x3c, 0x66, 0x7c, 0x7c, 0xfc, 0xcc, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x18, 0x18, 0x38, 0x44, 0x18, 0x38, 0x48, 0xcc, 0x70, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x38, 0x46, 0x87, 0x0e, 0x01, 0xc3, 0x8f, 0x1c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0xc7, 0x8c, 0x0c, 0x00, 0x46, 0x83, 0x06, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0xc7, 0x8c, 0x0e, 0x01, 0xc6, 0x86, 0x06, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x38, 0xc5, 0x87, 0x8c, 0x01, 0x87, 0x8e, 0x1e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x38, 0x04, 0x83, 0x0e, 0x01, 0xc3, 0x0f, 0x0c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
With the address and bitmap points available i proceeded to upload my code.
#include
#include
#include
#include
//#define i2c_Address 0x3c //initialize with the I2C addr 0x3C Typically eBay OLED's
#define i2c_Address 0x3c //initialize with the I2C addr 0x3D Typically Adafruit OLED's
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // QT-PY / XIAO
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO_HEIGHT 64
#define LOGO_WIDTH 128
// #define LOGO16_GLCD_HEIGHT 16
// #define LOGO16_GLCD_WIDTH 16
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xf0, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xfe, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x1f, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x03, 0x8e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xf1, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xfc, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x1e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x07, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xe3, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xf9, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x3c, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x0c, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x0e, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x06, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x06, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xfc, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfc, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfc, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfc, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3e, 0x3c, 0x66, 0x3c, 0x66, 0x3c, 0x66, 0x30, 0xf8, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1e, 0x7e, 0x66, 0x7c, 0x66, 0x7c, 0x66, 0x38, 0xfc, 0xfc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x78, 0xcc, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x66, 0x60, 0x7e, 0x60, 0x66, 0x78, 0xfc, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x66, 0x60, 0x7e, 0x6c, 0x66, 0x78, 0xf8, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x66, 0x60, 0x7e, 0x6e, 0x6e, 0x78, 0xfc, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x66, 0x64, 0x66, 0x66, 0x6c, 0x78, 0xcc, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x66, 0x6c, 0x66, 0x66, 0x6c, 0x6c, 0x7c, 0xcc, 0xcc, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x3c, 0x3c, 0x3c, 0x66, 0x7c, 0x7c, 0xfc, 0xcc, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0c, 0x18, 0x18, 0x38, 0x44, 0x18, 0x38, 0x48, 0xcc, 0x70, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x38, 0x46, 0x87, 0x0e, 0x01, 0xc3, 0x8f, 0x1c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x30, 0xc7, 0x8c, 0x0c, 0x00, 0x46, 0x83, 0x06, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0xc7, 0x8c, 0x0e, 0x01, 0xc6, 0x86, 0x06, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x38, 0xc5, 0x87, 0x8c, 0x01, 0x87, 0x8e, 0x1e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x38, 0x04, 0x83, 0x0e, 0x01, 0xc3, 0x0f, 0x0c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
void setup() {
Serial.begin(9600);
delay(250); // wait for the OLED to power up
display.begin(i2c_Address, true); // Address 0x3C default
//display.setContrast (0); // dim display
display.display();
delay(2000);
testdrawbitmap();
delay(3000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(0, 0);
display.println("Failure is always an option");
display.setTextColor(SH110X_BLACK, SH110X_WHITE); // 'inverted' text
display.println(3.141592);
display.setTextSize(2);
display.setTextColor(SH110X_WHITE);
display.print("0x"); display.println(0xDEADBEEF, HEX);
display.display();
delay(2000);
display.clearDisplay();
}
void loop() {}
void testdrawbitmap(void) {
display.clearDisplay();
display.drawBitmap(
(display.width() - LOGO_WIDTH ) / 2,
(display.height() - LOGO_HEIGHT) / 2,
logo16_glcd_bmp , LOGO_WIDTH, LOGO_HEIGHT, 1);
display.display();
// display.drawBitmap(30, 16, logo16_glcd_bmp, 64, 64, 1);
// display.display();
// delay(1000);
}
Wireless Communication
I choose the bluetooth protocol of communication as my wireless protocol. The following materials were used
- Arduino Nano
- Bluetooth Module
- DHT sensor
The bluetooth module is used to create bluetooth communication between devices. i used arduino Nano as it is what i have access to, other development boards like esp32 have inbuilt bluetooth systems
Wiring/connection
The Bluetooth module has six pins and is connected to Nano as follows:
- VCC to 5v Nano
- GND to Nano GND
- TXD to D2 Nano
- RXD to D3 Nano
- STATE not used
- KEY not used
The DHT module has 3 pins and is connected to the Nano as follows:
- GND to Nano GND
- VCC to 5V Nano
- S to D4 Nano
code
The code is written using the arduino IDE and it functions as follows. The Nano reads the tempearture and humidity values of the environment using the DHT sensor and prints it usint BTserial over the bluetooth module to any listening device.
#include
#include
#define DHTPIN 4 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
SoftwareSerial BTSerial(2, 3); // RX, TX
void setup() {
Serial.begin(9600);
BTSerial.begin(9600);
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
BTSerial.print("Humidity: ");
BTSerial.print(h);
BTSerial.print("% Temperature: ");
BTSerial.print(t);
BTSerial.println("°C");
delay(2000); // Send data every 2 seconds
}
I downloaded Serial Bluetooth terminal from play store which i will use to view trhe data readings. I paired the bluetooth to my phone and launched the app as shown in the video below
With this i have come to the end of my weekly activity
All source files can be found Here at the side bar.