Not getting correct value from BH1750
-
I managed to get all three of these working:
- NRFL as client
- OLED SPI 128x64
- BM1750
My C programming is a bit rusty I hope someone could help me. I'm planning to use the OLED screen as a "serial console" rather than plugging in a USB all the time. However, when I use the readLightLeve() from BH1750 libraries, on my SPI I'm getting gibberish characters. I suspect because the u8g.print() anticipates a char
Any ideas how do I fix this? Here's the draw() function I used within the loop
void draw(void) {
uint16_t lux;
lux = lightMeter.readLightLevel();
u8g.drawBitmapP( 76, 5, 6, 50, logo);
u8g.setFont(u8g_font_unifont);
u8g.drawStr(0, 30, "Lux: ");
u8g.setPrintPos(44, 30);
u8g.print( lux , 0);
}
-
Hello, a search on Google with keywords "u8g print integer" or "u8g print variable" will give answers to your questions
For example :
http://arduino.stackexchange.com/questions/17766/how-to-display-variables-on-0-96-oled-with-u8glib-library
-
Thanks @Nca78 ! That worked!