Hi,
I am using a version of the library that I changed to work with MS5535 sensor.
I am using it with Teensy 3.1 and AdafruitST7735 TFT. The problems I have are not being able to read data from the pressure sensor as soon as I want to use the TFT.
#define sclk 13 // SCLK can also use pin 14
#define mosi 11 // MOSI can also use pin 7
#define cs 10 // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define dc 9 // but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#define rst 8 // RST can use any pin
#define sdcs 4 // CS for SD card, can use any pin
#define lite 5 // TFT backlite
#define presscs 6 // Pressures sensor cs
#define miso 12 //MISO
#include <MS55xx.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#if defined(__SAM3X8E__)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif
//Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);
//creating the sensor
MS55xx PressSensor;
float airPressure;
float waterPressure=0;
void setup() {
pinMode(sdcs, INPUT_PULLUP);
Serial.begin(9600);
pinMode(presscs, OUTPUT);
digitalWrite(presscs, HIGH);
pinMode(5, OUTPUT);
digitalWrite(5, HIGH);
pinMode(23, OUTPUT);
digitalWrite(23, HIGH);
tft.initR(INITR_BLACKTAB);
tft.setRotation(tft.getRotation()+1);
tft.fillScreen(ST7735_BLACK);
PressSensor.setPressureSensorType(5535);
//start arduino before diving
//otherwise a 1.0 bar is used as surface pressure
digitalWrite(presscs, LOW);
delay(10);
PressSensor.update();
digitalWrite(presscs, HIGH);
airPressure = PressSensor.getPressureBar();
if (airPressure > 1.2) {
airPressure = 1.0;
}
tft.fillScreen(ST7735_BLACK);
}
void loop() {
//Before getting the values you need to update the sensor
digitalWrite(presscs, LOW);
delay(10);
PressSensor.update();
digitalWrite(presscs, HIGH);
//get pressure
waterPressure = PressSensor.getPressureBar() - airPressure;
Serial.print("Deep (meters): ");
Serial.println(abs(waterPressure)*10.0,1);
tft.setTextSize(2);
tft.setCursor(0,0);
tft.setTextColor(ST7735_GREEN);
tft.println(abs(waterPressure)*10.0,1);
//get 2nd temperature --> see datasheet for details
Serial.print("Temperatre 2nd (celsius): ");
//Serial.println(PressSensor.get2ndTemperatureC());
Serial.println();
delay(2000);
}
I added in library another line in both the Update() method and read Coeficients method the line
SPI.setDataMode(SPI_MODE0);
to alow AdafruitST7735 to work correctely.
Problem that remain is no correct data from pressure sensor.
Can anyone help?