Help with BME280 Example

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
spiney
 
Posts: 214
Joined: Mon Jul 09, 2012 6:35 am

Re: Help with BME280 Example

Post by spiney »

Having updated my weather Station project by changing to BME280 and a Mega, the only thing that was not working was the counting of the raingauge tipper. I now find that despite having PinChangInt_Master loaded in Documents\Arduino\library it does not appear when I try to find an example while running the IDE. When I opened the library in my documents directly I discovered that there was no Example in the library file. So I kicked it out and downloaded PinChangeInt again and pasted it back to docs\Ard\lib. Now examples do appear and also when running the IDE PinChangeInt does appear in the library list. The examples do run and write gobbledegook to the Serial Monitor but the rain gauge Interrupt still does not work. This is where the interrups are coded in my project. I am a rank amateur so if anyone can see a silly mistake that stops the interrupt working with a Mega I should be grateful. (It did work with a Uno.)

Code: Select all

#include <avr/wdt.h>
#include <SD.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <RTClib.h>
#include <Time.h>
#include <TimeAlarms.h>
#include <Adafruit_RGBLCDShield.h>
#include <PinChangeInt.h>
#define PIN 3  // the pin for button/ rain gauge
#define STOP_SWITCH 2

Code: Select all

 pinMode(PIN, INPUT);     //set the pin to input
  digitalWrite(PIN, LOW); //use the internal pullup resistor
  PCintPort::attachInterrupt(PIN, burpcount,RISING); // attach a PinChange
 // Interrupt to our pin on the rising edge
  // (RISING, FALLING and CHANGE all work with this library)
  // and execute the function burpcount when that pin changes 
Franklin: I am going to try to download a later version into "a directory of its own" if I can; previously later versions deleted earlier ones.

User avatar
spiney
 
Posts: 214
Joined: Mon Jul 09, 2012 6:35 am

Re: Help with BME280 Example

Post by spiney »

Second PS.
Franklin.
No, could not install a second IDE. Evidently I do not know how to make a suitable directory. Running the IDE installation does not offer any choices of where it should be put either.

User avatar
Franklin97355
 
Posts: 23911
Joined: Mon Apr 21, 2008 2:33 pm

Re: Help with BME280 Example

Post by Franklin97355 »

Running the IDE installation does not offer any choices of where it should be put either.
You are downloading the installer, don't. Instead download the zip file and unzip that into a directory. If you need a previous version there is a place to get those also.
Attachments
2017-06-21_09h27_56.png
2017-06-21_09h27_56.png (14.3 KiB) Viewed 354 times
2017-06-21_09h27_45.png
2017-06-21_09h27_45.png (15.69 KiB) Viewed 354 times

User avatar
spiney
 
Posts: 214
Joined: Mon Jul 09, 2012 6:35 am

Re: Help with BME280 Example

Post by spiney »

Success, finally.
I reinstalled IDE 1.0.5 and used only the old library files on Windows Vista.
I picked out the Interrupt coding from the weather station sketch and tried it on a Uno. Interrupts worked. I tried it with a Mega – Interrupts did not work.
On the Internet I found examples using "attachInterrupt". I modified a simple example code. This would not verify on IDE 1.0.5. I moved to a Windows 7 machine running IDE 1.6.5 and the code verified and worked with both Uno and Mega. There was 1 Megohm pulldown and a pushbutton to 5V for digital pin 3.

Code: Select all

//#include <PinChangeInt.h>
#define PIN 3  // the pin for button/ rain gauge
volatile int flag=0;
int nflag;

void setup()
{  
  Serial.begin(9600);

  pinMode(PIN3, INPUT);     //set the pin to input
  digitalWrite(PIN3, LOW); //use the internal pullup resistor
  attachInterrupt(digitalPinToInterrupt(3), burpcount, RISING);
 // PCintPort::attachInterrupt(PIN3, burpcount,RISING); // attach a PinChange Interrupt to our pin on the rising edge
  // (RISING, FALLING and CHANGE all work with this library)
  // and execute the function burpcount when that pin changes
  Serial.println("---------------------------------------"); 
}

void loop()
{
  delay(3000);
Serial.print(flag);
}
void burpcount()
{
  flag++;  } 
I switched back to the Dell running Vista and loaded IDE 1.5.6-r2 and the example did verify and run with both Uno and Mega.
Then I changed the weather station code to use attachInterrupts and tried to run it on the Mega. It did work after I had installed the later SD_Master. Here are the relevant lines.

Code: Select all

 pinMode(PIN, INPUT);     //set the pin to input
  digitalWrite(PIN, LOW); 
 attachInterrupt(digitalPinToInterrupt(3), burpcount, RISING);
 // PCintPort::attachInterrupt(PIN, burpcount,RISING); // attach a PinChange Interrupt to our pin on the rising edge
  // (RISING, FALLING and CHANGE all work with this library)
  // and execute the function burpcount when that pin changes 
I believe that the attachInterrupt function is internal in IDE code later than 007 – how that translates to the 1.*.* IDEs I do not know, but 1.5.6-r2 is OK. It seems that PinChangeInt does not work with Megas.
Seems to me that Arduino is no longer easy for amateurs, thanks to lack of backward compatibility issues.
And, No, I did not succeed in getting two IDE’s running in Vista, by my ignorance and lack of detailed advice.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”