I recently created my first custom PCB, producing what is essentially an Arduino pro mini clone with a few devices on the PCB, those being a logic level shifter, LTC4311, DRV2605L, and ms560702ba03-50. Off of the PCB, I also have an adafruit clear turbine water flow sensor. I've been using this library for the pressure sensor using the stock example code here:
/*
MS5xxx.h - Library for accessing MS5xxx sensors via I2C
Copyright (c) 2012 Roman Schmitz
This file is part of arduino-ms5xxx.
arduino-ms5xxx is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
arduino-ms5xxx is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with arduino-ms5xxx. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Wire.h>
#include <MS5xxx.h>
MS5xxx sensor(&Wire);
void setup() {
Serial.begin(9600);
if(sensor.connect()>0) {
Serial.println("Error connecting...");
delay(500);
setup();
}
}
void loop() {
sensor.ReadProm();
sensor.Readout();
Serial.print("Temperature [0.01 C]: ");
Serial.println(sensor.GetTemp());
Serial.print("Pressure [Pa]: ");
Serial.println(sensor.GetPres());
test_crc();
Serial.println("---");
delay(500);
}
void test_crc() {
sensor.ReadProm();
sensor.Readout();
Serial.print("CRC=0x");
Serial.print(sensor.Calc_CRC4(), HEX);
Serial.print(" (should be 0x");
Serial.print(sensor.Read_CRC4(), HEX);
Serial.print(")\n");
Serial.print("Test Code CRC=0x");
Serial.print(sensor.CRCcodeTest(), HEX);
Serial.println(" (should be 0xB)");
}
I used a simple interrupt function to use the flow sensor.
However, the instant I try to use these sensors at the same time, my controller seems to freak out and I have to go through the process for de-bricking the processor found here. I can't even have the text "noInterrupts();" written in the pressure sensor code, or it will brick the processor. Is there something here that I am missing, or is it possible to read the flow sensor without interrupts? Any help is appreciated, thanks.
Please show your code where the two sketches are combined.
Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project See About the Installation & Troubleshooting category.
As I mentioned though, even having a single line that disables interrupts is enough to break everything in the pressure sensor code. I've also tried using this library, and had the same issues with the board bricking, so it seems like the library might not be the issue. @Koepel I'm using an ATmega32U4 not a 328p, does that matter?
A Pro Mini is a ATmega328P.
A Pro Micro is a ATmega32U4.
They are both part of the AVR family microcontrollers.
Which pin of the ATmega32U4 is pin 0 on the Pro Micro ? Is that PD2, pin 20 on the chip ?
Would that be interrupt INT2 ? I'm not sure if you can use the number '2' for attachInterrupt().
This is recommended:
I don't see the problem, sorry. Can you use 115200 baud instead of 9600 ? Can you remove the disabling of the interrupt ? If millis() is checked, then the time is known and that can be used in a calculation.
While you are at it, remove also the delay() from the loop().