hi all,
i try to run my teacher codes for my homework.
when i open it, the code doesnt seem working neither verify nor upload. i pretty sure no problem with the port or cable because i tried with another code and it worked just well.
could someone please help?
thanks
/////////////////////
Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"
\claudius.science.mq.edu.au\44613156.Desktop\Smart_City_Client_3_Final_Hopefully_\Smart_City_Client_3_Final_Hopefully_.ino:11:21: fatal error: RH_RF95.h: No such file or directory
#include <RH_RF95.h>
^
compilation terminated.
exit status 1
Error compiling for board Arduino/Genuino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
.....
here is my code:
#include <RH_RF95.h>
#include <String.h>
#include <TimerOne.h>
// Hardware configuration ////////////////////////////////////////////////////////
int PIR1 = A0; // the pin that the sensor is atteched to
int PIR2 = A1;
int PIR3 = A2;
int state = LOW; // by default, no motion detected
int sam, isam; int state1 = LOW, state2 = LOW;
// Variable declaration ******************************************************
#define MINUTE_VALUE 1
int i = 0; // variable to store the sensor status (value)
int counter = 0, backup = 0;
int second = 0, minute = 0;
int flag_status = 0;
// Function Prototypes &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
void dataUpload();
void sensor1();
void sensor2();
void sensor3();
//****************************************************************************
RH_RF95 rf95;
byte bGlobalErr;
String stringOne;
float frequency = 915.0;
void setup()
{
Serial.begin(9600);
if (!rf95.init())
Serial.println("init failed");
// Setup ISM frequency
rf95.setFrequency(frequency);
// Setup Power,dBm
rf95.setTxPower(13);
Serial.println("START");
pinMode(PIR1, INPUT); // initialize sensor as an input
pinMode(PIR2, INPUT); // initialize sensor as an input
pinMode(PIR3, INPUT); // initialize sensor as an input
Timer1.initialize(1000000);
Timer1.attachInterrupt(dataUpload);
}
uint16_t calcByte(uint16_t crc, uint8_t b)
{
uint32_t i;
crc = crc ^ (uint32_t)b << 8;
for ( i = 0; i < 8; i++)
{
if ((crc & 0x8000) == 0x8000)
crc = crc << 1 ^ 0x1021;
else
crc = crc << 1;
}
return crc & 0xffff;
}
uint16_t CRC16(uint8_t pBuffer, uint32_t length)
{
uint16_t wCRC16 = 0;
uint32_t i;
if (( pBuffer == 0 ) || ( length == 0 ))
{
return 0;
}
for ( i = 0; i < length; i++)
{
wCRC16 = calcByte(wCRC16, pBuffer);*
- }*
- return wCRC16;*
}
void loop()
{ - char data[50] = {0} ;*
- // Use data[0], data[1],data[2] as Node ID*
- data[0] = 3 ;*
- data[1] = 2 ;*
- data[2] = 1 ;*
- data[3] = 10;*
- data[4] = 20;*
- sensor1();*
- sensor2();*
- sensor3();*
- if (flag_status)*
- {*
- backup = counter;*
- data[3] = backup;*
- Serial.println("Number of pedestarians in the last 2 minutes:");*
- Serial.println(backup);*
- int dataLength = strlen(data);//CRC length for LoRa Data*
-
//Serial.println(dataLength);*
uint16_t crcData = CRC16((unsigned char*)data, dataLength); //get CRC DATA - //Serial.println(crcData);*
- unsigned char sendBuf[50] = {0};*
- int i;*
- for (i = 0; i < 8; i++)*
- {*
sendBuf = data ;
* }*
* sendBuf[dataLength] = (unsigned char)crcData; // Add CRC to LoRa Data*
* //Serial.println( sendBuf[dataLength] );*
* sendBuf[dataLength + 1] = (unsigned char)(crcData >> 8); // Add CRC to LoRa Data*
* //Serial.println( sendBuf[dataLength+1] );*
_ rf95.send(sendBuf, strlen((char*)sendBuf));//Send LoRa Data_
_ //Serial.print(strlen((char*)sendBuf));
* uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];//Reply data array*
* uint8_t len = sizeof(buf);//reply data length*
* if (rf95.waitAvailableTimeout(3000))// Check If there is reply in 3 seconds.
{
// Should be a reply message for us now*
* if (rf95.recv(buf, &len))//check if reply message is correct*
* {
if (buf[0] == 1 || buf[1] == 1 || buf[2] == 1) // Check if reply message has the our node ID*
* {
Serial.print("got reply: ");//print reply*
Serial.println((char*)buf);
* delay(400);
//Serial.print("RSSI: "); // print RSSI*
* //Serial.println(rf95.lastRssi(), DEC);
}
}
else*
* {
Serial.println("recv failed");//
rf95.send(sendBuf, strlen((char)sendBuf));//resend if no reply_
* }*
* }*
* else*
* {*
* Serial.println("No reply, is rf95_server running?");//No signal reply*
_ rf95.send(sendBuf, strlen((char*)sendBuf));//resend data_
* }*
* flag_status = 0;
_ }
}
// Function defination ////////////////////////////////////////////////////////////////////////
void dataUpload() {
second++;
if (second == 59) {
second = 0;
minute++;
}_
if (minute == MINUTE_VALUE) {
_ second = 0;
minute = 0;_
flag_status = 1;
_ }
}
void sensor1() {
i = digitalRead(PIR1); // read sensor value*
* if (i == HIGH) { // check if the sensor is HIGH*
* delay(100); // delay 100 milliseconds*
* if (state == LOW) {
Serial.println("SENSOR 111 is detected!");
state = HIGH; // update variable state to HIGH*
* counter++;
}
}
else {
delay(200); // delay 200 milliseconds*
* if (state == HIGH) {
Serial.println("SENSOR 111 is stopped!");
state = LOW; // update variable state to LOW*
* }
}
}
void sensor2() {
sam = digitalRead(PIR2); // read sensor value*
* if (sam == HIGH) { // check if the sensor is HIGH*
* delay(100); // delay 100 milliseconds*
//
* if (state1 == LOW) {
Serial.println("SENSOR 222 is detected!");
state1 = HIGH; // update variable state to HIGH*
* counter++;
}
}
else {
delay(200); // delay 200 milliseconds*
* if (state1 == HIGH) {
Serial.println("SENSOR 222 is stopped!");
state1 = LOW; // update variable state to LOW*
* }
}
}
void sensor3() {
isam = digitalRead(PIR3); // read sensor value*
* if (isam == HIGH) { // check if the sensor is HIGH*
* delay(100);
if (state2 == LOW) {
Serial.println("SENSOR 333 is detected!");
state2 = HIGH; // update variable state to HIGH*
* counter++;
}
}
else {
delay(200); // delay 200 milliseconds*
* if (state2 == HIGH) {
Serial.println("SENSOR 333 is stopped!");
state2 = LOW; // update variable state to LOW*
* }
}
}*_