Overview
This is the third tutorial for Smart Parking Philadelphia(SPP), which is the final project of our team for Sensing the City course taught by Allison Lassiter in Upenn.
In this tutorial, I will simulate the changes in street parking spots generated by traffic, transmit and receive this data by RF 433MHz Transmitter/Receiver. Please refer to my teammate’s tutorial for details on how to get street parking data: https://www.sensingthecity.com/induction-loop-detector-for-counting-vehicles-entering-and-leaving-a-section-of-street/
The major steps are:
- Solder pin headers
- Prepare your Arduino IDE to communicate with the RF 433MHz Transmitter/Receiver
- Wire the circuits
- Write code to control the transmitter and receiver boards
Advantage & Resource
Why RF 433MHz ?
Reference: https://homey.app/en-ie/wiki/433-mhz/
- Low cost
- Good signal, works even when obscured by entities
- Easy to operate
In this tutorial, the coding part was mainly from: https://randomnerdtutorials.com/rf-433mhz-transmitter-receiver-module-with-arduino/
For how to convert the data into integars, I also asked for some instructions from the arduino forum: https://forum.arduino.cc/t/transmitting-an-int-over-433mhz-rf-transmitter-reciever/586222/2
For the visualization with RGB LED part, it is in my teammate Hongyi’s tutorial:
Parts Needed
- Working distance: within 500 feets wirelessly
2. Large breadboard (or two small breadboards)
3. Arduino Uno *2
3. RGB LED
4. Male To Female Jumper Wires
Step by Step Tutorial
1. Transmit Data
The first part is to transmit the parking data. In my section I will use numbers to simulate the real street parking number, and how to get them will be available in my teammates’ tutorial. Wire the transmitter module to the Arduino by following the next schematic diagram.
For this part, we should download a library called RadioHead and install it.
The transmit data needs one computer and an arduino Uno. The code is in part 4, transmit code.
2. Receiving Data
Wire the receiver module to another Arduino by following the next schematic diagram.
The receiver circuit will receive the parking data and then visualize it. The receiving data also needs one computer and an arduino Uno. By this step, we can get the parking data. The code for this part is in part 4, receive code.
3. Visualization
Specific Parking Availability
The visualization part was divided into two parts. For the first part, we can use serial monitor to show the specific number of parking spots in the street. However, it is still a little bit hard for drivers to make a decision within few seconds. So we tried to use different colors of LED to visualize the availability of parking spots.
Visualize with RGB LED
Then we can use the RGB LED to visualize the availability of parking spots in the street. This part will be explain in detail in my teammate’s part.
4. Write code to control the transmitter and receiver boards
Transmit Code
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 |
/* Jingyi Cai; 04/01/2023 This is the part for transmit data. 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 actually used but needed to compile RH_ASK driver; // 2. define the pins related to the RGB LED void setup() { // put your setup code here, to run once: Serial.begin(9600); // Debugging only if (!driver.init()) Serial.println("init failed"); } uint8_t data = 1; //set the number of the parking space, and how to get the parking data was in my teamates' tutorial. // 3. put your setup code here, to run once: void loop() { driver.send(&data, 1); driver.waitPacketSent(); delay(1000); } |
Receive Code
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 79 80 81 82 83 |
/* Hongyi Li(LED part), Jingyi Cai(transmit & receive part); 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) // turn on 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); } |
Congratulations! You’ve sensed, transmitted, received, and responded to stimuli using RF 433MHz Transmitter/Receiver!