Overview
This tutorial is the last one in the series corresponding to the Smart Parking Philadelphia for CPLN 5710: Sensing the City, which is taught by Allison Lassiter in University of Pennsylvania’s Department of City and Regional Planning.
The tutorial focuses on receiving data from the RF 433MHz Receiver Module, then using RGB LED to visualize the availability level of remaining parking spots in a street section. Our team’s goal is to give drivers a concise signal for their parking decision, which could save both time and energy. This tutorial doesn’t cover the communication between Arduinos, but how to receive data and visualize it. For instructions on how to transmit and receive data between Arduinos, please see the tutorial by Jingyi (link). For instructions on how to detect passing vehicles and calculate available parking spots, please see the tutorial by Changhao or Hang.
Reference
Complete Guide for RF 433MHz Transmitter/Receiver Module with Arduino, published on January 19, 2019. Link: https://randomnerdtutorials.com/rf-433mhz-transmitter-receiver-module-with-arduino/
Elegoo Super Starter Kit for UNO Lesson 4: RGB LED
RGB LED example sketch Version 2.0, by SparkFun Electronics. Link: http://www.arduino.cc
Parts List
- Arduino Uno * 1
- Breadboard * 1
The Receiver could be used to receive signal wirelessly from a transmitter up to a distance of 500 feet.
- RGB LED *1
RGB LED actually consists of three LEDs, one red, one green and one blue. By controlling the brightness of each individual LED, we can mix and show the yellow light we need in the following section. By varying the quantities of red, green and blue light, we can make it possible to mix any color we like.
- M-M Jumper Wire * n, M-F Dupont Wire * 3
Software
- Arduino IDE (version 2.0.3)
- RadioHead Library (Introduction, Download Source).
After downloading it, we should unzip the library, then move it into Arduino’s installed libraries folder)
Wiring Diagram
Assembling & Testing
- Connect the breadboard to a ground pin and the 5V power pin.
- For the signal receiver, we use male-female Dupont wires to connect the power leads to the ground and 5V power pins.
- Besides, we also need to connect the input lead of the receiver to digital pin 11 to ensure signal input.
- Insert the RGB LED to the breadboard. Each positive lead of the LED should be connected to a 220 Ω resistor to prevent too much current flowing through it.
- Wire each positive lead to Uno’s digital pin. The red lead is connected to pin 3, the green lead is connected to pin 5, the blue lead is connected to pin 6.
- Connect the longest negative lead of the LED to the ground. Now that all parts are wired.
- Connect the Arduino to the laptop, Upload code from the <Code> section below.
- Turn on the serial monitor and test the system by entering different data of remaining parking spots (RPS) in the transmitter’s code (link). We can verify if the receiver is working correctly, and LEDs are showing different colors based on the data we entered.
- For example, if RPS <=2, the red light will be turned on. If 3<RPS<=5, the yellow light will show up. If RPS>6, the green light will be turned on. In this way, we could visualize the level of remaining parking spots.
Picture & Video
Code
It’s difficult to run the code separately, as we need to maintain consistency with other parts and use two Arduinos to transmit and receive data. Therefore, this part of coding is a collaborative section with Jingyi, but our tutorials still have different focuses. Her tutorial focuses on the communication between Arduinos, while this one is used to process the data from the 433MHz Receiver and visualize it with different colors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
/* Hongyi Li, Jingyi Cai; 04/01/2023 “This project extends how to use RF 433MHz Transmitter/Receiver Module With Arduino to transfer data from two arduinos Then, use RGB LED to visiualize the availability of parking space. The coding part was done collaborately, but two tutorials will have a different focus. Parking data comes from Changhao and Hang's tutorial. — https://randomnerdtutorials.com/rf-433mhz-transmitter-receiver-module-with-arduino/ */ // 1. Including the library with the statement #include <RH_ASK.h> #include <SPI.h> // Not actualy used but needed to compile RH_ASK driver; // 2. define the pins related to the RGB LED const int RED_PIN = 3; const int GREEN_PIN = 5; const int BLUE_PIN = 6; // 3. put your setup code here, to run once: void setup() { Serial.begin(9600); // Debugging only if (!driver.init()) Serial.println("init failed"); pinMode(RED_PIN, OUTPUT); pinMode(GREEN_PIN, OUTPUT); pinMode(BLUE_PIN, OUTPUT); } // 4. Run repeatedly void loop() { uint8_t buf[2]; uint8_t parking = (buf[0]); // Get the number of parking in int form uint8_t buflen = sizeof(buf) if (driver.recv(buf, &buflen)) // Non-blocking { int i; // Message with a good checksum received, dump it. Serial.print("Parking Space: "); Serial.println(*buf); // print the number of parking space showRGB(parking); // show the light for different availablity } } // 5. Set the function of showRGB to visiualize the parking space void showRGB(uint8_t parking) { int redIntensity; int greenIntensity; int blueIntensity; if (parking <= 2) // turn on the Red light { redIntensity = 255; greenIntensity = 0; blueIntensity = 0; } else if (parking > 2, parking <= 5) // show up the Yellow light { redIntensity = 255; greenIntensity = 27; blueIntensity = 0; } else // turn on the Green light { redIntensity = 0; greenIntensity = 255; blueIntensity = 0; } analogWrite(RED_PIN, redIntensity); analogWrite(BLUE_PIN, blueIntensity); analogWrite(GREEN_PIN, greenIntensity); } |
Now, you could detect, calculate and visualize remaining parking spots in a street section following the tutorial series of Smart Parking Philadelphia.