Hi,
I have an arduino micro and a RPi.
I am trying to connect these two using 433MHz RF links with the arduino transmitting and the RPi receiving.
I have programmed a RGB sensor (ISL29125) to read red light levels and when the reading drops below a set value i changes from 0 to 1.
I want to transmit i to the pi and when the pi receives a 1 I want it to launch kweb browser.
I am new to this with little knowledge so any help would be greatly appreciated.
Thanks
/**********************************************
Adam Wallace - FYDP Code
Abnormality Sensor - RGB Sensor
**********************************************/
#include <Wire.h>
#include <SparkFunISL29125.h>
// Declare sensor object
SFE_ISL29125 RGB_sensor;
unsigned int i = 0; // The number of triggered interrupts
void setup()
{
// Set up Notification LED pins
pinMode(4, OUTPUT); // set pin 4 as output
pinMode(5, OUTPUT); // set pin 5 as output
pinMode(6, OUTPUT); // set pin 6 as output
pinMode(7, OUTPUT); // set pin 7 as output
pinMode(8, OUTPUT); // set pin 8 as output
pinMode(9, OUTPUT); // set pin 9 as output
pinMode(10, OUTPUT); // set pin 10 as output
pinMode(11, OUTPUT); // set pin 11 as output
pinMode(12, OUTPUT); // set pin 12 as output
// Set up RF transmitter pin
pinMode(1, OUTPUT); //set TX pin as output
// Initialize serial communication - USB and TTL
Serial1.begin(9600);
Serial.begin(9600);
// Initialize the RGB Sensor
(RGB_sensor.init());
}
void loop()
{
static unsigned int lasti = 0; // Stores the number of the last interrupt
// Turn notification LEDs on
digitalWrite(4, HIGH); // set pin 4 as high
digitalWrite(5, HIGH); // set pin 5 as high
digitalWrite(6, HIGH); // set pin 6 as high
digitalWrite(7, HIGH); // set pin 7 as high
digitalWrite(8, HIGH); // set pin 8 as high
digitalWrite(9, HIGH); // set pin 9 as high
digitalWrite(10, HIGH); // set pin 10 as high
digitalWrite(11, HIGH); // set pin 11 as high
digitalWrite(12, HIGH); // set pin 12 as high
// Set RF transmitter pin high
digitalWrite(1, HIGH); // set TX pin output low
{
// Read the detected light intensity of the red visible spectrum
RGB_sensor.readRed();
// Print out the i value used for communication when red light levels are low
Serial.print("i # = ");
Serial.println(i);
Serial.println(RGB_sensor.readRed());
Serial1.print(i);
delay (500);
// Set lasti to i, so that this if statement is not entered again until another interrupt is triggered
i = lasti;
}
if (RGB_sensor.readRed() < 350)
{
i = 1; // when red light levels are low i = 1
}
}
Sensor_FYDP.ino (2.21 KB)