2021年3月31日星期三

how to get sensor output to oled instead of serial console (eventualy maybe adafruit IO?)

i already posted this in the forum of adafruit itself but there is not a lot of help. the message i wrote there was :

hello everyone,

i am just getting started on the adafruit platform, i bough an adafruit HUZZAH! with an esp8266 chip (i switched from lua to arduino IDE) so i could learn on how to use this board. i also ordered the oled 128x64 feather which has a stemma connector to it, so i thought "lets buy a temperature/humidity sensor module too". but when i look it up i cannot find any way to use it with either the oled (which was my intended use: reading temps/humidity and streaming them to the oled just as in the video from the oled demo).

but since i saw a bit of `adafruitIO i kinda want to have it do both. i would like it to push the sensor data from the sensor to the oled (i think you first let it print to the serial monitor and from there you let it write to the display?). i will put a link down to the dispay i have so you can see the video itself where they use the setup i currently have in front of me (unfortunately without code ;( )

product links:

adafruit HUZZAH! : https://www.adafruit.com/product/2821 adfafruit oled: https://www.adafruit.com/product/4650 adafruit temp/humid sensor (AHT20): https://www.adafruit.com/product/4566 (do note that i have this connected to a STEMMA connector cable, it works. tested in the serial console)

oled demo/video that i want to re-create: https://cdn-shop.adafruit.com/product-videos/1200x900/4650-08.mp4

the only thing is that there wasn't a lot of help in the forum there... i kinda still suck at the making of this but i managed to at least get the serial data tot the oled by changing serial.print(); to display.print();.

the code i have:

#include <Adafruit_AHTX0.h>  #include <SPI.h>  #include <Wire.h>  #include <Adafruit_GFX.h>  #include <Adafruit_SH110X.h>  Adafruit_AHTX0 aht;  Adafruit_SH110X display = Adafruit_SH110X(64, 128, &Wire);    void setup() {    display.begin(0x3C, true); // Address 0x3C default    display.display();    delay(500);    display.clearDisplay();    display.display();    display.setTextSize(1);    display.setTextColor(SH110X_WHITE);    display.setCursor(0,0);    display.setRotation(1);    Serial.begin(115200);    Serial.println("Adafruit AHT10/AHT20 demo!");      if (! aht.begin()) {      Serial.println("Could not find AHT? Check wiring");      while (1) delay(10);    }    Serial.println("AHT10 or AHT20 found");  }    void loop() {    sensors_event_t humidity, temp;    aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data    Serial.print("Temperature: "); display.setCursor (0,0); display.print(temp.temperature); Serial.println(" °C");    Serial.print("Humidity: "); display.setCursor (0,8); display.print(humidity.relative_humidity); Serial.println("%");    display.display();    display.clearDisplay();    display.display();    delay(250);  }  

the problem is that if i use display.clearDisplay(); it clears the whole buffer (blackens the oled). but instead of that i want to have the same thing as what i commented on the other thread.

i was hoping to get it as smooth updating as this:

oled demo/video that i want to re-create: https://cdn-shop.adafruit.com/product-videos/1200x900/4650-08.mp4

https://stackoverflow.com/questions/66897182/how-to-get-sensor-output-to-oled-instead-of-serial-console-eventualy-maybe-adaf April 01, 2021 at 09:05AM

没有评论:

发表评论