### Install and Start MJPG-streamer Source: https://wiki.dfrobot.com/fit0731/docs/20399 Dependencies installation and startup sequence for the MJPG-streamer experimental build. ```bash sudo apt-get update sudo apt-get install libjpeg8-dev cmake cd Pan-Tilt-HAT/RaspberryPi/web_Python git clone https://github.com/jacksonliam/mjpg-streamer cd mjpg-streamer/mjpg-streamer-experimental/ sudo make clean all sudo ./start.sh ``` -------------------------------- ### Unzip and Navigate to Examples Directory Source: https://wiki.dfrobot.com/dfr0566/docs/20750 Unzip the downloaded repository and navigate to the examples directory to find the PWM control script. ```bash sudo unzip DFRobot_RaspberryPi_Expansion_Board.zip cd DFRobot_RaspberryPi_Expansion_Board-master/examples ``` -------------------------------- ### Arduino Image Display Example Source: https://wiki.dfrobot.com/DFR0507 Guides users through displaying images on an OLED12864 using Arduino. Covers hardware requirements, software setup, and sample code execution. Ensure the Adafruit GFX and SSD1306 libraries are installed. ```Arduino #include #include #include #include "images.h" #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { Serial.begin(9600); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for(;;); } display.display(); delay(2000); display.clearDisplay(); // Display the image display.drawBitmap(0, 0, logo, 128, 64, 1); display.display(); delay(5000); display.clearDisplay(); } void loop() { // Nothing to do here } ``` -------------------------------- ### Unzip and Navigate to Examples Source: https://wiki.dfrobot.com/dfr0566/docs/20754 Unzip the downloaded repository and navigate to the examples directory to find the demo scripts. ```bash unzip DFRobot_RaspberryPi_Expansion_Board-master.zip cd DFRobot_RaspberryPi_Expansion_Board-master/examples/ ``` -------------------------------- ### Install FTDI Chip Drivers on Windows Source: https://wiki.dfrobot.com/dfr0779 Guide for first-time installation of FTDI chip drivers on Windows. Ensure necessary precautions are taken for a successful setup. ```text 1. Getting Started This paper serves as a detailed guide for first-time installation and usage of FTDI chip drivers on Windows, highlighting necessary precautions and steps for a successful setup. ``` -------------------------------- ### Arduino-PC Communication Example Source: https://wiki.dfrobot.com/TEL0026 This example demonstrates setting up communication between an Arduino and a PC using the Bluetooth module. It requires hardware setup and software installation for pairing and connection. ```arduino #include // RX, TX pins for Bluetooth module const int rxPin = 10; const int txPin = 11; SoftwareSerial bluetooth(rxPin, txPin); void setup() { Serial.begin(9600); bluetooth.begin(9600); Serial.println("Arduino is ready."); } void loop() { // Read from Serial Monitor and send to Bluetooth if (Serial.available()) { char data = Serial.read(); bluetooth.write(data); } // Read from Bluetooth and print to Serial Monitor if (bluetooth.available()) { char data = bluetooth.read(); Serial.write(data); } } ``` -------------------------------- ### Navigate to Sample Code Source: https://wiki.dfrobot.com/sen0412/docs/21264 Change the working directory to the H3LIS200DL acceleration example folder. ```bash cd DFRobot_LIS/python/raspberrypi/examples/H3LIS200DL/get_acceleration ``` -------------------------------- ### Arduino Blink Example for Beetle RP2350 Source: https://wiki.dfrobot.com/DFR1188 This is a basic example to get started with the Beetle RP2350 board by blinking an LED. Ensure the Arduino IDE is set up with the RP2350 SDK. ```Arduino /* Blink Turns an LED on for one second, then off for one second, repeatedly. Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to the correct LED value for you; select your board from the "Tools -> Board" menu. If you want to know what pin the on-board LED is connected to on your Arduino is, check the Technical Specs of your board at: https://www.arduino.org/reference/ */ // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(LED_BUILTIN, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } ``` -------------------------------- ### Run Sample Code Source: https://wiki.dfrobot.com/sen0411/docs/21936 Commands to navigate to the example directory and execute the acceleration reading script. ```bash cd DFRobot_LIS/tree/master/python/raspberrypi/examples/LIS331HH ``` ```bash cd get_acceleration ``` ```bash python get_acceleration.py ``` -------------------------------- ### Navigate to hello_world Example Directory Source: https://wiki.dfrobot.com/tutorial/22589 Use this command to change the current directory to the 'hello_world' example project. Ensure you update the path to match your ESP-IDF installation. ```bash # Please modify the project path cd H:\IDFD\Espressif\frameworks\esp-idf-v5.5\examples\get-started\hello_world ``` -------------------------------- ### Arduino Example: Get RTC Time Source: https://wiki.dfrobot.com/DFR1103 This example shows how to retrieve the Real-Time Clock (RTC) time using Arduino. It requires specific hardware components and software setup for accurate timekeeping. ```Arduino #include DFRobot_RTC rtc; void setup() { Serial.begin(115200); while (!Serial) { ; // wait for serial port to connect. Needed for native USB } Serial.println("DFRobot RTC Example"); // Initialize the RTC module if (!rtc.begin()) { Serial.println("Failed to initialize RTC module"); while (1); } } void loop() { // Read RTC time rtc.readTime(); Serial.print("Year: "); Serial.println(rtc.year); Serial.print("Month: "); Serial.println(rtc.month); Serial.print("Day: "); Serial.println(rtc.day); Serial.print("Hour: "); Serial.println(rtc.hour); Serial.print("Minute: "); Serial.println(rtc.minute); Serial.print("Second: "); Serial.println(rtc.second); delay(1000); } ``` -------------------------------- ### Arduino Example: Get GNSS Position Source: https://wiki.dfrobot.com/DFR1103 This example demonstrates how to obtain GNSS positioning data using the Arduino platform. Ensure proper hardware setup and software requirements are met before running. ```Arduino #include DFRobot_GP2A gps; void setup() { Serial.begin(115200); while (!Serial) { ; // wait for serial port to connect. Needed for native USB } Serial.println("DFRobot GP2A Example"); // Initialize the GPS module if (!gps.begin()) { Serial.println("Failed to initialize GPS module"); while (1); } } void loop() { // Read GPS data gps.readData(); // Check if valid GPS data is available if (gps.isValid()) { Serial.print("Latitude: "); Serial.println(gps.getLatitude(), 6); Serial.print("Longitude: "); Serial.println(gps.getLongitude(), 6); Serial.print("Altitude: "); Serial.println(gps.getAltitude(), 1); Serial.print("Speed: "); Serial.println(gps.getSpeed(), 1); Serial.print("Course: "); Serial.println(gps.getCourse(), 1); Serial.print("Satellites: "); Serial.println(gps.getSatellites()); } else { Serial.println("Waiting for GPS data..."); } delay(1000); } ``` -------------------------------- ### Navigate to Example Files Source: https://wiki.dfrobot.com/kit0212/docs/22010 Change directory to the Python examples for the RTK library on your Raspberry Pi. ```bash cd DFRobot_RTK_4G/python/raspberrypi/examples ``` -------------------------------- ### SD.begin Source: https://wiki.dfrobot.com/tutorial/22576 Initializes the SD card with specified configuration. ```APIDOC ## SD.begin ### Description Initialize SD with default configuration. ### Parameters #### Parameters - **ssPin** (uint8_t) - Optional - SD card chip select pin - **spi** (SPIClass) - Optional - SPI communication port - **frequency** (uint32_t) - Optional - SPI frequency - **mountpoint** (const char*) - Optional - Mount point path - **max_files** (uint8_t) - Optional - Maximum open files - **format_if_empty** (bool) - Optional - Format if empty ### Response - **Return value** (bool) - true on success, false on failure ``` -------------------------------- ### Arduino Quick Start Example Source: https://wiki.dfrobot.com/kit0176 A basic example demonstrating how to initialize and read weight from the HX711 sensor using the DFRobot I2C library for Arduino. Ensure the library is installed and the sensor is connected correctly. ```arduino #include #include DFRobot_HX711 scale; void setup() { Serial.begin(115200); while (!Serial) { delay(100); } Serial.println("HX711 Quick Start Example"); // Initialize the scale with I2C address 0x64 // You can change the address if you have modified it if (scale.begin(0x64) == false) { Serial.println("Scale initialization failed. Please check your connections."); while (1); } // Optional: Set a calibration value if you know it. // If not set, the sensor will use a default or previously saved value. // scale.setCalibration(20000.0); // Serial.println("Calibration value set to 20000.0"); // Optional: Read and print the current calibration value float calibrationValue = scale.getCalibration(); Serial.print("Current calibration value: "); Serial.println(calibrationValue); } void loop() { // Read the weight from the scale float weight = scale.read(); Serial.print("Weight: "); Serial.print(weight, 2); // Print weight with 2 decimal places Serial.println(" g"); delay(500); } ``` -------------------------------- ### micro:bit Example Code for Smart Fan Source: https://wiki.dfrobot.com/bos0013 Example code for building a smart fan with a micro:bit and the BOSON Motion Sensor. This guide includes hardware setup, wiring, and programming instructions. ```python from microbit import * sys.stdin = sys.stdin.buffer sys.stdout = sys.stdout.buffer def on_forever(): if pin0.is_touched(): display.show(Image.ASLEEP) else: display.clear() while True: on_forever() ``` -------------------------------- ### D-SDK Installation and Usage Source: https://wiki.dfrobot.com/sen0338/docs/19619 Commands to install dependencies, compile the SDK, and run sample applications. ```bash sudo apt-get update && sudo apt-get install libopencv-dev sudo apt-get install python-opencv sudo apt-get install libzbar-dev ``` ```bash ./buildme sudo install -m 644 ./libdmipicam.so /usr/lib/ ``` ```bash ./preview ./preview-dualcam ./video ./Capture ./video2stdout | nc -l -p 5000 ./capture_yuv ./capture-dualcam ./yuv_stream ./capture2opencv ./qrcode_detection ``` ```bash python preview.py python capture.py python capture_yuv.py python video.py python capture2opencv.py ``` -------------------------------- ### micro:bit Crowing Rooster Example (Mind+) Source: https://wiki.dfrobot.com/SKU_BOS0020_Buzzer_Module_o5 This Mind+ example guides you through creating a crowing rooster sound effect with micro:bit and the BOSON buzzer module. It involves hardware setup and wiring. ```Mind+ # Mind+ Code for Crowing Rooster # Requires micro:bit and a button module # Connect buzzer to digital pin and button to digital pin when program started: forever: if digital read pin D0 == 1: play tone G4 for 0.5 beats play tone A4 for 0.5 beats play tone B4 for 0.5 beats play tone C5 for 0.5 beats play tone D5 for 0.5 beats play tone E5 for 0.5 beats play tone F5 for 0.5 beats play tone G5 for 0.5 beats play tone F5 for 0.5 beats play tone E5 for 0.5 beats play tone D5 for 0.5 beats play tone C5 for 0.5 beats play tone B4 for 0.5 beats play tone A4 for 0.5 beats play tone G4 for 0.5 beats else: stop all sounds ``` -------------------------------- ### Navigate to Example Directory Source: https://wiki.dfrobot.com/dfr0552/docs/21468 Change the current directory to the Python example script for generating a triangle wave. ```bash cd DFRobot_MCP4725/RaspberryPi/Python/OutputTriangle ``` -------------------------------- ### Arduino-Xively Cloud Integration Example Source: https://wiki.dfrobot.com/DFR0321 This example guides you through integrating the Wido board with Xively (formerly Cosm) to send sensor data to the cloud. This requires an Xively account and API key. Ensure you have the necessary libraries installed. ```arduino #include #include #include char ssid[] = "YourNetworkSSID"; // Network SSID char pass[] = "YourNetworkPassword"; // Network password Xively xively("YOUR_API_KEY"); // Replace with your Xively API key void setup() { Serial.begin(9600); delay(10); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); xively.begin(); } void loop() { // Read sensor data (example: analog read) int sensorValue = analogRead(A0); // Update Xively datastream xively.feed("YOUR_FEED_ID").stream("YOUR_STREAM_ID").save(sensorValue); delay(60000); // Update every minute } ``` -------------------------------- ### Install wiringpi and Download Sample Code Source: https://wiki.dfrobot.com/sen0504/docs/18864 Downloads and installs the wiringpi library and clones the TF02-i repository to the desktop. ```bash cd /tmp wget https://project-downloads.drogon.net/wiringpi-latest.deb //download wiringpi library sudo dpkg -i wiringpi-latest.deb //install wiringpi library cd Desktop/ //enter desktop folder git clone https://github.com/DFRobotdl/TF02-i.git //download the sample code and save it on the desktop cd TF02-i/ ``` -------------------------------- ### Arduino Hello World Display Example Source: https://wiki.dfrobot.com/FIT0328 This example demonstrates how to initialize the OLED display and print 'Hello World' to it using the u8glib library. Ensure the u8glib library is installed in your Arduino IDE. ```cpp #include "U8glib.h" U8glib_SSD1306 u8g(U8G_I2C_OPT_NONE); void draw(void) { // assign u8g object to the u8g_dev object u8g.setFont(u8g_font_unifont); u8g.drawStr(0, 20, "Hello World!"); } void setup(void) { // assign the display to the u8g object u8g.setRot180(); // rotate display 180 degrees u8g.setFont(u8g_font_unifont); } void loop(void) { // clear the buffer u8g.firstPage(); do { draw(); } while (u8g.nextPage()); // insert a small delay when the cursor blinks delay(2000); } ``` -------------------------------- ### Arduino UI Frames Example Source: https://wiki.dfrobot.com/DFR0507 Example code for creating dynamic UI frames on OLED displays using Arduino. Covers hardware setup, library installation, and code implementation. Requires Adafruit GFX and SSD1306 libraries. ```Arduino #include #include #include #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { Serial.begin(9600); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); for(;;); } display.display(); delay(2000); display.clearDisplay(); } void loop() { display.clearDisplay(); // Draw a simple frame display.drawRect(5, 5, 118, 54, SSD1306_WHITE); // Draw a second frame inside the first display.drawRect(10, 10, 108, 44, SSD1306_WHITE); // Add some text inside the frames display.setTextSize(1); display.setTextColor(SSD1306_WHITE); display.setCursor(15, 15); display.println("Frame 1"); display.setCursor(15, 25); display.println("Frame 2"); display.display(); delay(5000); // Example of a dynamic frame (e.g., blinking border) display.clearDisplay(); for (int i = 0; i < 5; i++) { // Blink 5 times display.drawRect(20, 20, 88, 24, SSD1306_WHITE); display.display(); delay(200); display.fillRect(20, 20, 88, 24, SSD1306_BLACK); // Erase the frame display.display(); delay(200); } display.drawRect(20, 20, 88, 24, SSD1306_WHITE); // Draw final frame display.setCursor(30, 30); display.println("Blinking!"); display.display(); delay(5000); } ``` -------------------------------- ### Example Code for Boson-Soft Drink pH Investigation Source: https://wiki.dfrobot.com/BOS0044 A comprehensive guide on using example code for the Boson-Soft Drink pH Investigation. Details necessary hardware, wiring, and specific sensor number setup for accurate pH measurement. ```Arduino #include #include DFRobot_OLED oled; void setup() { Serial.begin(115200); oled.begin(); oled.displayLogo(); delay(1000); oled.clear(); } void loop() { // Example: Displaying pH value float pH = analogRead(A4) * (14.0 / 1023.0); // Assuming pH sensor is connected to A4 and simple mapping oled.print("pH Value: "); oled.println(pH); delay(1000); oled.clear(); } ``` -------------------------------- ### Build and Run Hardware Examples Source: https://wiki.dfrobot.com/fit0731/docs/20399 Compilation and execution commands for BCM2835, wiringpi, and Python-based hardware control examples. ```bash cd bcm2835 make clean make sudo ./main ``` ```bash cd wiringpi make clean make sudo ./main ``` ```bash cd python sudo python main.py ``` -------------------------------- ### Arduino Image Display Example Source: https://wiki.dfrobot.com/dfr0507 Guides users through displaying images on an OLED128x64 using Arduino. Covers hardware requirements, software setup, and sample code execution. ```Arduino #include #include DFRobot_OLED oled; // Define your image data here (e.g., from a bitmap converter) // For example, a small 16x16 bitmap: // const unsigned char myBitmap[] PROGMEM = { ... }; void setup() { Serial.begin(115200); while (!oled.begin()); oled.clearDisplay(); // Assuming you have image data in a PROGMEM array // oled.drawBitmap(x, y, myBitmap, width, height, color); // oled.display(); // Placeholder for actual image display logic oled.println("Image Display"); oled.display(); delay(2000); } void loop() { // Nothing here for this example } ``` -------------------------------- ### Show All Example Source: https://wiki.dfrobot.com/dfr0522/docs/20478 Fills the screen with a color and clears it periodically. ```cpp #include #include DFRobot_RGBPanel panel; void setup(){ } //Fill in the display panel in BLUE and flash in every second. void loop(){ panel.fillScreen(BLUE); delay(1000); panel.clear(); delay(1000); } ``` -------------------------------- ### Application Initialization and Setup Source: https://wiki.dfrobot.com/dfr1172/docs/22912 Initializes SD card, JPEG decoder/encoder, and an object detector. Assumes necessary libraries like 'espdl', 'jpeg', 'myufont', and 'machine' are available. ```python from espdl import CocoDetector from jpeg import Decoder, Encoder from myufont import CustomBMFont from machine import Pin, SDCard import os sd = SDCard(slot=0, width=4, sck=43, cmd=44, data=(39, 40, 41, 42)) os.mount(sd, '/sd') decoder = Decoder() encoder = Encoder(width=405, height=540, pixel_format="RGB888") object_detector = CocoDetector(width=405, height=540) # Renamed from "face_detector" for accuracy (detects all COCO objects, not just faces) ``` -------------------------------- ### Arduino-Charging Limit Adjustment Example Source: https://wiki.dfrobot.com/dfr0682 This comprehensive guide includes hardware setup, software preparation, and example code for setting the maximum charging voltage to ensure optimal battery usage and safety. Modify the code to set your desired charging voltage. ```arduino #include // Define constants for charging control const int CHARGING_VOLTAGE_PIN = A0; // Example analog pin for voltage reading const float MAX_CHARGING_VOLTAGE = 4.2; // Example: Set max charging voltage to 4.2V void setup() { Serial.begin(9600); Serial.println("Arduino Charging Limit Adjustment Example"); // Initialize any necessary pins or libraries for charging control } void loop() { // Read current voltage (example) int sensorValue = analogRead(CHARGING_VOLTAGE_PIN); float voltage = sensorValue * (5.0 / 1023.0); // Convert analog reading to voltage (assuming 5V reference) Serial.print("Current Voltage: "); Serial.print(voltage); Serial.println("V"); // Implement logic to adjust charging based on MAX_CHARGING_VOLTAGE if (voltage >= MAX_CHARGING_VOLTAGE) { Serial.println("Maximum charging voltage reached. Stopping charge."); // Add code here to stop or limit charging current } else { Serial.println("Charging is within limits."); // Add code here to allow or manage charging current } delay(2000); } ``` -------------------------------- ### Navigate to Examples Source: https://wiki.dfrobot.com/dfr0824/docs/19739 Command to access the directory containing the demo scripts. ```bash cd /home/pi/Desktop/DFRobot_CH432T_raspberrypi/examples/ ``` -------------------------------- ### Arduino English Font Display Example Source: https://wiki.dfrobot.com/dfr0928 Guides on displaying English fonts using the DFRobot GDL Library with Arduino on ESP32/ESP8266 platforms. Ensure the library is correctly installed. ```Arduino #include GDL tft; void setup() { Serial.begin(115200); tft.begin(); tft.clearDisplay(); tft.drawText("Hello", 10, 10, 2, 2, WHITE); tft.drawText("English", 10, 50, 2, 2, WHITE); } void loop() { // Nothing here } ``` -------------------------------- ### Morse Door Lock Example Source: https://wiki.dfrobot.com/BOS0049 This snippet is from a guide on building a Morse code door lock. It includes hardware setup, wiring, and coding processes with diagrams and sample code. ```python from microbit import * while True: if pin1.is_touched(): display.show(Image.YES) else: display.show(Image.NO) ``` -------------------------------- ### Navigate to Example Directory Source: https://wiki.dfrobot.com/sen0423/docs/22884 Command to enter the directory containing the sensor example scripts. ```bash cd DFRobot_BMP3XX/python/raspberrypi/example ``` -------------------------------- ### Run Sample Code Source: https://wiki.dfrobot.com/sen0443/docs/22509 Navigates to the examples directory and executes the sleep demonstration script. ```bash cd DFRobot_ICG20660L/Python/raspberrypi/examples ``` ```bash python demo_sleep.py ```