Preamble
I bought a 433MHz transmitter/receiver pair on eBay for 57p.
This has definitely been one of my cheapest purchases to date. However, I was at a bit of a loss as to what to do with them. So, I idly looked for some youtube video tutorials.
Video tutorials
A brief, but succinct, video introduction to using the 433MHz transmitter/receiver pair in conjunction with a pair of Arduinos.
Shows that a 433MHz signal requires a 173mm quarter wave dipole, as well as recommending the RadioHead Packet Radio library.
This video, which is part of a series from EEEnthusiast, shows the transmitter/receiver pair being used without an Arduino, which is interesting. Also, some useful code displaying the signals received from the receiver.
Bringing it all together
Now, by combining Julian Ilett‘s code from Arduino Nokia 5110 LCD Tutorial #3 – Live Numerical Data, with the code from Arduino Tut. #8 – Wireless RF Links Tutorial & Noise Reduction, the video tutorial above, you end up with
/* Original code from https://www.youtube.com/watch?v=cwsCxUhHbQM Julian Ilets 433MHz/Certainty code from https://www.youtube.com/watch?t=370&v=RHJVyMYJ1XQ */ // For Nano Expansion Shield /* #define RST 12 #define CE 11 #define DC 10 #define DIN 9 #define CLK 8 */ // For Leonardo Joystick Shield with blue LCD /* #define RST 9 #define CE 10 #define DC 11 #define DIN 12 #define CLK 13 */ // For Leonardo Joystick Shield with Red #define RST 12 #define CE 13 #define DC 11 #define DIN 10 #define CLK 9 #define PROBE_PIN A0 #define LED_PIN 13 #include "font.h"; int certainty = 0; void LcdWriteString(char *characters) { while(*characters) LcdWriteCharacter(*characters++); } void LcdWriteCharacter(char character) { for(int i=0; i<5; i++) LcdWriteData(ASCII[character - 0x20][i]); LcdWriteData(0x00); } void LcdWriteData(byte dat) { digitalWrite(DC, HIGH); //DC pin is low for commands digitalWrite(CE, LOW); shiftOut(DIN, CLK, MSBFIRST, dat); //transmit serial data digitalWrite(CE, HIGH); } void LcdXY(int x, int y) { LcdWriteCmd(0x80 | x); // Column. LcdWriteCmd(0x40 | y); // Row. } void LcdWriteCmd(byte cmd) { digitalWrite(DC, LOW); //DC pin is low for commands digitalWrite(CE, LOW); shiftOut(DIN, CLK, MSBFIRST, cmd); //transmit serial data digitalWrite(CE, HIGH); } void setup() { pinMode(RST, OUTPUT); pinMode(CE, OUTPUT); pinMode(DC, OUTPUT); pinMode(DIN, OUTPUT); pinMode(LED_PIN, OUTPUT); digitalWrite(RST, LOW); digitalWrite(RST, HIGH); LcdWriteCmd(0x21); // LCD extended commands LcdWriteCmd(0xbf); // set LCD Vop (contrast) LcdWriteCmd(0x04); // set temp coefficent LcdWriteCmd(0x10); // LCD bias mode 1:40 LcdWriteCmd(0x20); // LCD basic commands LcdWriteCmd(0x0C); // LCD normal video for(int i=0; i<504; i++) LcdWriteData(0x00); // clear LCD LcdXY(0,2); LcdWriteString("VOLTAGE:"); } char string[8]; void loop() { float voltage = analogRead(PROBE_PIN) * 5.0 / 1024; LcdXY (50,2); LcdWriteString(dtostrf(voltage,5,2,string)); if (voltage > 4.75){ certainty++; } else { certainty = 0; } if (certainty >= 4) { digitalWrite(LED_PIN, HIGH); } else { digitalWrite(LED_PIN, LOW); } delay(50); }
Load this on to the Leonardo, sporting a Joystick shield, as mentioned in Is your backlight pin in the wrong place?
Now, connect the output of the receiver to A0 on the Arduino, like so (Fritzing diagram omits the joystick shield, and LED on pin D13, for clarity),
with the Transmitter circuit having a momentary push button between ATAD and Vcc
you end up with a display on the LCD screen, in lieu of using the serial port, showing the received voltage, as well as the LED lighting up, upon the button press.
Note: The fritzing diagrams are taken from 433 MHz RF module with Arduino Tutorial 1
One thought on “Carry on HF screaming”