Rev p reading infinity

Questions about Modern Device and JeeLabs Sensors
Vangarden
Posts: 1
Joined: Sat Jan 14, 2023 10:00 am

Rev p reading infinity

Post by Vangarden »

https://drive.google. com/file/d/1QXInc6zM06QmNlldWmbFaDUJM8M5aZGF/view?usp=drivesdk Good morning, I recently bought a wind sensor rev p that I can't get to work properly. My circuit consists of a small i2c oled screen and the wind sensor connected to a seeed xiao rp2040. Powered by a 12vdc supply. My sketch is as follows and should be pretty much the same as the provided sketch, but outputting to the oled rather than serial.

Code: Select all

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET     -1

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

const int ReadButton = 2;
const int WindOutpin  = A0;
const int WindTempOutpin = A1;

int ReadButtonState = 0;

void setup() {
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000);
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 10);
  display.println("Please Wait!");
  display.setCursor(1, 0);
  display.println("ENV 1.0");
  display.display(); 
  delay(5000);
  display.clearDisplay();
  display.display();
         
  pinMode(ReadButton, INPUT);
}

void loop() {
    int WindRead = analogRead(A0);
    float WindMPH =  pow((((float)WindRead - 264.0) / 85.6814), 3.36814);
    int WindTempRead = analogRead(A1);  
    float WindTemp = (((((float)WindTempRead * 5.0) / 1024.0) - 0.400) / .0195);
    //String WindO = String(WindMPH);
    //String WindT = String(WindTemp);
    display.clearDisplay();
    display.setCursor(0, 0);  
    display.println("Wind Speed");
    display.setCursor(0, 10);   
    display.println(WindMPH);
    display.setCursor(60, 10);       
    display.println("MPH");
    display.setCursor(0, 20);            
    display.println(WindTemp); 
    display.setCursor(60, 20);
    display.println("C");
    display.display();
    delay(300);
}